diff options
author | Yabin Cui <yabinc@google.com> | 2020-07-29 19:09:55 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-07-29 19:09:55 +0000 |
commit | 3eb0e555d742b60ef2922ae61ebdb837ef4aa305 (patch) | |
tree | 01781b202832d73d33a16fd1f683dba444066134 | |
parent | aba29d61efefd5694348d5ff915b5a672bd30be3 (diff) | |
parent | 17cffbbd0da1763dfb287ea70ec70708ccc22fc2 (diff) | |
download | extras-3eb0e555d742b60ef2922ae61ebdb837ef4aa305.tar.gz |
Merge "Update language to comply with Android's inclusive language guidance."
-rw-r--r-- | simpleperf/Android.bp | 1 | ||||
-rw-r--r-- | simpleperf/README.md | 2 | ||||
-rw-r--r-- | simpleperf/RecordReadThread.cpp | 16 | ||||
-rw-r--r-- | simpleperf/cmd_list.cpp | 3 | ||||
-rw-r--r-- | simpleperf/demo/README.md | 2 | ||||
-rw-r--r-- | simpleperf/doc/README.md | 4 | ||||
-rw-r--r-- | simpleperf/doc/android_platform_profiling.md | 6 | ||||
-rw-r--r-- | simpleperf/environment.cpp | 40 | ||||
-rw-r--r-- | simpleperf/gtest_main.cpp | 5 | ||||
-rw-r--r-- | simpleperf/main.cpp | 4 | ||||
-rw-r--r-- | simpleperf/nonlinux_support/nonlinux_support.cpp | 4 | ||||
-rwxr-xr-x | simpleperf/scripts/report.py | 4 |
12 files changed, 45 insertions, 46 deletions
diff --git a/simpleperf/Android.bp b/simpleperf/Android.bp index 6ec2f942..b4357055 100644 --- a/simpleperf/Android.bp +++ b/simpleperf/Android.bp @@ -26,7 +26,6 @@ cc_defaults { // Try some more extreme warnings. "-Wpedantic", "-Wunreachable-code-aggressive", - // And disable some dumb things. "-Wno-zero-length-array", "-Wno-c99-extensions", "-Wno-language-extension-token", diff --git a/simpleperf/README.md b/simpleperf/README.md index 7ca61c54..ae30480a 100644 --- a/simpleperf/README.md +++ b/simpleperf/README.md @@ -5,7 +5,7 @@ There is also [user documentation](doc/README.md). ## Building new prebuilts -To snap the aosp-simpleperf-release branch to ToT AOSP master and kick off a +To snap the aosp-simpleperf-release branch to ToT AOSP main and kick off a build, use [this coastguard page](https://android-build.googleplex.com/coastguard/dashboard/5938649007521792/#/request/create) and choose "aosp-simpleperf-release" from the "Branch" dropdown. Then click diff --git a/simpleperf/RecordReadThread.cpp b/simpleperf/RecordReadThread.cpp index dfcc1a9e..bfc36e40 100644 --- a/simpleperf/RecordReadThread.cpp +++ b/simpleperf/RecordReadThread.cpp @@ -286,8 +286,8 @@ bool RecordReadThread::SendCmdToReadThread(Cmd cmd, void* cmd_arg) { cmd_ = cmd; cmd_arg_ = cmd_arg; } - char dummy = 0; - if (TEMP_FAILURE_RETRY(write(write_cmd_fd_, &dummy, 1)) != 1) { + char unused = 0; + if (TEMP_FAILURE_RETRY(write(write_cmd_fd_, &unused, 1)) != 1) { return false; } std::unique_lock<std::mutex> lock(cmd_mutex_); @@ -310,8 +310,8 @@ std::unique_ptr<Record> RecordReadThread::GetRecord() { return r; } if (has_data_notification_) { - char dummy; - TEMP_FAILURE_RETRY(read(read_data_fd_, &dummy, 1)); + char unused; + TEMP_FAILURE_RETRY(read(read_data_fd_, &unused, 1)); has_data_notification_ = false; } return nullptr; @@ -342,8 +342,8 @@ RecordReadThread::Cmd RecordReadThread::GetCmd() { } bool RecordReadThread::HandleCmd(IOEventLoop& loop) { - char dummy; - TEMP_FAILURE_RETRY(read(read_cmd_fd_, &dummy, 1)); + char unused; + TEMP_FAILURE_RETRY(read(read_cmd_fd_, &unused, 1)); bool result = true; switch (GetCmd()) { case CMD_ADD_EVENT_FDS: @@ -618,8 +618,8 @@ void RecordReadThread::ReadAuxDataFromKernelBuffer(bool* has_data) { bool RecordReadThread::SendDataNotificationToMainThread() { if (!has_data_notification_.load(std::memory_order_relaxed)) { has_data_notification_ = true; - char dummy = 0; - if (TEMP_FAILURE_RETRY(write(write_data_fd_, &dummy, 1)) != 1) { + char unused = 0; + if (TEMP_FAILURE_RETRY(write(write_data_fd_, &unused, 1)) != 1) { PLOG(ERROR) << "write"; return false; } diff --git a/simpleperf/cmd_list.cpp b/simpleperf/cmd_list.cpp index 396d7a8e..bf767065 100644 --- a/simpleperf/cmd_list.cpp +++ b/simpleperf/cmd_list.cpp @@ -47,8 +47,7 @@ static EventTypeStatus IsEventTypeSupported(const EventType& event_type) { } if (event_type.type != PERF_TYPE_RAW) { perf_event_attr attr = CreateDefaultPerfEventAttr(event_type); - // Exclude kernel to list supported events even when - // /proc/sys/kernel/perf_event_paranoid is 2. + // Exclude kernel to list supported events even when kernel recording isn't allowed. attr.exclude_kernel = 1; return IsEventAttrSupported(attr, event_type.name) ? EventTypeStatus::SUPPORTED : EventTypeStatus::NOT_SUPPORTED; diff --git a/simpleperf/demo/README.md b/simpleperf/demo/README.md index 6f9317fb..2005fa22 100644 --- a/simpleperf/demo/README.md +++ b/simpleperf/demo/README.md @@ -8,7 +8,7 @@ - [Profile a Java application](#profile-a-java-application) - [Profile a Java/C++ application](#profile-a-javac-application) - [Profile a Kotlin application](#profile-a-kotlin-application) -- [Profile via app_api](#profile-via-appapi) +- [Profile via app_api](#profile-via-app_api) ## Introduction diff --git a/simpleperf/doc/README.md b/simpleperf/doc/README.md index f0cddd2a..161fdc02 100644 --- a/simpleperf/doc/README.md +++ b/simpleperf/doc/README.md @@ -20,7 +20,7 @@ The latest document is [here](https://android.googlesource.com/platform/system/e - [Executable commands reference](#executable-commands-reference) - [Scripts reference](#scripts-reference) - [Answers to common issues](#answers-to-common-issues) - - [Why we suggest profiling on Android >= N devices?](#why-we-suggest-profiling-on-android-gt-n-devices) + - [Why we suggest profiling on Android >= N devices?](#why-we-suggest-profiling-on-android--n-devices) - [Suggestions about recording call graphs](#suggestions-about-recording-call-graphs) - [How to solve missing symbols in report?](#how-to-solve-missing-symbols-in-report) - [Fix broken callchain stopped at C functions](#fix-broken-callchain-stopped-at-c-functions) @@ -233,7 +233,7 @@ Patches can be uploaded to android-review.googlesource.com as [here](https://sou or sent to email addresses listed [here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/OWNERS). If you want to compile simpleperf C++ source code, follow below steps: -1. Download AOSP master branch as [here](https://source.android.com/setup/build/requirements). +1. Download AOSP main branch as [here](https://source.android.com/setup/build/requirements). 2. Build simpleperf. ```sh $ . build/envsetup.sh diff --git a/simpleperf/doc/android_platform_profiling.md b/simpleperf/doc/android_platform_profiling.md index 797d640a..21cf0f42 100644 --- a/simpleperf/doc/android_platform_profiling.md +++ b/simpleperf/doc/android_platform_profiling.md @@ -4,7 +4,7 @@ - [Android platform profiling](#android-platform-profiling) - [Table of Contents](#table-of-contents) - [General Tips](#general-tips) - - [Start simpleperf from system_server process](#start-simpleperf-from-systemserver-process) + - [Start simpleperf from system_server process](#start-simpleperf-from-system_server-process) - [Hardware PMU counter limit](#hardware-pmu-counter-limit) ## General Tips @@ -12,8 +12,8 @@ Here are some tips for Android platform developers, who build and flash system images on rooted devices: 1. After running `adb root`, simpleperf can be used to profile any process or system wide. -2. It is recommended to use the latest simpleperf available in AOSP master, if you are not working -on the current master branch. Scripts are in `system/extras/simpleperf/scripts`, binaries are in +2. It is recommended to use the latest simpleperf available in AOSP main, if you are not working +on the current main branch. Scripts are in `system/extras/simpleperf/scripts`, binaries are in `system/extras/simpleperf/scripts/bin/android`. 3. It is recommended to use `app_profiler.py` for recording, and `report_html.py` for reporting. Below is an example. diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp index 5873f56b..1f003cdb 100644 --- a/simpleperf/environment.cpp +++ b/simpleperf/environment.cpp @@ -275,22 +275,24 @@ bool GetValidThreadsFromThreadString(const std::string& tid_str, std::set<pid_t> } /* - * perf event paranoia level: - * -1 - not paranoid at all + * perf event allow level: + * -1 - everything allowed * 0 - disallow raw tracepoint access for unpriv * 1 - disallow cpu events for unpriv * 2 - disallow kernel profiling for unpriv * 3 - disallow user profiling for unpriv */ -static bool ReadPerfEventParanoid(int* value) { +static const char* perf_event_allow_path = "/proc/sys/kernel/perf_event_paranoid"; + +static bool ReadPerfEventAllowStatus(int* value) { std::string s; - if (!android::base::ReadFileToString("/proc/sys/kernel/perf_event_paranoid", &s)) { - PLOG(DEBUG) << "failed to read /proc/sys/kernel/perf_event_paranoid"; + if (!android::base::ReadFileToString(perf_event_allow_path, &s)) { + PLOG(DEBUG) << "failed to read " << perf_event_allow_path; return false; } s = android::base::Trim(s); if (!android::base::ParseInt(s.c_str(), value)) { - PLOG(ERROR) << "failed to parse /proc/sys/kernel/perf_event_paranoid: " << s; + PLOG(ERROR) << "failed to parse " << perf_event_allow_path << ": " << s; return false; } return true; @@ -307,7 +309,7 @@ bool CanRecordRawData() { return false; #else int value; - return ReadPerfEventParanoid(&value) && value == -1; + return ReadPerfEventAllowStatus(&value) && value == -1; #endif } @@ -323,16 +325,16 @@ static const char* GetLimitLevelDescription(int limit_level) { } bool CheckPerfEventLimit() { - // Root is not limited by /proc/sys/kernel/perf_event_paranoid. However, the monitored threads + // Root is not limited by perf_event_allow_path. However, the monitored threads // may create child processes not running as root. To make sure the child processes have - // enough permission to create inherited tracepoint events, write -1 to perf_event_paranoid. + // enough permission to create inherited tracepoint events, write -1 to perf_event_allow_path. // See http://b/62230699. if (IsRoot()) { - return android::base::WriteStringToFile("-1", "/proc/sys/kernel/perf_event_paranoid"); + return android::base::WriteStringToFile("-1", perf_event_allow_path); } int limit_level; - bool can_read_paranoid = ReadPerfEventParanoid(&limit_level); - if (can_read_paranoid && limit_level <= 1) { + bool can_read_allow_file = ReadPerfEventAllowStatus(&limit_level); + if (can_read_allow_file && limit_level <= 1) { return true; } #if defined(__ANDROID__) @@ -345,25 +347,25 @@ bool CheckPerfEventLimit() { if (prop_value == "0") { return true; } - // Try to enable perf_event_paranoid by setprop security.perf_harden=0. + // Try to enable perf events by setprop security.perf_harden=0. if (android::base::SetProperty(prop_name, "0")) { sleep(1); - if (can_read_paranoid && ReadPerfEventParanoid(&limit_level) && limit_level <= 1) { + if (can_read_allow_file && ReadPerfEventAllowStatus(&limit_level) && limit_level <= 1) { return true; } if (android::base::GetProperty(prop_name, "") == "0") { return true; } } - if (can_read_paranoid) { - LOG(WARNING) << "/proc/sys/kernel/perf_event_paranoid is " << limit_level - << ", " << GetLimitLevelDescription(limit_level) << "."; + if (can_read_allow_file) { + LOG(WARNING) << perf_event_allow_path << " is " << limit_level << ", " + << GetLimitLevelDescription(limit_level) << "."; } LOG(WARNING) << "Try using `adb shell setprop security.perf_harden 0` to allow profiling."; return false; #else - if (can_read_paranoid) { - LOG(WARNING) << "/proc/sys/kernel/perf_event_paranoid is " << limit_level + if (can_read_allow_file) { + LOG(WARNING) << perf_event_allow_path << " is " << limit_level << ", " << GetLimitLevelDescription(limit_level) << "."; return false; } diff --git a/simpleperf/gtest_main.cpp b/simpleperf/gtest_main.cpp index 013ec603..3fce9857 100644 --- a/simpleperf/gtest_main.cpp +++ b/simpleperf/gtest_main.cpp @@ -60,7 +60,7 @@ class ScopedEnablingPerf { android::base::SetProperty("security.perf_harden", value); // Sleep one second to wait for security.perf_harden changing - // /proc/sys/kernel/perf_event_paranoid. + // perf_event_allow_path. sleep(1); } @@ -99,8 +99,7 @@ int main(int argc, char** argv) { android::base::ScopedLogSeverity severity(log_severity); #if defined(__ANDROID__) - // A cts test PerfEventParanoidTest.java is testing if - // /proc/sys/kernel/perf_event_paranoid is 3, so restore perf_harden + // A cts test is testing if perf_event_allow_path is 3, so restore perf_harden // value after current test to not break that test. ScopedEnablingPerf scoped_enabling_perf; #endif diff --git a/simpleperf/main.cpp b/simpleperf/main.cpp index d5906a25..21c5351e 100644 --- a/simpleperf/main.cpp +++ b/simpleperf/main.cpp @@ -29,11 +29,11 @@ bool AndroidSecurityCheck() { // Simpleperf can be executed by the shell, or by apps themselves. To avoid malicious apps // exploiting perf_event_open interface via simpleperf, simpleperf needs proof that the user // is expecting simpleperf to be ran: - // 1) On Android < R, perf_event_open is secured by perf_event_paranoid, which is controlled + // 1) On Android < R, perf_event_open is secured by perf_event_allow_path, which is controlled // by security.perf_harden property. perf_event_open syscall can be used only after user setting // security.perf_harden to 0 in shell. So we don't need to check security.perf_harden explicitly. // 2) On Android R, perf_event_open may be controlled by selinux instead of - // perf_event_paranoid. So we need to check security.perf_harden explicitly. If simpleperf is + // perf_event_allow_path. So we need to check security.perf_harden explicitly. If simpleperf is // running via shell, we already know the origin of the request is the user, so set the property // ourselves for convenience. When started by the app, we won't have the permission to set the // property, so the user will need to prove this intent by setting it manually via shell. diff --git a/simpleperf/nonlinux_support/nonlinux_support.cpp b/simpleperf/nonlinux_support/nonlinux_support.cpp index deb3b1d5..b813109b 100644 --- a/simpleperf/nonlinux_support/nonlinux_support.cpp +++ b/simpleperf/nonlinux_support/nonlinux_support.cpp @@ -45,7 +45,7 @@ const char* GetTraceFsDir() { namespace simpleperf { -class DummyOfflineUnwinder : public OfflineUnwinder { +class NoOpOfflineUnwinder : public OfflineUnwinder { public: bool UnwindCallChain(const ThreadEntry&, const RegSet&, const char*, size_t, std::vector<uint64_t>*, std::vector<uint64_t>*) override { @@ -54,7 +54,7 @@ class DummyOfflineUnwinder : public OfflineUnwinder { }; std::unique_ptr<OfflineUnwinder> OfflineUnwinder::Create(bool) { - return std::unique_ptr<OfflineUnwinder>(new DummyOfflineUnwinder); + return std::unique_ptr<OfflineUnwinder>(new NoOpOfflineUnwinder); } } // namespace simpleperf
\ No newline at end of file diff --git a/simpleperf/scripts/report.py b/simpleperf/scripts/report.py index ae99e25f..f453d56c 100755 --- a/simpleperf/scripts/report.py +++ b/simpleperf/scripts/report.py @@ -192,8 +192,8 @@ class ReportWindow(object): """A window used to display report file.""" - def __init__(self, master, report_context, title_line, report_items): - frame = Frame(master) + def __init__(self, main, report_context, title_line, report_items): + frame = Frame(main) frame.pack(fill=BOTH, expand=1) font = Font(family='courier', size=12) |