summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-09-01 09:03:32 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-01 09:04:41 -0700
commitb308bc06514600e9dedc16442fa5099050090d94 (patch)
treeb85fec244098d41964f1d2b5709c45bbd5638a2b /absl
parent43d3c7a4e290ee96684735daf7b1d528c30a7943 (diff)
Changes mutex profiling
PiperOrigin-RevId: 471545981 Change-Id: I4d2c8b6d4f1e58976915bda78a77178b8bf80da8
Diffstat (limited to 'absl')
-rw-r--r--absl/synchronization/mutex.cc5
-rw-r--r--absl/synchronization/mutex.h2
2 files changed, 5 insertions, 2 deletions
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc
index 2662c071..144fdee6 100644
--- a/absl/synchronization/mutex.cc
+++ b/absl/synchronization/mutex.cc
@@ -493,7 +493,8 @@ struct SynchWaitParams {
cvmu(cvmu_arg),
thread(thread_arg),
cv_word(cv_word_arg),
- contention_start_cycles(base_internal::CycleClock::Now()) {}
+ contention_start_cycles(base_internal::CycleClock::Now()),
+ should_submit_contention_data(false) {}
const Mutex::MuHow how; // How this thread needs to wait.
const Condition *cond; // The condition that this thread is waiting for.
@@ -511,6 +512,7 @@ struct SynchWaitParams {
int64_t contention_start_cycles; // Time (in cycles) when this thread started
// to contend for the mutex.
+ bool should_submit_contention_data;
};
struct SynchLocksHeld {
@@ -2348,6 +2350,7 @@ ABSL_ATTRIBUTE_NOINLINE void Mutex::UnlockSlow(SynchWaitParams *waitp) {
if (!wake_list->cond_waiter) {
wait_cycles += (now - wake_list->waitp->contention_start_cycles);
wake_list->waitp->contention_start_cycles = now;
+ wake_list->waitp->should_submit_contention_data = true;
}
wake_list = Wakeup(wake_list); // wake waiters
} while (wake_list != kPerThreadSynchNull);
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
index b69b7089..8694bb75 100644
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -988,7 +988,7 @@ inline Condition::Condition(const T *object,
method_(reinterpret_cast<InternalMethodType>(method)),
arg_(reinterpret_cast<void *>(const_cast<T *>(object))) {}
-// Register a hook for profiling support.
+// Register hooks for profiling support.
//
// The function pointer registered here will be called whenever a mutex is
// contended. The callback is given the cycles for which waiting happened (as