Commits

Remi Meier committed d5b9623

import stmgc 3b302406acd8

Comments (0)

Files changed (6)

rpython/translator/stm/src_stm/revision

-31f9797a356c
+3b302406acd8

rpython/translator/stm/src_stm/stm/contention.c

 /************************************************************/
 
 
-static void contention_management(uint8_t other_segment_num,
+static bool contention_management(uint8_t other_segment_num,
                                   enum contention_kind_e kind,
                                   object_t *obj)
 {
     assert(_has_mutex());
     assert(other_segment_num != STM_SEGMENT->segment_num);
 
+    bool others_may_have_run = false;
     if (must_abort())
         abort_with_mutex();
 
 
     if (contmgr.try_sleep && kind != WRITE_WRITE_CONTENTION &&
         contmgr.other_pseg->safe_point != SP_WAIT_FOR_C_TRANSACTION_DONE) {
+        others_may_have_run = true;
         /* Sleep.
 
            - Not for write-write contentions, because we're not at a
             if (must_abort())
                 abort_with_mutex();
 
+            others_may_have_run = true;
             dprintf(("contention: wait C_ABORTED...\n"));
             cond_wait(C_ABORTED);
             dprintf(("contention: done\n"));
             stmcb_commit_soon();
         }
     }
+    return others_may_have_run;
 }
 
 static void write_write_contention_management(uintptr_t lock_idx,
     s_mutex_unlock();
 }
 
-static void write_read_contention_management(uint8_t other_segment_num,
+static bool write_read_contention_management(uint8_t other_segment_num,
                                              object_t *obj)
 {
-    contention_management(other_segment_num, WRITE_READ_CONTENTION, obj);
+    return contention_management(other_segment_num, WRITE_READ_CONTENTION, obj);
 }
 
 static void inevitable_contention_management(uint8_t other_segment_num)

rpython/translator/stm/src_stm/stm/contention.h

 
 static void write_write_contention_management(uintptr_t lock_idx,
                                               object_t *obj);
-static void write_read_contention_management(uint8_t other_segment_num,
+static bool write_read_contention_management(uint8_t other_segment_num,
                                              object_t *obj);
 static void inevitable_contention_management(uint8_t other_segment_num);
 

rpython/translator/stm/src_stm/stm/core.c

             ({
                 if (was_read_remote(remote_base, item, remote_version)) {
                     /* A write-read conflict! */
-                    write_read_contention_management(i, item);
-
-                    /* If we reach this point, we didn't abort, but maybe we
-                       had to wait for the other thread to commit.  If we
-                       did, then we have to restart committing from our call
-                       to synchronize_all_threads(). */
-                    return true;
+                    if (write_read_contention_management(i, item)) {
+                        /* If we reach this point, we didn't abort, but we
+                           had to wait for the other thread to commit.  If we
+                           did, then we have to restart committing from our call
+                           to synchronize_all_threads(). */
+                        return true;
+                    }
+                    /* we aborted the other transaction without waiting, so
+                       we can just continue */
                 }
             }));
     }
     /* the call to minor_collection() above leaves us with
        STM_TIME_BOOKKEEPING */
 
+    /* synchronize overflow objects living in privatized pages */
+    push_overflow_objects_from_privatized_pages();
+
     s_mutex_lock();
 
  restart:
     STM_SEGMENT->jmpbuf_ptr = NULL;
 
     /* if a major collection is required, do it here */
-    if (is_major_collection_requested())
+    if (is_major_collection_requested()) {
+        int oldstate = change_timing_state(STM_TIME_MAJOR_GC);
         major_collection_now_at_safe_point();
-
-    /* synchronize overflow objects living in privatized pages */
-    push_overflow_objects_from_privatized_pages();
+        change_timing_state(oldstate);
+    }
 
     /* synchronize modified old objects to other threads */
     push_modified_to_other_segments();

rpython/translator/stm/src_stm/stm/sync.c

     long i;
  restart:
     for (i = 1; i <= NB_SEGMENTS; i++) {
-        if (get_priv_segment(i)->transaction_state == TS_INEVITABLE) {
+        struct stm_priv_segment_info_s *other_pseg = get_priv_segment(i);
+        if (other_pseg->transaction_state == TS_INEVITABLE) {
             if (tl_or_null_if_can_abort == NULL) {
                 /* handle this case like a contention: it will either
                    abort us (not the other thread, which is inevitable),
             else {
                 /* wait for stm_commit_transaction() to finish this
                    inevitable transaction */
+                signal_other_to_commit_soon(other_pseg);
                 change_timing_state_tl(tl_or_null_if_can_abort,
                                        STM_TIME_WAIT_INEVITABLE);
                 cond_wait(C_INEVITABLE);
 static bool _safe_points_requested = false;
 #endif
 
-static void signal_other_to_commit_soon(struct stm_priv_segment_info_s *other_pseg)
+void signal_other_to_commit_soon(struct stm_priv_segment_info_s *other_pseg)
 {
     assert(_has_mutex());
     /* never overwrite abort signals or safepoint requests

rpython/translator/stm/src_stm/stm/sync.h

 static void committed_globally_unique_transaction(void);
 
 static bool pause_signalled, globally_unique_transaction;
+
+void signal_other_to_commit_soon(struct stm_priv_segment_info_s *other_pseg);