Author: Tobias Weber <tobias_webe...@gmx.de> Branch: c8-overheads-instrumentation Changeset: r2032:6c8ad9d4223c Date: 2017-03-15 13:25 +0100 http://bitbucket.org/pypy/stmgc/changeset/6c8ad9d4223c/
Log: Fix logger accesses to running thread info after it has already been reset diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -159,6 +159,7 @@ /* returns true if we reached a valid state, or false if we need to abort now */ start_timer(); + stm_thread_local_t *thread_local_for_logging = STM_SEGMENT->running_thread; dprintf(("_stm_validate() at cl=%p, rev=%lu\n", STM_PSEGMENT->last_commit_log_entry, STM_PSEGMENT->last_commit_log_entry->rev_num)); @@ -174,7 +175,10 @@ if (STM_PSEGMENT->transaction_state == TS_INEVITABLE) { assert(first_cl->next == INEV_RUNNING); - stop_timer_and_publish(STM_DURATION_VALIDATION); + if (thread_local_for_logging != NULL) { + stop_timer_and_publish_for_thread( + thread_local_for_logging, STM_DURATION_VALIDATION); + } return true; } @@ -342,7 +346,10 @@ release_privatization_lock(my_segnum); } - stop_timer_and_publish(STM_DURATION_VALIDATION); + if (thread_local_for_logging != NULL) { + stop_timer_and_publish_for_thread( + thread_local_for_logging, STM_DURATION_VALIDATION); + } return !needs_abort; } @@ -1219,6 +1226,7 @@ static void _core_commit_transaction(bool external) { start_timer(); + stm_thread_local_t *thread_local_for_logging = STM_SEGMENT->running_thread; exec_local_finalizers(); @@ -1316,7 +1324,8 @@ s_mutex_unlock(); - stop_timer_and_publish(STM_DURATION_COMMIT_EXCEPT_GC); + stop_timer_and_publish_for_thread( + thread_local_for_logging, STM_DURATION_COMMIT_EXCEPT_GC); /* between transactions, call finalizers. this will execute a transaction itself */ diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c --- a/c8/stm/gcpage.c +++ b/c8/stm/gcpage.c @@ -747,6 +747,8 @@ dprintf((" .----- major collection -----------------------\n")); assert(_has_mutex()); + stm_thread_local_t *thread_local_for_logging = STM_SEGMENT->running_thread; + /* first, force a minor collection in each of the other segments */ major_do_validation_and_minor_collections(); @@ -784,8 +786,9 @@ if (must_abort()) abort_with_mutex(); - stop_timer_and_publish(STM_DURATION_MAJOR_GC_LOG_ONLY); - + stop_timer_and_publish_for_thread( + thread_local_for_logging, STM_DURATION_MAJOR_GC_LOG_ONLY); + return; #endif } @@ -843,5 +846,6 @@ if (must_abort()) abort_with_mutex(); - stop_timer_and_publish(STM_DURATION_MAJOR_GC_FULL); + stop_timer_and_publish_for_thread( + thread_local_for_logging, STM_DURATION_MAJOR_GC_FULL); } diff --git a/c8/stm/timing.h b/c8/stm/timing.h --- a/c8/stm/timing.h +++ b/c8/stm/timing.h @@ -10,10 +10,8 @@ continue_timer() /* Must use start_timer before using this macro. */ -#define get_duration() duration.tv_sec = \ - stop.tv_sec - start.tv_sec + duration.tv_sec; \ - duration.tv_nsec = \ - stop.tv_nsec - start.tv_nsec + duration.tv_nsec; +#define get_duration() duration.tv_sec += stop.tv_sec - start.tv_sec; \ + duration.tv_nsec += stop.tv_nsec - start.tv_nsec; #define pause_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &stop); \ get_duration() @@ -24,12 +22,16 @@ stm_timing_event_payload_t stm_duration_payload = \ { STM_EVENT_PAYLOAD_DURATION, stm_duration_data }; -#define publish_event(event) \ +#define publish_event(thread_local, event) \ (timing_enabled() ? \ - stmcb_timing_event( \ - STM_SEGMENT->running_thread, event, &stm_duration_payload) : \ + stmcb_timing_event(thread_local, event, &stm_duration_payload) : \ (void)0); -#define stop_timer_and_publish(event) pause_timer() \ - stm_duration_payload(duration) \ - publish_event(event) +#define stop_timer_and_publish_for_thread(thread_local, event) \ + pause_timer() \ + stm_duration_payload(duration) \ + assert(thread_local != NULL); \ + publish_event(thread_local, event) + +#define stop_timer_and_publish(event) \ + stop_timer_and_publish_for_thread(STM_SEGMENT->running_thread, event) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit