Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r899:410c7a4975d0 Date: 2014-02-27 19:51 +0100 http://bitbucket.org/pypy/stmgc/changeset/410c7a4975d0/
Log: Improve the logic behind stm_collect(1) diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c --- a/c7/stm/gcpage.c +++ b/c7/stm/gcpage.c @@ -110,10 +110,10 @@ /************************************************************/ -static void major_collection(bool forced) +static void major_collection_if_requested(void) { assert(!_has_mutex()); - if (!forced && !is_major_collection_requested()) + if (!is_major_collection_requested()) return; mutex_lock(); @@ -121,7 +121,7 @@ assert(STM_PSEGMENT->safe_point == SP_RUNNING); STM_PSEGMENT->safe_point = SP_SAFE_POINT; - while (forced || is_major_collection_requested()) { + while (is_major_collection_requested()) { /* wait until the other thread is at a safe-point */ if (try_wait_for_other_safe_points()) { /* ok */ diff --git a/c7/stm/gcpage.h b/c7/stm/gcpage.h --- a/c7/stm/gcpage.h +++ b/c7/stm/gcpage.h @@ -33,7 +33,7 @@ static void teardown_gcpage(void); static char *allocate_outside_nursery_large(uint64_t size); -static void major_collection(bool forced); +static void major_collection_if_requested(void); static void major_collection_now_at_safe_point(void); diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c --- a/c7/stm/nursery.c +++ b/c7/stm/nursery.c @@ -282,8 +282,11 @@ void stm_collect(long level) { + if (level > 0) + force_major_collection_request(); + minor_collection(/*commit=*/ false); - major_collection(/*forced=*/ level > 0); + major_collection_if_requested(); } diff --git a/c7/stm/pages.c b/c7/stm/pages.c --- a/c7/stm/pages.c +++ b/c7/stm/pages.c @@ -8,7 +8,7 @@ static union { struct { uint8_t mutex_pages; - bool major_collection_requested; + volatile bool major_collection_requested; uint64_t total_allocated; /* keep track of how much memory we're using, ignoring nurseries */ uint64_t total_allocated_bound; @@ -61,6 +61,11 @@ return pages_ctl.major_collection_requested; } +static void force_major_collection_request(void) +{ + pages_ctl.major_collection_requested = true; +} + static void reset_major_collection_requested(void) { assert(_has_mutex()); diff --git a/c7/stm/pages.h b/c7/stm/pages.h --- a/c7/stm/pages.h +++ b/c7/stm/pages.h @@ -25,6 +25,7 @@ static void mutex_pages_unlock(void); static uint64_t increment_total_allocated(ssize_t add_or_remove); static bool is_major_collection_requested(void); +static void force_major_collection_request(void); static void reset_major_collection_requested(void); inline static void pages_privatize(uintptr_t pagenum, uintptr_t count, _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit