[pypy-commit] stmgc c8-hashtable: The buggy privatization_lock() logic was still buggy

arigo noreply at buildbot.pypy.org
Thu Mar 12 15:02:05 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: c8-hashtable
Changeset: r1719:44c106e7ae45
Date: 2015-03-12 15:02 +0100
http://bitbucket.org/pypy/stmgc/changeset/44c106e7ae45/

Log:	The buggy privatization_lock() logic was still buggy

diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -148,14 +148,14 @@
     memcpy(nobj_seg0, initial_data, size_rounded_up);
     ((struct object_s *)nobj_seg0)->stm_flags = GCFLAG_WRITE_BARRIER;
 
+    acquire_privatization_lock(STM_SEGMENT->segment_num);
+
     long j;
     for (j = 1; j < NB_SEGMENTS; j++) {
         const char *src = nobj_seg0;
         char *dest = get_segment_base(j) + nobj;
         char *end = dest + size_rounded_up;
 
-        acquire_privatization_lock(j);
-
         while (((uintptr_t)dest) / 4096 != ((uintptr_t)end - 1) / 4096) {
             uintptr_t count = 4096 - ((uintptr_t)dest) / 4096;
             _fill_preexisting_slice(j, dest, src, count);
@@ -171,9 +171,10 @@
             assert(!was_read_remote(get_segment_base(j), (object_t *)nobj));
         }
 #endif
-        release_privatization_lock(j);
     }
 
+    release_privatization_lock(STM_SEGMENT->segment_num);
+
     write_fence();     /* make sure 'nobj' is fully initialized from
                           all threads here */
     DEBUG_EXPECT_SEGFAULT(true);
@@ -298,6 +299,8 @@
 }
 
 
+#define TRACE_FOR_MAJOR_COLLECTION  (&mark_record_trace)
+
 static void mark_and_trace(
     object_t *obj,
     char *segment_base, /* to trace obj in */
diff --git a/c8/stm/pages.h b/c8/stm/pages.h
--- a/c8/stm/pages.h
+++ b/c8/stm/pages.h
@@ -62,7 +62,11 @@
 
 static inline bool get_page_status_in(long segnum, uintptr_t pagenum)
 {
-    /* reading page status requires "read"-lock: */
+    /* reading page status requires "read"-lock, which is defined as
+       "any segment has the privatization_lock".  This is enough to
+       prevent the "write"-lock from being acquired by somebody else
+       (defined as "_all_ segments have the privatization_lock").
+    */
     assert(STM_PSEGMENT->privatization_lock);
 
     OPT_ASSERT(segnum < 8 * sizeof(struct page_shared_s));


More information about the pypy-commit mailing list