From 9351f72049a2bc65170afcf131008c8bd1710959 Mon Sep 17 00:00:00 2001 From: Joel Fernandes Date: Tue, 6 Jun 2017 12:20:29 -0700 Subject: [PATCH] atrace: setup saved_cmdlines_size and write only if available Older kernels (bullhead etc) don't have saved_cmdlines_size, check and write only if available. Also make work on non-root by setting permissions in rc file (thanks John Reck for suggestion). Bug: 62375794 Change-Id: Iefffc3203afd092ffb6cf420a144b38844aaee39 Signed-off-by: Joel Fernandes --- cmds/atrace/atrace.cpp | 5 ++++- cmds/atrace/atrace.rc | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 6f2159db23..8758516a4d 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -444,7 +444,10 @@ static bool setTraceBufferSizeKB(int size) // Set the default size of cmdline hashtable static bool setCmdlineSize() { - return writeStr(k_traceCmdlineSizePath, "8192"); + if (fileExists(k_traceCmdlineSizePath)) { + return writeStr(k_traceCmdlineSizePath, "8192"); + } + return true; } // Set the clock to the best available option while tracing. Use 'boot' if it's diff --git a/cmds/atrace/atrace.rc b/cmds/atrace/atrace.rc index cef41bebf4..5e9cef384b 100644 --- a/cmds/atrace/atrace.rc +++ b/cmds/atrace/atrace.rc @@ -15,6 +15,8 @@ on post-fs chown root shell /sys/kernel/tracing/options/overwrite chown root shell /sys/kernel/debug/tracing/options/print-tgid chown root shell /sys/kernel/tracing/options/print-tgid + chown root shell /sys/kernel/debug/tracing/options/saved_cmdlines_size + chown root shell /sys/kernel/tracing/options/saved_cmdlines_size chown root shell /sys/kernel/debug/tracing/events/sched/sched_switch/enable chown root shell /sys/kernel/tracing/events/sched/sched_switch/enable chown root shell /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable @@ -63,6 +65,8 @@ on post-fs chmod 0664 /sys/kernel/tracing/options/overwrite chmod 0664 /sys/kernel/debug/tracing/options/print-tgid chmod 0664 /sys/kernel/tracing/options/print-tgid + chmod 0664 /sys/kernel/debug/tracing/options/saved_cmdlines_size + chmod 0664 /sys/kernel/tracing/options/saved_cmdlines_size chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_switch/enable chmod 0664 /sys/kernel/tracing/events/sched/sched_switch/enable chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable -- 2.11.0