[pypy-commit] stmgc c7-refactor: fix for race condition (see comment in pages.h for PRIVATE_PAGE)

Remi Meier noreply at buildbot.pypy.org
Tue Feb 25 16:00:52 CET 2014


Author: Remi Meier
Branch: c7-refactor
Changeset: r861:4915e227b68f
Date: 2014-02-25 16:00 +0100
http://bitbucket.org/pypy/stmgc/changeset/4915e227b68f/

Log:	fix for race condition (see comment in pages.h for PRIVATE_PAGE)

diff --git a/c7/stm/pages.c b/c7/stm/pages.c
--- a/c7/stm/pages.c
+++ b/c7/stm/pages.c
@@ -110,6 +110,7 @@
 
 static void _pages_privatize(uintptr_t pagenum, uintptr_t count, bool full)
 {
+    /* narrow the range of pages to privatize from the end: */
     while (flag_page_private[pagenum + count - 1] == PRIVATE_PAGE) {
         if (!--count)
             return;
diff --git a/c7/stm/pages.h b/c7/stm/pages.h
--- a/c7/stm/pages.h
+++ b/c7/stm/pages.h
@@ -19,17 +19,21 @@
 static void pages_initialize_shared(uintptr_t pagenum, uintptr_t count);
 //static void pages_make_shared_again(uintptr_t pagenum, uintptr_t count);
 
+static void mutex_pages_lock(void);
+static void mutex_pages_unlock(void);
+
 inline static void pages_privatize(uintptr_t pagenum, uintptr_t count,
                                    bool full) {
+    mutex_pages_lock();
     while (flag_page_private[pagenum] == PRIVATE_PAGE) {
-        if (!--count)
+        if (!--count) {
+            mutex_pages_unlock();
             return;
+        }
         pagenum++;
     }
+    mutex_pages_unlock();
     _pages_privatize(pagenum, count, full);
 }
 
-static void mutex_pages_lock(void);
-static void mutex_pages_unlock(void);
-
 //static bool is_fully_in_shared_pages(object_t *obj);  -- not needed?


More information about the pypy-commit mailing list