Author: Remi Meier <[email protected]>
Branch: c8-private-pages
Changeset: r1557:06bc63626a03
Date: 2015-01-20 11:34 +0100
http://bitbucket.org/pypy/stmgc/changeset/06bc63626a03/
Log: possibly fix a race
diff --git a/c8/stm/smallmalloc.c b/c8/stm/smallmalloc.c
--- a/c8/stm/smallmalloc.c
+++ b/c8/stm/smallmalloc.c
@@ -74,8 +74,17 @@
long i;
for (i = 0; i < GCPAGE_NUM_PAGES; i++) {
/* add to free_uniform_pages list */
- ((struct small_free_loc_s *)p)->nextpage = free_uniform_pages;
- free_uniform_pages = (struct small_free_loc_s *)p;
+ struct small_free_loc_s *to_add = (struct small_free_loc_s *)p;
+
+ retry:
+ to_add->nextpage = free_uniform_pages;
+ if (UNLIKELY(!__sync_bool_compare_and_swap(
+ &free_uniform_pages,
+ to_add->nextpage,
+ to_add))) {
+ goto retry;
+ }
+
p += 4096;
}
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit