Add a systrace support for lock contention logging.
- Now several ART executables like oatdump need to link with libcutils
as the mutex code is shared among them.
- The blocking thread ID and lock owner thread ID are passed to
ScopedContentionRecorder in the correct order.
Bug: 9986464
Change-Id: Id766de23fbc4af1d8ba2de051595e365b04f5ae7
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 3007978..b99e7c9 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -351,7 +351,7 @@
done = android_atomic_acquire_cas(0, 1, &state_) == 0;
} else {
// Failed to acquire, hang up.
- ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self));
+ ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid());
android_atomic_inc(&num_contenders_);
if (futex(&state_, FUTEX_WAIT, 1, NULL, NULL, 0) != 0) {
// EAGAIN and EINTR both indicate a spurious failure, try again from the beginning.
@@ -554,7 +554,7 @@
done = android_atomic_acquire_cas(0, -1, &state_) == 0;
} else {
// Failed to acquire, hang up.
- ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self));
+ ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid());
android_atomic_inc(&num_pending_writers_);
if (futex(&state_, FUTEX_WAIT, cur_state, NULL, NULL, 0) != 0) {
// EAGAIN and EINTR both indicate a spurious failure, try again from the beginning.
@@ -623,7 +623,7 @@
if (ComputeRelativeTimeSpec(&rel_ts, end_abs_ts, now_abs_ts)) {
return false; // Timed out.
}
- ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self));
+ ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid());
android_atomic_inc(&num_pending_writers_);
if (futex(&state_, FUTEX_WAIT, cur_state, &rel_ts, NULL, 0) != 0) {
if (errno == ETIMEDOUT) {