Author: Armin Rigo <[email protected]>
Branch: c7-full-profiling
Changeset: r1445:4efd6b7175db
Date: 2014-10-04 14:15 +0200
http://bitbucket.org/pypy/stmgc/changeset/4efd6b7175db/
Log: Tests start to pass again
diff --git a/c7/stm/contention.c b/c7/stm/contention.c
--- a/c7/stm/contention.c
+++ b/c7/stm/contention.c
@@ -159,7 +159,7 @@
/* Do one of three things here...
*/
- if (contmgr.try_sleep && kind != WRITE_WRITE_CONTENTION &&
+ if (contmgr.try_sleep && kind != STM_CONTENTION_WRITE_WRITE &&
contmgr.other_pseg->safe_point != SP_WAIT_FOR_C_TRANSACTION_DONE) {
others_may_have_run = true;
/* Sleep.
@@ -172,28 +172,12 @@
itself already paused here.
*/
contmgr.other_pseg->signal_when_done = true;
- marker_contention(kind, false, other_segment_num, obj);
/* tell the other to commit ASAP */
signal_other_to_commit_soon(contmgr.other_pseg);
- enum stm_event_e wait_category;
- switch (kind) {
- case WRITE_READ_CONTENTION:
- wait_category = STM_WT_WRITE_READ;
- break;
- case INEVITABLE_CONTENTION:
- wait_category = STM_WT_INEVITABLE;
- break;
- default:
- stm_fatalerror("unexpected wait kind: %d", kind);
- }
-
dprintf(("pausing...\n"));
- timing_event(STM_SEGMENT->running_thread, wait_category, .., ..);
- ...;
-
cond_signal(C_AT_SAFE_POINT);
STM_PSEGMENT->safe_point = SP_WAIT_FOR_C_TRANSACTION_DONE;
cond_wait(C_TRANSACTION_DONE);
@@ -202,16 +186,6 @@
if (must_abort())
abort_with_mutex();
-
- abort(); /* XXX
- struct stm_priv_segment_info_s *pseg =
- get_priv_segment(STM_SEGMENT->segment_num);
- double elapsed =
- change_timing_state_tl(pseg->pub.running_thread,
- STM_TIME_RUN_CURRENT);
- marker_copy(pseg->pub.running_thread, pseg,
- wait_category, elapsed);
- */
}
else if (!contmgr.abort_other) {
@@ -219,16 +193,13 @@
signal_other_to_commit_soon(contmgr.other_pseg);
dprintf(("abort in contention: kind %d\n", kind));
- STM_SEGMENT->nursery_end = abort_category;
- marker_contention(kind, false, other_segment_num, obj);
abort_with_mutex();
}
else {
/* We have to signal the other thread to abort, and wait until
it does. */
- contmgr.other_pseg->pub.nursery_end = abort_category;
- marker_contention(kind, true, other_segment_num, obj);
+ contmgr.other_pseg->pub.nursery_end = NSE_SIGABORT;
int sp = contmgr.other_pseg->safe_point;
switch (sp) {
@@ -320,7 +291,8 @@
assert(get_priv_segment(other_segment_num)->write_lock_num ==
prev_owner);
- contention_management(other_segment_num, WRITE_WRITE_CONTENTION, obj);
+ contention_management(other_segment_num,
+ STM_CONTENTION_WRITE_WRITE, obj);
/* now we return into _stm_write_slowpath() and will try again
to acquire the write lock on our object. */
@@ -332,10 +304,12 @@
static bool write_read_contention_management(uint8_t other_segment_num,
object_t *obj)
{
- return contention_management(other_segment_num, WRITE_READ_CONTENTION,
obj);
+ return contention_management(other_segment_num,
+ STM_CONTENTION_WRITE_READ, obj);
}
static void inevitable_contention_management(uint8_t other_segment_num)
{
- contention_management(other_segment_num, INEVITABLE_CONTENTION, NULL);
+ contention_management(other_segment_num,
+ STM_CONTENTION_INEVITABLE, NULL);
}
diff --git a/c7/stm/marker.c b/c7/stm/marker.c
--- a/c7/stm/marker.c
+++ b/c7/stm/marker.c
@@ -40,8 +40,7 @@
STM_PSEGMENT->marker_inev.object = marker.object;
}
-static void marker_fetch_obj_write(object_t *obj,
- struct stm_loc_marker_t *out_marker)
+static void marker_fetch_obj_write(object_t *obj, stm_loc_marker_t *out_marker)
{
/* From 'out_marker->tl', fill in 'out_marker->segment_base' and
'out_marker->odd_number' and 'out_marker->object' from the
@@ -117,12 +116,12 @@
markers[1].segment_base = other_pseg->pub.segment_base;
switch (kind) {
- case WRITE_WRITE_CONTENTION:
+ case STM_CONTENTION_WRITE_WRITE:
marker_fetch_obj_write(obj, &markers[1]);
break;
- case INEVITABLE_CONTENTION:
- markers[1].odd_number = other_pseg->marker_inev[0];
- markers[1].object = (object_t *)other_pseg->marker_inev[1];
+ case STM_CONTENTION_INEVITABLE:
+ markers[1].odd_number = other_pseg->marker_inev.odd_number;
+ markers[1].object = other_pseg->marker_inev.object;
break;
default:
markers[1].odd_number = 0;
@@ -130,11 +129,14 @@
break;
}
+ stmcb_timing_event(markers[0].tl, kind, markers);
+
+ /* only release the lock after stmcb_timing_event(), otherwise it could
+ run into race conditions trying to interpret 'markers[1].object' */
release_marker_lock(other_segment_base);
-
- stmcb_timing_event(markers[0].tl, kind, markers);
}
-void (*stmcb_timing_event)(enum stm_event_e event,
- stm_loc_marker_t *markers[2]);
+void (*stmcb_timing_event)(stm_thread_local_t *tl, /* the local thread */
+ enum stm_event_e event,
+ stm_loc_marker_t *markers);
diff --git a/c7/stm/nursery.h b/c7/stm/nursery.h
--- a/c7/stm/nursery.h
+++ b/c7/stm/nursery.h
@@ -1,10 +1,12 @@
-/* 'nursery_end' is either NURSERY_END, NSE_SIGxxx, or STM_TR_ABORT_xxx. */
-#define NSE_SIGPAUSE (_STM_NSE_SIGNAL_MAX - 1)
-#define NSE_SIGCOMMITSOON (_STM_NSE_SIGNAL_MAX - 2)
+/* 'nursery_end' is either NURSERY_END or one of NSE_SIGxxx */
+#define NSE_SIGABORT 1
+#define NSE_SIGPAUSE 2
+#define NSE_SIGCOMMITSOON 3
+#define _NSE_NUM_SIGNALS 4
-#if !(STM_TR_ABORT_OTHER < NSE_SIGCOMMITSOON)
-# error "STM_TR_ABORT_xxx is too large; increase _STM_NSE_SIGNAL_MAX"
+#if _NSE_NUM_SIGNALS >= _STM_NSE_SIGNAL_MAX
+# error "increase _STM_NSE_SIGNAL_MAX"
#endif
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -123,7 +123,7 @@
#define _STM_CARD_SIZE 32 /* must be >= 32 */
#define _STM_MIN_CARD_COUNT 17
#define _STM_MIN_CARD_OBJ_SIZE (_STM_CARD_SIZE * _STM_MIN_CARD_COUNT)
-#define _STM_NSE_SIGNAL_MAX 63
+#define _STM_NSE_SIGNAL_MAX 7
#define _STM_FAST_ALLOC (66*1024)
@@ -406,10 +406,6 @@
const char *msg);
-/* Temporary? */
-void stm_flush_timing(stm_thread_local_t *tl, int verbose);
-
-
/* Profiling events. In the comments: content of the markers, if any */
enum stm_event_e {
/* always STM_TRANSACTION_START followed later by one of COMMIT or ABORT */
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -138,8 +138,6 @@
...
};
-void stm_flush_timing(stm_thread_local_t *, int);
-
typedef struct {
stm_thread_local_t *tl;
/* If segment_base==NULL, the remaining fields are undefined. If non-NULL,
@@ -155,7 +153,6 @@
void stm_push_marker(stm_thread_local_t *, uintptr_t, object_t *);
void stm_update_marker_num(stm_thread_local_t *, uintptr_t);
void stm_pop_marker(stm_thread_local_t *);
-char *_stm_expand_marker(void);
""")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit