[pypy-commit] stmgc c7-refactor: Some more comments and figuring out that a particular point is not

arigo noreply at buildbot.pypy.org
Mon Feb 17 11:37:14 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r756:2d3e642f4330
Date: 2014-02-17 11:36 +0100
http://bitbucket.org/pypy/stmgc/changeset/2d3e642f4330/

Log:	Some more comments and figuring out that a particular point is not
	problematic after all

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -216,7 +216,8 @@
     }
 
     /* wait until the other thread is at a safe-point */
-    wait_for_other_safe_points(SP_SAFE_POINT_CANNOT_COLLECT);
+    if (!try_wait_for_other_safe_points(SP_SAFE_POINT_CANNOT_COLLECT))
+        goto restart;
 
     /* the rest of this function runs either atomically without releasing
        the mutex, or it needs to restart. */
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -69,35 +69,33 @@
     } while (tl != stm_thread_locals);
 }
 
+static void reset_all_nursery_section_ends(void)
+{
+    long i;
+    for (i = 0; i < NB_SEGMENTS; i++) {
+        struct stm_priv_segment_info_s *other_pseg = get_priv_segment(i);
+        /* no race condition here, because all other threads are paused
+           in safe points, so cannot be e.g. in _stm_allocate_slowpath() */
+        other_pseg->real_nursery_section_end = 0;
+        other_pseg->pub.v_nursery_section_end = 0;
+    }
+}
+
 static void do_minor_collection(void)
 {
+    /* all other threads are paused in safe points during the whole
+       minor collection */
+    assert_has_mutex();
+
     minor_trace_roots();
 
-            /* visit shadowstack & add to old_obj_to_trace */
-    object_t **current = _STM_TL->shadow_stack;
-    object_t **base = _STM_TL->shadow_stack_base;
-    while (current-- != base) {
-        trace_if_young(current);
-    }
 
-    
-    
-    
     fprintf(stderr, "minor_collection\n");
     abort(); //...;
 
 
-    /* reset all segments' nursery_section_end, as well as nursery_ctl.used */
-    long i;
-    for (i = 0; i < NB_SEGMENTS; i++) {
-        get_segment(i)->nursery_section_end = 0;
-        get_priv_segment(i)->real_nursery_section_end = 0;
-    }
     nursery_ctl.used = 0;
-
-    /* done */
-    assert(requested_minor_collections == completed_minor_collections + 1);
-    completed_minor_collections += 1;
+    reset_all_nursery_section_ends();
 }
 
 
diff --git a/c7/stm/sync.c b/c7/stm/sync.c
--- a/c7/stm/sync.c
+++ b/c7/stm/sync.c
@@ -202,12 +202,17 @@
        false; you can call repeatedly this function in this case.
 
        When this function returns true, the other threads are all
-       blocked at safe points as requested, until the next time we
-       unlock the mutex (with mutex_unlock() or cond_wait()).
+       blocked at safe points as requested.  They may be either in their
+       own cond_wait(), or running at SP_NO_TRANSACTION, in which case
+       they should not do anything related to stm until the next time
+       they call mutex_lock().
+
+       The next time we unlock the mutex (with mutex_unlock() or
+       cond_wait()), they will proceed.
 
        This function requires that the calling thread is in a safe-point
        right now, so there is no deadlock if one thread calls
-       wait_for_other_safe_points() while another is currently blocked
+       try_wait_for_other_safe_points() while another is currently blocked
        in the cond_wait() in this same function.
     */
     assert_has_mutex();
@@ -251,12 +256,6 @@
     return true;
 }
 
-static void wait_for_other_safe_points(int requested_safe_point_kind)
-{
-    while (!try_wait_for_other_safe_points(requested_safe_point_kind))
-        /* repeat */;
-}
-
 static bool collectable_safe_point(void)
 {
     bool any_operation = false;
@@ -268,6 +267,7 @@
            we end up here as soon as we try to call stm_allocate().
            See try_wait_for_other_safe_points() for details. */
         mutex_lock();
+        assert(STM_PSEGMENT->safe_point == SP_RUNNING);
         STM_PSEGMENT->safe_point = SP_SAFE_POINT_CAN_COLLECT;
         cond_broadcast();
         cond_wait();
diff --git a/c7/stm/sync.h b/c7/stm/sync.h
--- a/c7/stm/sync.h
+++ b/c7/stm/sync.h
@@ -15,6 +15,5 @@
 static void release_thread_segment(stm_thread_local_t *tl);
 
 /* see the source for an exact description */
-static void wait_for_other_safe_points(int requested_safe_point_kind);
 static bool try_wait_for_other_safe_points(int requested_safe_point_kind);
 static bool collectable_safe_point(void);


More information about the pypy-commit mailing list