[pypy-commit] stmgc default: tweaks

arigo noreply at buildbot.pypy.org
Thu Jun 18 18:35:51 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r1861:5b75b3f3a9b7
Date: 2015-06-18 17:01 +0200
http://bitbucket.org/pypy/stmgc/changeset/5b75b3f3a9b7/

Log:	tweaks

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -529,7 +529,7 @@
             enter_safe_point_if_requested();
         }
         else if (STM_PSEGMENT->last_commit_log_entry->next == INEV_RUNNING) {
-            cond_wait(C_SEGMENT_FREE_OR_SAFE_POINT);
+            cond_wait(C_SEGMENT_FREE_OR_SAFE_POINT_REQ);
         }
         s_mutex_unlock();
         goto retry_from_start;   /* redo _stm_validate() now */
@@ -1119,7 +1119,7 @@
 {
     assert(!_stm_in_transaction(tl));
 
-    while (!acquire_thread_segment(tl)) {}
+    acquire_thread_segment(tl);
     /* GS invalid before this point! */
 
     assert(STM_PSEGMENT->safe_point == SP_NO_TRANSACTION);
@@ -1567,7 +1567,7 @@
             s_mutex_lock();
             if (any_soon_finished_or_inevitable_thread_segment() &&
                     !safe_point_requested()) {
-                cond_wait(C_SEGMENT_FREE_OR_SAFE_POINT);
+                cond_wait(C_SEGMENT_FREE_OR_SAFE_POINT_REQ);
             }
             s_mutex_unlock();
             num_waits++;
diff --git a/c8/stm/sync.c b/c8/stm/sync.c
--- a/c8/stm/sync.c
+++ b/c8/stm/sync.c
@@ -188,10 +188,11 @@
 #endif
 
 
-static bool acquire_thread_segment(stm_thread_local_t *tl)
+static void acquire_thread_segment(stm_thread_local_t *tl)
 {
     /* This function acquires a segment for the currently running thread,
        and set up the GS register if it changed. */
+ retry_from_start:
     assert(_has_mutex());
     assert(_is_tl_registered(tl));
 
@@ -225,13 +226,13 @@
         }
     }
     /* No segment available.  Wait until release_thread_segment()
-       signals that one segment has been freed. */
+       signals that one segment has been freed.  Note that we prefer
+       waiting rather than detaching an inevitable transaction, here. */
     timing_event(tl, STM_WAIT_FREE_SEGMENT);
     cond_wait(C_SEGMENT_FREE);
     timing_event(tl, STM_WAIT_DONE);
 
-    /* Return false to the caller, which will call us again */
-    return false;
+    goto retry_from_start;
 
  got_num:
     OPT_ASSERT(num >= 0 && num < NB_SEGMENTS-1);
@@ -242,7 +243,6 @@
     assert(!in_transaction(tl));
     STM_SEGMENT->running_thread = tl;
     assert(in_transaction(tl));
-    return true;
 }
 
 static void release_thread_segment(stm_thread_local_t *tl)
@@ -251,7 +251,7 @@
     assert(_has_mutex());
 
     cond_signal(C_SEGMENT_FREE);
-    cond_broadcast(C_SEGMENT_FREE_OR_SAFE_POINT);   /* often no listener */
+    cond_broadcast(C_SEGMENT_FREE_OR_SAFE_POINT_REQ);  /* often no listener */
 
     assert(STM_SEGMENT->running_thread == tl);
     segnum = STM_SEGMENT->segment_num;
@@ -347,7 +347,7 @@
     assert(!pause_signalled);
     pause_signalled = true;
     dprintf(("request to pause\n"));
-    cond_broadcast(C_SEGMENT_FREE_OR_SAFE_POINT);
+    cond_broadcast(C_SEGMENT_FREE_OR_SAFE_POINT_REQ);
 }
 
 static inline long count_other_threads_sp_running(void)
diff --git a/c8/stm/sync.h b/c8/stm/sync.h
--- a/c8/stm/sync.h
+++ b/c8/stm/sync.h
@@ -5,7 +5,7 @@
     C_AT_SAFE_POINT,
     C_REQUEST_REMOVED,
     C_SEGMENT_FREE,
-    C_SEGMENT_FREE_OR_SAFE_POINT,
+    C_SEGMENT_FREE_OR_SAFE_POINT_REQ,
     _C_TOTAL
 };
 
@@ -23,7 +23,7 @@
 
 /* acquire and release one of the segments for running the given thread
    (must have the mutex acquired!) */
-static bool acquire_thread_segment(stm_thread_local_t *tl);
+static void acquire_thread_segment(stm_thread_local_t *tl);
 static void release_thread_segment(stm_thread_local_t *tl);
 static void soon_finished_or_inevitable_thread_segment(void);
 static bool any_soon_finished_or_inevitable_thread_segment(void);


More information about the pypy-commit mailing list