Skip to content

Commit

Permalink
i#4219 xl8: Add an rstat on synch xl8 failures
Browse files Browse the repository at this point in the history
Adds an rstat "synchs_not_at_safe_spot" measuring the count of
synch_with_thread attempts that had to be re-tried due to the target
being suspended at an un-translatable (i.e., unsafe) spot.

Adds a corresponding dr_stats_t field "synchs_not_at_safe_spot" for
extraction.

These will be useful for measuring the impact of clean calls and other
un-translatable places on detach and other synch operations.

Issue: #4219
  • Loading branch information
derekbruening committed Mar 26, 2020
1 parent 48bafdb commit d65ad60
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ typedef struct _dr_stats_t {
uint64 peak_num_threads;
/** Accumulated total number of threads encountered by DR. */
uint64 num_threads_created;
/**
* Thread synchronization attempts retried due to the target thread being at
* an un-translatable spot.
*/
uint64 synchs_not_at_safe_spot;
} dr_stats_t;

/* DR_API EXPORT END */
Expand Down
4 changes: 2 additions & 2 deletions core/lib/instrument_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6382,8 +6382,8 @@ DR_API
/**
* Retrieves various statistics exported by DR as global, process-wide values.
* The API is not thread-safe.
* The caller is expected to pass a pointer to a valid, initialized dr_stats_t
* value, with the size field set (see dr_stats_t).
* The caller is expected to pass a pointer to a valid, initialized #dr_stats_t
* value, with the size field set (see #dr_stats_t).
* Returns false if stats are not enabled.
*/
bool
Expand Down
1 change: 1 addition & 0 deletions core/lib/statsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ STATS_DEF("Cache consistency flushes that flushed nothing", num_empty_flushes)
STATS_DEF("Cache consistency flushes via synchall", flush_synchall)
STATS_DEF("Thread not translated in synchall flush (race)", flush_synchall_races)
STATS_DEF("Thread not synched with in synchall flush", flush_synchall_fail)
RSTATS_DEF("Synch attempt failure b/c not at safe spot", synchs_not_at_safe_spot)
STATS_DEF("Cache consistency coarse units flushed", flush_coarse_units)
STATS_DEF("Cache consistency persisted units flushed", flush_persisted_units)
STATS_DEF("Cache consistency persisted flushed at unload", flush_persisted_unload)
Expand Down
2 changes: 2 additions & 0 deletions core/synch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,8 @@ synch_with_thread(thread_id_t id, bool block, bool hold_initexit_lock,
my_id);
res = THREAD_SYNCH_RESULT_SUCCESS;
break;
} else {
RSTATS_INC(synchs_not_at_safe_spot);
}
if (!os_thread_resume(trec)) {
ASSERT_NOT_REACHED();
Expand Down
3 changes: 3 additions & 0 deletions core/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -4606,5 +4606,8 @@ stats_get_snapshot(dr_stats_t *drstats)
}
drstats->peak_num_threads = GLOBAL_STAT(peak_num_threads);
drstats->num_threads_created = GLOBAL_STAT(num_threads_created);
if (drstats->size > offsetof(dr_stats_t, synchs_not_at_safe_spot)) {
drstats->synchs_not_at_safe_spot = GLOBAL_STAT(synchs_not_at_safe_spot);
}
return true;
}

0 comments on commit d65ad60

Please sign in to comment.