atrace: add support for tracing CPU idle events

This change adds the -i command line flag to atrace to enable tracing CPU idle
kernel events.

Change-Id: I4a2c8619224c0f50c7fd7c61c7b24fa2211f656c
This commit is contained in:
Jamie Gennis 2012-05-07 17:58:44 -07:00
parent 7b5170b249
commit 3169533f1d

View File

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