summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2013-08-13 21:01:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-13 21:01:23 +0000
commit7b67bee4f6ca4e634f35f63d1e08e1b05f138e01 (patch)
tree8135032a8ecd634a7cb8e921b9416a9f63c279a1
parent0a564f3ef661a98b46c0a36472b48a52a5c735cc (diff)
parentb3733086ab415088b97fac20b3eea24433a7d2c5 (diff)
downloadart-7b67bee4f6ca4e634f35f63d1e08e1b05f138e01.tar.gz
art-7b67bee4f6ca4e634f35f63d1e08e1b05f138e01.tar.bz2
art-7b67bee4f6ca4e634f35f63d1e08e1b05f138e01.zip
Merge "Add a systrace support for lock contention logging." into dalvik-dev
-rw-r--r--build/Android.libarttest.mk3
-rw-r--r--dex2oat/Android.mk4
-rw-r--r--oatdump/Android.mk4
-rw-r--r--runtime/base/mutex-inl.h9
-rw-r--r--runtime/base/mutex.cc6
5 files changed, 18 insertions, 8 deletions
diff --git a/build/Android.libarttest.mk b/build/Android.libarttest.mk
index 4fb2bbfff6..f7b4d1e817 100644
--- a/build/Android.libarttest.mk
+++ b/build/Android.libarttest.mk
@@ -46,13 +46,14 @@ define build-libarttest
ifeq ($$(art_target_or_host),target)
LOCAL_CLANG := $(ART_TARGET_CLANG)
LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
- LOCAL_SHARED_LIBRARIES += libdl
+ LOCAL_SHARED_LIBRARIES += libdl libcutils
LOCAL_STATIC_LIBRARIES := libgtest
LOCAL_MODULE_PATH := $(ART_TEST_OUT)
include $(BUILD_SHARED_LIBRARY)
else # host
LOCAL_CLANG := $(ART_HOST_CLANG)
LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
+ LOCAL_STATIC_LIBRARIES := libcutils
LOCAL_LDLIBS := -ldl -lpthread
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt
diff --git a/dex2oat/Android.mk b/dex2oat/Android.mk
index 5cfab51d66..05dcd7bac6 100644
--- a/dex2oat/Android.mk
+++ b/dex2oat/Android.mk
@@ -22,10 +22,10 @@ DEX2OAT_SRC_FILES := \
dex2oat.cc
ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler,art/compiler,target,ndebug))
+ $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libcutils libart-compiler,art/compiler,target,ndebug))
endif
ifeq ($(ART_BUILD_TARGET_DEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler,art/compiler,target,debug))
+ $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libcutils libartd-compiler,art/compiler,target,debug))
endif
ifeq ($(WITH_HOST_DALVIK),true)
diff --git a/oatdump/Android.mk b/oatdump/Android.mk
index bf5c41b74e..a63b229846 100644
--- a/oatdump/Android.mk
+++ b/oatdump/Android.mk
@@ -22,10 +22,10 @@ OATDUMP_SRC_FILES := \
include art/build/Android.executable.mk
ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
- $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,,target,ndebug))
+ $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils,,target,ndebug))
endif
ifeq ($(ART_BUILD_TARGET_DEBUG),true)
- $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,,target,debug))
+ $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils,,target,debug))
endif
ifeq ($(WITH_HOST_DALVIK),true)
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h
index 7f3b459c2e..a559d63f77 100644
--- a/runtime/base/mutex-inl.h
+++ b/runtime/base/mutex-inl.h
@@ -19,7 +19,10 @@
#include "mutex.h"
+#define ATRACE_TAG ATRACE_TAG_DALVIK
+
#include "cutils/atomic-inline.h"
+#include "cutils/trace.h"
#include "runtime.h"
#include "thread.h"
@@ -45,10 +48,16 @@ class ScopedContentionRecorder {
blocked_tid_(kLogLockContentions ? blocked_tid : 0),
owner_tid_(kLogLockContentions ? owner_tid : 0),
start_nano_time_(kLogLockContentions ? NanoTime() : 0) {
+ if (kLogLockContentions) {
+ std::string msg = StringPrintf("Lock contention on %s (owner tid: %llu)",
+ mutex->GetName(), owner_tid);
+ ATRACE_BEGIN(msg.c_str());
+ }
}
~ScopedContentionRecorder() {
if (kLogLockContentions) {
+ ATRACE_END();
uint64_t end_nano_time = NanoTime();
mutex_->RecordContention(blocked_tid_, owner_tid_, end_nano_time - start_nano_time_);
}
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 30079786d7..b99e7c9281 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -351,7 +351,7 @@ void Mutex::ExclusiveLock(Thread* self) {
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 @@ void ReaderWriterMutex::ExclusiveLock(Thread* self) {
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 @@ bool ReaderWriterMutex::ExclusiveLockWithTimeout(Thread* self, int64_t ms, int32
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) {