Author: Remi Meier <[email protected]>
Branch: stmgc-c7
Changeset: r71480:d5b96230865f
Date: 2014-05-13 10:46 +0200
http://bitbucket.org/pypy/pypy/changeset/d5b96230865f/
Log: import stmgc 3b302406acd8
diff --git a/rpython/translator/stm/src_stm/revision
b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-31f9797a356c
+3b302406acd8
diff --git a/rpython/translator/stm/src_stm/stm/contention.c
b/rpython/translator/stm/src_stm/stm/contention.c
--- a/rpython/translator/stm/src_stm/stm/contention.c
+++ b/rpython/translator/stm/src_stm/stm/contention.c
@@ -99,13 +99,14 @@
/************************************************************/
-static void contention_management(uint8_t other_segment_num,
+static bool contention_management(uint8_t other_segment_num,
enum contention_kind_e kind,
object_t *obj)
{
assert(_has_mutex());
assert(other_segment_num != STM_SEGMENT->segment_num);
+ bool others_may_have_run = false;
if (must_abort())
abort_with_mutex();
@@ -153,6 +154,7 @@
if (contmgr.try_sleep && kind != WRITE_WRITE_CONTENTION &&
contmgr.other_pseg->safe_point != SP_WAIT_FOR_C_TRANSACTION_DONE) {
+ others_may_have_run = true;
/* Sleep.
- Not for write-write contentions, because we're not at a
@@ -226,6 +228,7 @@
if (must_abort())
abort_with_mutex();
+ others_may_have_run = true;
dprintf(("contention: wait C_ABORTED...\n"));
cond_wait(C_ABORTED);
dprintf(("contention: done\n"));
@@ -279,6 +282,7 @@
stmcb_commit_soon();
}
}
+ return others_may_have_run;
}
static void write_write_contention_management(uintptr_t lock_idx,
@@ -302,10 +306,10 @@
s_mutex_unlock();
}
-static void write_read_contention_management(uint8_t other_segment_num,
+static bool write_read_contention_management(uint8_t other_segment_num,
object_t *obj)
{
- contention_management(other_segment_num, WRITE_READ_CONTENTION, obj);
+ return contention_management(other_segment_num, WRITE_READ_CONTENTION,
obj);
}
static void inevitable_contention_management(uint8_t other_segment_num)
diff --git a/rpython/translator/stm/src_stm/stm/contention.h
b/rpython/translator/stm/src_stm/stm/contention.h
--- a/rpython/translator/stm/src_stm/stm/contention.h
+++ b/rpython/translator/stm/src_stm/stm/contention.h
@@ -2,7 +2,7 @@
static void write_write_contention_management(uintptr_t lock_idx,
object_t *obj);
-static void write_read_contention_management(uint8_t other_segment_num,
+static bool write_read_contention_management(uint8_t other_segment_num,
object_t *obj);
static void inevitable_contention_management(uint8_t other_segment_num);
diff --git a/rpython/translator/stm/src_stm/stm/core.c
b/rpython/translator/stm/src_stm/stm/core.c
--- a/rpython/translator/stm/src_stm/stm/core.c
+++ b/rpython/translator/stm/src_stm/stm/core.c
@@ -287,13 +287,15 @@
({
if (was_read_remote(remote_base, item, remote_version)) {
/* A write-read conflict! */
- write_read_contention_management(i, item);
-
- /* If we reach this point, we didn't abort, but maybe we
- had to wait for the other thread to commit. If we
- did, then we have to restart committing from our call
- to synchronize_all_threads(). */
- return true;
+ if (write_read_contention_management(i, item)) {
+ /* If we reach this point, we didn't abort, but we
+ had to wait for the other thread to commit. If we
+ did, then we have to restart committing from our
call
+ to synchronize_all_threads(). */
+ return true;
+ }
+ /* we aborted the other transaction without waiting, so
+ we can just continue */
}
}));
}
@@ -502,6 +504,9 @@
/* the call to minor_collection() above leaves us with
STM_TIME_BOOKKEEPING */
+ /* synchronize overflow objects living in privatized pages */
+ push_overflow_objects_from_privatized_pages();
+
s_mutex_lock();
restart:
@@ -521,11 +526,11 @@
STM_SEGMENT->jmpbuf_ptr = NULL;
/* if a major collection is required, do it here */
- if (is_major_collection_requested())
+ if (is_major_collection_requested()) {
+ int oldstate = change_timing_state(STM_TIME_MAJOR_GC);
major_collection_now_at_safe_point();
-
- /* synchronize overflow objects living in privatized pages */
- push_overflow_objects_from_privatized_pages();
+ change_timing_state(oldstate);
+ }
/* synchronize modified old objects to other threads */
push_modified_to_other_segments();
diff --git a/rpython/translator/stm/src_stm/stm/sync.c
b/rpython/translator/stm/src_stm/stm/sync.c
--- a/rpython/translator/stm/src_stm/stm/sync.c
+++ b/rpython/translator/stm/src_stm/stm/sync.c
@@ -130,7 +130,8 @@
long i;
restart:
for (i = 1; i <= NB_SEGMENTS; i++) {
- if (get_priv_segment(i)->transaction_state == TS_INEVITABLE) {
+ struct stm_priv_segment_info_s *other_pseg = get_priv_segment(i);
+ if (other_pseg->transaction_state == TS_INEVITABLE) {
if (tl_or_null_if_can_abort == NULL) {
/* handle this case like a contention: it will either
abort us (not the other thread, which is inevitable),
@@ -142,6 +143,7 @@
else {
/* wait for stm_commit_transaction() to finish this
inevitable transaction */
+ signal_other_to_commit_soon(other_pseg);
change_timing_state_tl(tl_or_null_if_can_abort,
STM_TIME_WAIT_INEVITABLE);
cond_wait(C_INEVITABLE);
@@ -265,7 +267,7 @@
static bool _safe_points_requested = false;
#endif
-static void signal_other_to_commit_soon(struct stm_priv_segment_info_s
*other_pseg)
+void signal_other_to_commit_soon(struct stm_priv_segment_info_s *other_pseg)
{
assert(_has_mutex());
/* never overwrite abort signals or safepoint requests
diff --git a/rpython/translator/stm/src_stm/stm/sync.h
b/rpython/translator/stm/src_stm/stm/sync.h
--- a/rpython/translator/stm/src_stm/stm/sync.h
+++ b/rpython/translator/stm/src_stm/stm/sync.h
@@ -39,3 +39,5 @@
static void committed_globally_unique_transaction(void);
static bool pause_signalled, globally_unique_transaction;
+
+void signal_other_to_commit_soon(struct stm_priv_segment_info_s *other_pseg);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit