[pypy-commit] stmgc c7-refactor: Resetting the creation markers between transactions
arigo
noreply at buildbot.pypy.org
Fri Feb 14 19:19:28 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r738:a26f2c58f57e
Date: 2014-02-14 19:19 +0100
http://bitbucket.org/pypy/stmgc/changeset/a26f2c58f57e/
Log: Resetting the creation markers between transactions
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -130,6 +130,8 @@
reset_transaction_read_version();
assert(list_is_empty(STM_PSEGMENT->old_objects_to_trace));
+ assert(list_is_empty(STM_PSEGMENT->modified_objects));
+ assert(list_is_empty(STM_PSEGMENT->creation_markers));
}
@@ -137,6 +139,7 @@
{
stm_thread_local_t *tl = STM_SEGMENT->running_thread;
release_thread_segment(tl);
+ reset_all_creation_markers();
}
void stm_abort_transaction(void)
@@ -144,6 +147,7 @@
stm_thread_local_t *tl = STM_SEGMENT->running_thread;
stm_jmpbuf_t *jmpbuf_ptr = STM_SEGMENT->jmpbuf_ptr;
release_thread_segment(tl);
+ reset_all_creation_markers();
assert(jmpbuf_ptr != NULL);
assert(jmpbuf_ptr != (stm_jmpbuf_t *)-1); /* for tests only */
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -55,6 +55,7 @@
struct stm_segment_info_s pub;
struct list_s *old_objects_to_trace;
struct list_s *modified_objects;
+ struct list_s *creation_markers;
uint64_t approximate_start_time;
uint8_t write_lock_num;
uint8_t need_abort;
diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -5,12 +5,14 @@
static void setup_gcpage(void)
{
+ /* NB. the very last page is not used, which allows a speed-up in
+ reset_all_creation_markers() */
char *base = stm_object_pages + END_NURSERY_PAGE * 4096UL;
- uintptr_t length = (NB_PAGES - END_NURSERY_PAGE) * 4096UL;
+ uintptr_t length = (NB_PAGES - END_NURSERY_PAGE - 1) * 4096UL;
largemalloc_init_arena(base, length);
uninitialized_page_start = (stm_char *)(END_NURSERY_PAGE * 4096UL);
- uninitialized_page_stop = (stm_char *)(NB_PAGES * 4096UL);
+ uninitialized_page_stop = (stm_char *)((NB_PAGES - 1) * 4096UL);
}
object_t *_stm_allocate_old(ssize_t size_rounded_up)
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -49,6 +49,37 @@
return (uintptr_t)obj < NURSERY_START + NURSERY_SIZE;
}
+static void set_creation_markers(stm_char *p, uint64_t size)
+{
+ /* Set the creation markers to 0xff for all lines from p to p+size.
+ Both p and size should be aligned to NURSERY_LINE. */
+
+ assert((((uintptr_t)p) & (NURSERY_LINE - 1)) == 0);
+ assert((size & (NURSERY_LINE - 1)) == 0);
+
+ char *addr = REAL_ADDRESS(STM_SEGMENT->segment_base,
+ ((uintptr_t)p) >> NURSERY_LINE_SHIFT);
+ memset(addr, 0xff, size >> NURSERY_LINE_SHIFT);
+
+ LIST_APPEND(STM_PSEGMENT->creation_markers, addr);
+}
+
+static void reset_all_creation_markers(void)
+{
+ /* Note that the page 'NB_PAGES - 1' is not actually used. This
+ ensures that the creation markers always end with some zeroes.
+ We reset the markers 8 at a time, by writing null integers
+ until we reach a place that is already null.
+ */
+ LIST_FOREACH_R(STM_PSEGMENT->creation_markers, uintptr_t, ({
+ uint64_t *p = (uint64_t *)(item & ~7);
+ while (*p != 0)
+ *p++ = 0;
+ }));
+
+ list_clear(STM_PSEGMENT->creation_markers);
+}
+
#define NURSERY_ALIGN(bytes) \
(((bytes) + NURSERY_LINE - 1) & ~(NURSERY_LINE - 1))
@@ -76,10 +107,10 @@
NURSERY_SECTION_SIZE);
STM_SEGMENT->nursery_current = p + size_rounded_up;
STM_SEGMENT->nursery_section_end = (uintptr_t)p + NURSERY_SECTION_SIZE;
+
/* Also fill the corresponding creation markers with 0xff. */
- memset(REAL_ADDRESS(STM_SEGMENT->segment_base,
- ((uintptr_t)p) >> NURSERY_LINE_SHIFT),
- 0xff, NURSERY_SECTION_SIZE >> NURSERY_LINE_SHIFT);
+ set_creation_markers(p, NURSERY_SECTION_SIZE);
+
return p;
}
abort();
diff --git a/c7/stm/nursery.h b/c7/stm/nursery.h
new file mode 100644
--- /dev/null
+++ b/c7/stm/nursery.h
@@ -0,0 +1,2 @@
+
+static void reset_all_creation_markers(void);
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -66,6 +66,7 @@
pr->pub.segment_base = segment_base;
pr->old_objects_to_trace = list_create();
pr->modified_objects = list_create();
+ pr->creation_markers = list_create();
}
/* Make the nursery pages shared. The other pages are
diff --git a/c7/stmgc.c b/c7/stmgc.c
--- a/c7/stmgc.c
+++ b/c7/stmgc.c
@@ -8,6 +8,7 @@
#include "stm/gcpage.h"
#include "stm/sync.h"
#include "stm/largemalloc.h"
+#include "stm/nursery.h"
#include "stm/misc.c"
#include "stm/list.c"
More information about the pypy-commit
mailing list