summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-08 01:00:36 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-08 01:00:36 +0000
commit3b20c0b9990abaf252e1e4820f693ee764cda00a (patch)
tree836ef72ecb400dadfa555ba377fddf3b83b37160
parentb5d1d79d0c0b59819aac57ed0bc238b81ef3401d (diff)
parentb2e6ae0e8b86c2bde220eb31e841ab8cd9bb4127 (diff)
downloadart-3b20c0b9990abaf252e1e4820f693ee764cda00a.tar.gz
Snap for 7711521 from b2e6ae0e8b86c2bde220eb31e841ab8cd9bb4127 to sc-qpr1-release
Change-Id: I9ffcba7c901725f333c9bd3a9c7e59fa3763ac92
-rw-r--r--libartpalette/apex/palette.cc24
-rw-r--r--libartpalette/include/palette/palette_method_list.h10
-rw-r--r--libartpalette/libartpalette.map.txt1
-rw-r--r--libartpalette/system/palette_fake.cc13
-rw-r--r--runtime/monitor_android.cc40
5 files changed, 75 insertions, 13 deletions
diff --git a/libartpalette/apex/palette.cc b/libartpalette/apex/palette.cc
index 71fd39ddb4..75a3878028 100644
--- a/libartpalette/apex/palette.cc
+++ b/libartpalette/apex/palette.cc
@@ -218,4 +218,28 @@ palette_status_t PaletteNotifyEndJniInvocation(JNIEnv* env) {
return m(env);
}
+palette_status_t PaletteReportLockContention(JNIEnv* env,
+ int32_t wait_ms,
+ const char* filename,
+ int32_t line_number,
+ const char* method_name,
+ const char* owner_filename,
+ int32_t owner_line_number,
+ const char* owner_method_name,
+ const char* proc_name,
+ const char* thread_name) {
+ PaletteReportLockContentionMethod m =
+ PaletteLoader::Instance().GetPaletteReportLockContentionMethod();
+ return m(env,
+ wait_ms,
+ filename,
+ line_number,
+ method_name,
+ owner_filename,
+ owner_line_number,
+ owner_method_name,
+ proc_name,
+ thread_name);
+}
+
} // extern "C"
diff --git a/libartpalette/include/palette/palette_method_list.h b/libartpalette/include/palette/palette_method_list.h
index 6a7822b1a2..066f24fb54 100644
--- a/libartpalette/include/palette/palette_method_list.h
+++ b/libartpalette/include/palette/palette_method_list.h
@@ -53,5 +53,15 @@
M(PaletteShouldReportJniInvocations, bool*) \
M(PaletteNotifyBeginJniInvocation, JNIEnv* env) \
M(PaletteNotifyEndJniInvocation, JNIEnv* env) \
+ M(PaletteReportLockContention, JNIEnv* env, \
+ int32_t wait_ms, \
+ const char* filename, \
+ int32_t line_number, \
+ const char* method_name, \
+ const char* owner_filename, \
+ int32_t owner_line_number, \
+ const char* owner_method_name, \
+ const char* proc_name, \
+ const char* thread_name) \
#endif // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
diff --git a/libartpalette/libartpalette.map.txt b/libartpalette/libartpalette.map.txt
index 9c846b160b..6401010abe 100644
--- a/libartpalette/libartpalette.map.txt
+++ b/libartpalette/libartpalette.map.txt
@@ -35,6 +35,7 @@ LIBARTPALETTE_1 {
PaletteShouldReportJniInvocations; #apex
PaletteNotifyBeginJniInvocation; #apex
PaletteNotifyEndJniInvocation; #apex
+ PaletteReportLockContention; #apex
local:
*;
diff --git a/libartpalette/system/palette_fake.cc b/libartpalette/system/palette_fake.cc
index dbbbf89dfa..bbf8f2dd8c 100644
--- a/libartpalette/system/palette_fake.cc
+++ b/libartpalette/system/palette_fake.cc
@@ -128,3 +128,16 @@ palette_status_t PaletteNotifyBeginJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
palette_status_t PaletteNotifyEndJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
return PALETTE_STATUS_OK;
}
+
+palette_status_t PaletteReportLockContention(JNIEnv* env ATTRIBUTE_UNUSED,
+ int32_t wait_ms ATTRIBUTE_UNUSED,
+ const char* filename ATTRIBUTE_UNUSED,
+ int32_t line_number ATTRIBUTE_UNUSED,
+ const char* method_name ATTRIBUTE_UNUSED,
+ const char* owner_filename ATTRIBUTE_UNUSED,
+ int32_t owner_line_number ATTRIBUTE_UNUSED,
+ const char* owner_method_name ATTRIBUTE_UNUSED,
+ const char* proc_name ATTRIBUTE_UNUSED,
+ const char* thread_name ATTRIBUTE_UNUSED) {
+ return PALETTE_STATUS_OK;
+}
diff --git a/runtime/monitor_android.cc b/runtime/monitor_android.cc
index 19e1f3d2c4..f661631789 100644
--- a/runtime/monitor_android.cc
+++ b/runtime/monitor_android.cc
@@ -24,6 +24,8 @@
#include <log/log_event_list.h>
#include "art_method.h"
+#include "jni/jni_env_ext.h"
+#include "palette/palette.h"
#include "thread.h"
#define EVENT_LOG_TAG_dvm_lock_sample 20003
@@ -41,14 +43,13 @@ void Monitor::LogContentionEvent(Thread* self,
int32_t owner_line_number;
TranslateLocation(owner_method, owner_dex_pc, &owner_filename, &owner_line_number);
- // Emit the process name, <= 37 bytes.
+ // Emit the process name, <= 33 bytes.
+ char proc_name[33] = {};
{
int fd = open("/proc/self/cmdline", O_RDONLY | O_CLOEXEC);
- char procName[33];
- memset(procName, 0, sizeof(procName));
- read(fd, procName, sizeof(procName) - 1);
+ read(fd, proc_name, sizeof(proc_name) - 1);
close(fd);
- ctx << procName;
+ ctx << proc_name;
}
// Emit the sensitive thread ("main thread") status. We follow tradition that this corresponds
@@ -58,20 +59,19 @@ void Monitor::LogContentionEvent(Thread* self,
ctx << (Thread::IsSensitiveThread() ? kIsSensitive : kIsNotSensitive);
// Emit self thread name string.
- {
- std::string thread_name;
- self->GetThreadName(thread_name);
- ctx << thread_name;
- }
+ std::string thread_name;
+ self->GetThreadName(thread_name);
+ ctx << thread_name;
// Emit the wait time.
ctx << wait_ms;
const char* filename = nullptr;
+ int32_t line_number;
+ std::string method_name;
{
uint32_t pc;
ArtMethod* m = self->GetCurrentMethod(&pc);
- int32_t line_number;
TranslateLocation(m, pc, &filename, &line_number);
// Emit the source code file name.
@@ -81,7 +81,8 @@ void Monitor::LogContentionEvent(Thread* self,
ctx << line_number;
// Emit the method name.
- ctx << ArtMethod::PrettyMethod(m);
+ method_name = ArtMethod::PrettyMethod(m);
+ ctx << method_name;
}
// Emit the lock owner source code file name.
@@ -97,12 +98,25 @@ void Monitor::LogContentionEvent(Thread* self,
ctx << owner_line_number;
// Emit the owner method name.
- ctx << ArtMethod::PrettyMethod(owner_method);
+ std::string owner_method_name = ArtMethod::PrettyMethod(owner_method);
+ ctx << owner_method_name;
// Emit the sample percentage.
ctx << sample_percent;
ctx << LOG_ID_EVENTS;
+
+ // Now report to other interested parties.
+ PaletteReportLockContention(self->GetJniEnv(),
+ wait_ms,
+ filename,
+ line_number,
+ method_name.c_str(),
+ owner_filename,
+ owner_line_number,
+ owner_method_name.c_str(),
+ proc_name,
+ thread_name.c_str());
}
} // namespace art