OSDN Git Service

atrace: setup saved_cmdlines_size and write only if available
authorJoel Fernandes <joelaf@google.com>
Tue, 6 Jun 2017 19:20:29 +0000 (12:20 -0700)
committerJoel Fernandes <joelaf@google.com>
Tue, 6 Jun 2017 19:35:54 +0000 (12:35 -0700)
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 <joelaf@google.com>
cmds/atrace/atrace.cpp
cmds/atrace/atrace.rc

index 595fbab..d61cbc9 100644 (file)
@@ -446,7 +446,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
index 1e0f6f8..aab86c7 100644 (file)
@@ -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
@@ -65,6 +67,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