[pypy-commit] stmgc c8-private-pages: progress

Raemi noreply at buildbot.pypy.org
Fri Jan 16 16:36:19 CET 2015


Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: c8-private-pages
Changeset: r1535:50c110de7f3a
Date: 2015-01-16 13:53 +0100
http://bitbucket.org/pypy/stmgc/changeset/50c110de7f3a/

Log:	progress

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -298,9 +298,6 @@
         cl = first_cl;
         while ((next_cl = cl->next) != NULL) {
             if (next_cl == INEV_RUNNING) {
-#if STM_TESTS
-                stm_abort_transaction();
-#endif
                 /* only validate entries up to INEV */
                 break;
             }
@@ -337,6 +334,8 @@
                             */
                             reset_modified_from_backup_copies(my_segnum);
                             needs_abort = true;
+
+                            dprintf(("_stm_validate() failed for obj %p\n", undo->object));
                             break;
                         }
                     }
@@ -419,6 +418,14 @@
             stm_abort_transaction();
         }
 
+#if STM_TESTS
+        if (STM_PSEGMENT->transaction_state != TS_INEVITABLE
+            && STM_PSEGMENT->last_commit_log_entry->next == INEV_RUNNING) {
+            /* abort for tests... */
+            stm_abort_transaction();
+        }
+#endif
+
         /* try to attach to commit log: */
         old = STM_PSEGMENT->last_commit_log_entry;
         if (old->next == NULL) {
@@ -479,7 +486,6 @@
         stm_abort_transaction();
     }
 #endif
-
 }
 
 
diff --git a/c8/stm/core.h b/c8/stm/core.h
--- a/c8/stm/core.h
+++ b/c8/stm/core.h
@@ -216,7 +216,7 @@
 {
 #ifndef NDEBUG
     long l;
-    for (l = 1; l < NB_SEGMENTS; l++) {
+    for (l = 0; l < NB_SEGMENTS; l++) {
         if (!get_priv_segment(l)->privatization_lock)
             return false;
     }
@@ -228,8 +228,9 @@
 
 static inline void acquire_all_privatization_locks()
 {
+    /* XXX: don't do for the sharing seg0 */
     long l;
-    for (l = 1; l < NB_SEGMENTS; l++) {
+    for (l = 0; l < NB_SEGMENTS; l++) {
         acquire_privatization_lock(l);
     }
 }
@@ -237,7 +238,7 @@
 static inline void release_all_privatization_locks()
 {
     long l;
-    for (l = NB_SEGMENTS-1; l >= 1; l--) {
+    for (l = NB_SEGMENTS-1; l >= 0; l--) {
         release_privatization_lock(l);
     }
 }
@@ -269,7 +270,7 @@
 
     /* acquire locks in global order */
     int i;
-    for (i = 1; i < NB_SEGMENTS; i++) {
+    for (i = 0; i < NB_SEGMENTS; i++) {
         if ((seg_set & (1 << i)) == 0)
             continue;
 
@@ -283,7 +284,7 @@
     OPT_ASSERT(seg_set < (1 << NB_SEGMENTS));
 
     int i;
-    for (i = 1; i < NB_SEGMENTS; i++) {
+    for (i = 0; i < NB_SEGMENTS; i++) {
         if ((seg_set & (1 << i)) == 0)
             continue;
 
diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -359,7 +359,6 @@
         */
         lst = pseg->objects_pointing_to_nursery;
         if (!list_is_empty(lst)) {
-            abort(); // check that there is a test
             LIST_FOREACH_R(lst, object_t* /*item*/,
                 ({
                     struct object_s *realobj = (struct object_s *)
diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -391,7 +391,17 @@
     for (i = 0; i < NB_SEGMENTS; i++) {
         set_gs_register(get_segment_base(i));
 
+        assert(!must_abort());
         if (!_stm_validate()) {
+            assert(i != 0);     /* sharing seg0 should never need an abort */
+
+            if (STM_PSEGMENT->transaction_state == TS_NONE) {
+                /* we found a segment that has stale read-marker data and thus
+                   is in conflict with committed objs. Since it is not running
+                   currently, it's fine to ignore it. */
+                continue;
+            }
+
             /* tell it to abort when continuing */
             STM_PSEGMENT->pub.nursery_end = NSE_SIGABORT;
             assert(must_abort());
diff --git a/c8/stm/pages.h b/c8/stm/pages.h
--- a/c8/stm/pages.h
+++ b/c8/stm/pages.h
@@ -63,7 +63,7 @@
 static inline bool get_page_status_in(long segnum, uintptr_t pagenum)
 {
     /* reading page status requires "read"-lock: */
-    assert(STM_SEGMENT->segment_num==0 || STM_PSEGMENT->privatization_lock);
+    assert(STM_PSEGMENT->privatization_lock);
 
     OPT_ASSERT(segnum < 8 * sizeof(struct page_shared_s));
     volatile struct page_shared_s *ps = (volatile struct page_shared_s *)
diff --git a/c8/test/test_gcpage.py b/c8/test/test_gcpage.py
--- a/c8/test/test_gcpage.py
+++ b/c8/test/test_gcpage.py
@@ -289,3 +289,23 @@
         stm_major_collect()
         assert lib._stm_total_allocated() == 64 + LMO # large malloc'd
         self.commit_transaction()
+
+    def test_bug(self):
+        lp_ref_4 = stm_allocate_old_refs(50)
+        #
+        self.start_transaction()
+        stm_set_ref(lp_ref_4, 0, ffi.NULL, False)
+        #
+        self.switch(1)
+        self.start_transaction()
+        self.become_inevitable()
+        #
+        py.test.raises(Conflict, self.switch, 0)
+        #
+        self.switch(1)
+
+        stm_set_ref(lp_ref_4, 0, ffi.NULL, False)
+
+        self.commit_transaction()
+        self.start_transaction()
+        stm_major_collect()


More information about the pypy-commit mailing list