[pypy-commit] stmgc c7-refactor: I think that with a REMAPPING_PAGE intermediate value it becomes

arigo noreply at buildbot.pypy.org
Tue Feb 25 16:21:36 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r862:a396ed3087b8
Date: 2014-02-25 16:21 +0100
http://bitbucket.org/pypy/stmgc/changeset/a396ed3087b8/

Log:	I think that with a REMAPPING_PAGE intermediate value it becomes
	simply this.

diff --git a/c7/stm/pages.c b/c7/stm/pages.c
--- a/c7/stm/pages.c
+++ b/c7/stm/pages.c
@@ -93,7 +93,7 @@
     void *localpg = stm_object_pages + localpgoff * 4096UL;
     void *otherpg = stm_object_pages + otherpgoff * 4096UL;
 
-    memset(flag_page_private + pagenum, PRIVATE_PAGE, count);
+    memset(flag_page_private + pagenum, REMAPPING_PAGE, count);
     d_remap_file_pages(localpg, count * 4096, pgoff2);
     uintptr_t i;
     if (full) {
@@ -106,6 +106,8 @@
         if (count > 1)
             pagecopy(localpg + 4096 * (count-1), otherpg + 4096 * (count-1));
     }
+    write_fence();
+    memset(flag_page_private + pagenum, PRIVATE_PAGE, count);
 }
 
 static void _pages_privatize(uintptr_t pagenum, uintptr_t count, bool full)
diff --git a/c7/stm/pages.h b/c7/stm/pages.h
--- a/c7/stm/pages.h
+++ b/c7/stm/pages.h
@@ -7,9 +7,11 @@
        physical page (the one that is within the segment 0 mmap address). */
     SHARED_PAGE,
 
-    /* Page is private for each segment.  If we obtain this value outside
-       a mutex_pages_lock(), there might be a race: the value can say
-       PRIVATE_PAGE before the page is really un-shared. */
+    /* For only one range of pages at a time, around the call to
+       remap_file_pages() that un-shares the pages (SHARED -> PRIVATE). */
+    REMAPPING_PAGE,
+
+    /* Page is private for each segment. */
     PRIVATE_PAGE,
 };
 
@@ -24,15 +26,14 @@
 
 inline static void pages_privatize(uintptr_t pagenum, uintptr_t count,
                                    bool full) {
-    mutex_pages_lock();
+    /* This is written a bit carefully so that a call with a constant
+       count == 1 will turn this loop into just one "if". */
     while (flag_page_private[pagenum] == PRIVATE_PAGE) {
         if (!--count) {
-            mutex_pages_unlock();
             return;
         }
         pagenum++;
     }
-    mutex_pages_unlock();
     _pages_privatize(pagenum, count, full);
 }
 


More information about the pypy-commit mailing list