summaryrefslogtreecommitdiff
path: root/ANRdaemon
diff options
context:
space:
mode:
authorZhengyin Qian <qianzy@google.com>2016-05-27 18:18:45 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-05-27 18:18:45 +0000
commit486c4ed8fc1337d4e99b5a6697dd4a378848958e (patch)
tree6cbf993e1e75a60da40919851a891eb8d77efb87 /ANRdaemon
parent045794dbf9aaa64d8fc3cee0f7a089fd4f1919c3 (diff)
parent7ce6c2a6d4acfb747a022029e6372bc4c32fc94e (diff)
downloadextras-486c4ed8fc1337d4e99b5a6697dd4a378848958e.tar.gz
ANRdaemon: increase the CPU threshold resolution to 0.01% am: 6d25c0bd81 am: c33bbcd4c7 am: 05d982d4ed
am: 7ce6c2a6d4 * commit '7ce6c2a6d4acfb747a022029e6372bc4c32fc94e': ANRdaemon: increase the CPU threshold resolution to 0.01% Change-Id: I79fca6b4f279c21e62a4b8833cfa97ae980a71fd
Diffstat (limited to 'ANRdaemon')
-rw-r--r--ANRdaemon/ANRdaemon.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/ANRdaemon/ANRdaemon.cpp b/ANRdaemon/ANRdaemon.cpp
index 5a4f8bf9..9b36b2df 100644
--- a/ANRdaemon/ANRdaemon.cpp
+++ b/ANRdaemon/ANRdaemon.cpp
@@ -74,8 +74,11 @@ typedef struct cpu_stat {
unsigned long total;
} cpu_stat_t;
-/* Make the logging on/off threshold equal to 95% cpu usage. */
-static int idle_threshold = 5;
+/*
+ * Logging on/off threshold.
+ * Uint: 0.01%; default to 99.90% cpu.
+ */
+static int idle_threshold = 10;
static bool quit = false;
static bool suspend= false;
@@ -151,18 +154,18 @@ static void get_cpu_stat(cpu_stat_t *cpu) {
/*
* Calculate cpu usage in the past interval.
- * If tracing is on, increase the idle threshold by 1% so that we do not
+ * If tracing is on, increase the idle threshold by 1.00% so that we do not
* turn on and off tracing frequently whe the cpu load is right close to
* threshold.
*/
static bool is_heavy_load(void) {
unsigned long diff_idle, diff_total;
- int threshold = idle_threshold + (tracing?1:0);
+ int threshold = idle_threshold + (tracing?100:0);
get_cpu_stat(&new_cpu);
diff_idle = new_cpu.itime - old_cpu.itime;
diff_total = new_cpu.total - old_cpu.total;
old_cpu = new_cpu;
- return (diff_idle * 100 < diff_total * threshold);
+ return (diff_idle * 10000 < diff_total * threshold);
}
/*
@@ -494,7 +497,7 @@ static void show_help(void) {
" -a appname enable app-level tracing for a comma "
"separated list of cmdlines\n"
" -t N cpu threshold for logging to start "
- "(min = 50, max = 100, default = 95)\n"
+ "(uint = 0.01%%, min = 5000, max = 9999, default = 9990)\n"
" -s N use a trace buffer size of N KB "
"default to 16KB\n"
" -h show helps\n");
@@ -535,11 +538,11 @@ static int get_options(int argc, char *argv[]) {
break;
case 't':
threshold = atoi(optarg);
- if (threshold > 100 || threshold < 50) {
- fprintf(stderr, "logging threshold should be 50-100\n");
+ if (threshold > 9999 || threshold < 5000) {
+ fprintf(stderr, "logging threshold should be 5000-9999\n");
return 1;
}
- idle_threshold = 100 - threshold;
+ idle_threshold = 10000 - threshold;
break;
case 'h':
show_help();