diff --git a/cmds/atrace/atrace.c b/cmds/atrace/atrace.c index 7b4f55e5e..a67429571 100644 --- a/cmds/atrace/atrace.c +++ b/cmds/atrace/atrace.c @@ -29,6 +29,7 @@ static int g_traceDurationSeconds = 5; static bool g_traceSchedSwitch = false; static bool g_traceCpuFrequency = false; +static bool g_traceCpuIdle = false; static bool g_traceGovernorLoad = false; static bool g_traceWorkqueue = false; static bool g_traceOverwrite = false; @@ -54,6 +55,9 @@ static const char* k_schedSwitchEnablePath = static const char* k_cpuFreqEnablePath = "/sys/kernel/debug/tracing/events/power/cpu_frequency/enable"; +static const char* k_cpuIdleEnablePath = + "/sys/kernel/debug/tracing/events/power/cpu_idle/enable"; + static const char* k_governorLoadEnablePath = "/sys/kernel/debug/tracing/events/cpufreq_interactive/enable"; @@ -117,6 +121,12 @@ static bool setCpuFrequencyTracingEnable(bool enable) return setKernelOptionEnable(k_cpuFreqEnablePath, enable); } +// Enable or disable tracing of CPU idle events. +static bool setCpuIdleTracingEnable(bool enable) +{ + return setKernelOptionEnable(k_cpuIdleEnablePath, enable); +} + // Enable or disable tracing of the interactive CPU frequency governor's idea of // the CPU load. static bool setGovernorLoadTracingEnable(bool enable) @@ -184,6 +194,7 @@ static bool startTrace() ok &= setTraceOverwriteEnable(g_traceOverwrite); ok &= setSchedSwitchTracingEnable(g_traceSchedSwitch); ok &= setCpuFrequencyTracingEnable(g_traceCpuFrequency); + ok &= setCpuIdleTracingEnable(g_traceCpuIdle); if (fileExists(k_governorLoadEnablePath) || g_traceGovernorLoad) { ok &= setGovernorLoadTracingEnable(g_traceGovernorLoad); } @@ -363,7 +374,7 @@ int main(int argc, char **argv) for (;;) { int ret; - ret = getopt(argc, argv, "b:cflst:wz"); + ret = getopt(argc, argv, "b:ciflst:wz"); if (ret < 0) { break; @@ -378,6 +389,10 @@ int main(int argc, char **argv) g_traceOverwrite = true; break; + case 'i': + g_traceCpuIdle = true; + break; + case 'l': g_traceGovernorLoad = true; break;