diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-05-22 18:58:46 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-05-22 18:58:46 -0700 |
commit | ac9453d82e9077a8b02afa4e26ef9ff1f47b4ee9 (patch) | |
tree | 10da4c7f693595d816c453ac3ee04e24390c2806 | |
parent | 3169533f1d11c4a7aa0cd6fa2aa04fc810db0de6 (diff) | |
download | frameworks_native-ac9453d82e9077a8b02afa4e26ef9ff1f47b4ee9.zip frameworks_native-ac9453d82e9077a8b02afa4e26ef9ff1f47b4ee9.tar.gz frameworks_native-ac9453d82e9077a8b02afa4e26ef9ff1f47b4ee9.tar.bz2 |
Add disk I/O tracing.
Bug: 6488845
Change-Id: I93acb726f35b114fb1ea7297da4456826f805b7b
-rw-r--r-- | cmds/atrace/Android.mk | 1 | ||||
-rw-r--r-- | cmds/atrace/atrace.c | 34 |
2 files changed, 34 insertions, 1 deletions
diff --git a/cmds/atrace/Android.mk b/cmds/atrace/Android.mk index df79e82..1de8e95 100644 --- a/cmds/atrace/Android.mk +++ b/cmds/atrace/Android.mk @@ -6,6 +6,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= atrace.c LOCAL_C_INCLUDES += external/zlib +LOCAL_CFLAGS += -std=c99 LOCAL_MODULE:= atrace diff --git a/cmds/atrace/atrace.c b/cmds/atrace/atrace.c index a674295..a0d4250 100644 --- a/cmds/atrace/atrace.c +++ b/cmds/atrace/atrace.c @@ -25,11 +25,14 @@ #include <time.h> #include <zlib.h> +#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) + /* Command line options */ static int g_traceDurationSeconds = 5; static bool g_traceSchedSwitch = false; static bool g_traceCpuFrequency = false; static bool g_traceCpuIdle = false; +static bool g_traceDisk = false; static bool g_traceGovernorLoad = false; static bool g_traceWorkqueue = false; static bool g_traceOverwrite = false; @@ -64,6 +67,13 @@ static const char* k_governorLoadEnablePath = static const char* k_workqueueEnablePath = "/sys/kernel/debug/tracing/events/workqueue/enable"; +static const char* k_diskEnablePaths[] = { + "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable", + "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable", + "/sys/kernel/debug/tracing/events/block/block_rq_issue/enable", + "/sys/kernel/debug/tracing/events/block/block_rq_complete/enable", +}; + static const char* k_tracingOnPath = "/sys/kernel/debug/tracing/tracing_on"; @@ -102,6 +112,16 @@ static bool setKernelOptionEnable(const char* filename, bool enable) return writeStr(filename, enable ? "1" : "0"); } +// Enable or disable a collection of kernel options by writing a "1" or a "0" into each /sys file. +static bool setMultipleKernelOptionsEnable(const char** filenames, size_t count, bool enable) +{ + bool result = true; + for (size_t i = 0; i < count; i++) { + result &= setKernelOptionEnable(filenames[i], enable); + } + return result; +} + // Enable or disable overwriting of the kernel trace buffers. Disabling this // will cause tracing to stop once the trace buffers have filled up. static bool setTraceOverwriteEnable(bool enable) @@ -140,6 +160,12 @@ static bool setWorkqueueTracingEnabled(bool enable) return setKernelOptionEnable(k_workqueueEnablePath, enable); } +// Enable or disable tracing of disk I/O. +static bool setDiskTracingEnabled(bool enable) +{ + return setMultipleKernelOptionsEnable(k_diskEnablePaths, NELEM(k_diskEnablePaths), enable); +} + // Enable or disable kernel tracing. static bool setTracingEnabled(bool enable) { @@ -199,6 +225,7 @@ static bool startTrace() ok &= setGovernorLoadTracingEnable(g_traceGovernorLoad); } ok &= setWorkqueueTracingEnabled(g_traceWorkqueue); + ok &= setDiskTracingEnabled(g_traceDisk); ok &= setTraceBufferSizeKB(g_traceBufferSizeKB); ok &= setGlobalClockEnable(true); @@ -336,6 +363,7 @@ static void showHelp(const char *cmd) fprintf(stderr, "options include:\n" " -b N use a trace buffer size of N KB\n" " -c trace into a circular buffer\n" + " -d trace disk I/O\n" " -f trace CPU frequency changes\n" " -l trace CPU frequency governor load\n" " -s trace the kernel scheduler switches\n" @@ -374,7 +402,7 @@ int main(int argc, char **argv) for (;;) { int ret; - ret = getopt(argc, argv, "b:ciflst:wz"); + ret = getopt(argc, argv, "b:cidflst:wz"); if (ret < 0) { break; @@ -397,6 +425,10 @@ int main(int argc, char **argv) g_traceGovernorLoad = true; break; + case 'd': + g_traceDisk = true; + break; + case 'f': g_traceCpuFrequency = true; break; |