[pypy-commit] stmgc c8-gil-like: Really remove stm_become_globally_unique_transaction and adapt
arigo
noreply at buildbot.pypy.org
Fri Jun 12 09:54:38 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: c8-gil-like
Changeset: r1810:246e3b318782
Date: 2015-06-12 09:55 +0200
http://bitbucket.org/pypy/stmgc/changeset/246e3b318782/
Log: Really remove stm_become_globally_unique_transaction and adapt
demo_random to test for it. Rare crashes at the moment...
diff --git a/c8/demo/demo_random.c b/c8/demo/demo_random.c
--- a/c8/demo/demo_random.c
+++ b/c8/demo/demo_random.c
@@ -49,8 +49,10 @@
int num_roots;
int num_roots_at_transaction_start;
int steps_left;
+ long globally_unique;
};
__thread struct thread_data td;
+static long progress = 1;
struct thread_data *_get_td(void)
{
@@ -300,6 +302,15 @@
return p;
}
+static void end_gut(void)
+{
+ if (td.globally_unique != 0) {
+ fprintf(stderr, "[GUT END]");
+ assert(progress == td.globally_unique);
+ td.globally_unique = 0;
+ stm_resume_all_other_threads();
+ }
+}
objptr_t do_step(objptr_t p)
{
@@ -320,8 +331,14 @@
return NULL;
} else if (get_rand(240) == 1) {
push_roots();
- stm_become_globally_unique_transaction(&stm_thread_local, "really");
- fprintf(stderr, "[GUT/%d]", (int)STM_SEGMENT->segment_num);
+ if (td.globally_unique == 0) {
+ stm_stop_all_other_threads();
+ td.globally_unique = progress;
+ fprintf(stderr, "[GUT/%d]", (int)STM_SEGMENT->segment_num);
+ }
+ else {
+ end_gut();
+ }
pop_roots();
return NULL;
}
@@ -376,10 +393,14 @@
(void)local_seg;
(void)p_sig;
+ if (!td.globally_unique)
+ ++progress; /* racy, but good enough */
+
p = do_step(p);
if (p == (objptr_t)-1) {
push_roots();
+ end_gut();
long call_fork = (arg != NULL && *(long *)arg);
if (call_fork == 0) { /* common case */
@@ -425,6 +446,7 @@
}
}
push_roots();
+ end_gut();
stm_force_transaction_break(&stm_thread_local);
/* even out the shadow stack before leaveframe: */
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -1297,6 +1297,10 @@
assert(!_has_mutex());
assert(STM_PSEGMENT->safe_point == SP_RUNNING);
+ if (globally_unique_transaction) {
+ stm_fatalerror("cannot commit between stm_stop_all_other_threads "
+ "and stm_resume_all_other_threads");
+ }
dprintf(("> stm_commit_transaction(external=%d)\n", (int)external));
minor_collection(/*commit=*/ true, external);
@@ -1351,10 +1355,6 @@
_verify_cards_cleared_in_all_lists(get_priv_segment(STM_SEGMENT->segment_num));
- if (globally_unique_transaction && was_inev) {
- committed_globally_unique_transaction();
- }
-
/* done */
stm_thread_local_t *tl = STM_SEGMENT->running_thread;
assert(external == (tl == NULL));
@@ -1549,16 +1549,17 @@
invoke_and_clear_user_callbacks(0); /* for commit */
}
+#if 0
void stm_become_globally_unique_transaction(stm_thread_local_t *tl,
const char *msg)
{
- stm_become_inevitable(tl, msg); /* may still abort */
+ stm_become_inevitable(tl, msg);
s_mutex_lock();
synchronize_all_threads(STOP_OTHERS_AND_BECOME_GLOBALLY_UNIQUE);
s_mutex_unlock();
}
-
+#endif
void stm_stop_all_other_threads(void)
{
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -528,8 +528,8 @@
other threads. A very heavy-handed way to make sure that no other
transaction is running concurrently. Avoid as much as possible.
Other transactions will continue running only after this transaction
- commits. (xxx deprecated and may be removed) */
-void stm_become_globally_unique_transaction(stm_thread_local_t *tl, const char *msg);
+ commits. (deprecated, not working any more according to demo_random2) */
+//void stm_become_globally_unique_transaction(stm_thread_local_t *tl, const char *msg);
/* Moves the transaction forward in time by validating the read and
write set with all commits that happened since the last validation
More information about the pypy-commit
mailing list