summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-04-15 07:23:09 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-04-15 07:23:09 +0000
commitc208e8c1c35cd1b5b74d39001264801dcbd8b580 (patch)
treec945aa1cb8e85271a59dc9cdf6330da894d5bab4
parent636c72937a89e1586f89f3b86cd4f1db312a291c (diff)
parentb3ebfaaeef2fa5fd3f1071b0fe8b9b92edbbdd2d (diff)
downloadextras-c208e8c1c35cd1b5b74d39001264801dcbd8b580.tar.gz
Snap for 4722539 from b3ebfaaeef2fa5fd3f1071b0fe8b9b92edbbdd2d to pi-release
Change-Id: Ifee7113065ba37d9696798b9dec18b2969c13758
-rw-r--r--perfprofd/binder_interface/perfprofd_config.proto6
-rw-r--r--perfprofd/config.h8
-rw-r--r--perfprofd/configreader.cc4
-rw-r--r--perfprofd/perfprofdcore.cc15
4 files changed, 25 insertions, 8 deletions
diff --git a/perfprofd/binder_interface/perfprofd_config.proto b/perfprofd/binder_interface/perfprofd_config.proto
index c25aa93b..37c369c2 100644
--- a/perfprofd/binder_interface/perfprofd_config.proto
+++ b/perfprofd/binder_interface/perfprofd_config.proto
@@ -33,8 +33,12 @@ message ProfilingConfig {
// Desired sampling period (passed to perf -c option). Small
// sampling periods can perturb the collected profiles, so enforce
- // min/max.
+ // min/max. A value of 0 means perf default. sampling_frequency
+ // takes priority.
optional uint32 sampling_period = 7;
+ // Desired sampling frequency (passed to perf -f option). A value of 0
+ // means using sampling_period or default.
+ optional uint32 sampling_frequency = 22;
// Length of time to collect samples (number of seconds for 'perf
// record -a' run).
optional uint32 sample_duration_in_s = 8;
diff --git a/perfprofd/config.h b/perfprofd/config.h
index 774f7e86..0ee23099 100644
--- a/perfprofd/config.h
+++ b/perfprofd/config.h
@@ -52,8 +52,12 @@ struct Config {
// Desired sampling period (passed to perf -c option). Small
// sampling periods can perturb the collected profiles, so enforce
- // min/max.
- uint32_t sampling_period = 5000;
+ // min/max. A value of 0 means perf default. sampling_frequency
+ // takes priority.
+ uint32_t sampling_period = 0;
+ // Desired sampling frequency (passed to perf -f option). A value of 0
+ // means using sampling_period or default.
+ uint32_t sampling_frequency = 0;
// Length of time to collect samples (number of seconds for 'perf
// record -a' run).
uint32_t sample_duration_in_s = 2;
diff --git a/perfprofd/configreader.cc b/perfprofd/configreader.cc
index ac78f276..5d52b26e 100644
--- a/perfprofd/configreader.cc
+++ b/perfprofd/configreader.cc
@@ -91,7 +91,9 @@ void ConfigReader::addDefaultEntries()
addStringEntry("perf_path", config.perf_path.c_str());
// Desired sampling period (passed to perf -c option).
- addUnsignedEntry("sampling_period", config.sampling_period, 1, UINT32_MAX);
+ addUnsignedEntry("sampling_period", config.sampling_period, 0, UINT32_MAX);
+ // Desired sampling frequency (passed to perf -f option).
+ addUnsignedEntry("sampling_frequency", config.sampling_frequency, 0, UINT32_MAX);
// Length of time to collect samples (number of seconds for 'perf
// record -a' run).
diff --git a/perfprofd/perfprofdcore.cc b/perfprofd/perfprofdcore.cc
index 69508ad6..d7b0e9b4 100644
--- a/perfprofd/perfprofdcore.cc
+++ b/perfprofd/perfprofdcore.cc
@@ -491,10 +491,17 @@ static PROFILE_RESULT invoke_perf(Config& config,
argv[slot++] = "-o";
argv[slot++] = data_file_path.c_str();
- // -c N
- argv[slot++] = "-c";
- std::string p_str = android::base::StringPrintf("%u", sampling_period);
- argv[slot++] = p_str.c_str();
+ // -c/f N
+ std::string p_str;
+ if (config.sampling_frequency > 0) {
+ argv[slot++] = "-f";
+ p_str = android::base::StringPrintf("%u", sampling_period);
+ argv[slot++] = p_str.c_str();
+ } else if (config.sampling_period > 0) {
+ argv[slot++] = "-c";
+ p_str = android::base::StringPrintf("%u", sampling_period);
+ argv[slot++] = p_str.c_str();
+ }
// -g if desired
if (stack_profile_opt)