1## Permissions to allow system-wide tracing to the kernel trace buffer.
2##
3on post-fs
4
5# Allow writing to the kernel trace log.
6    chmod 0222 /sys/kernel/debug/tracing/trace_marker
7    chmod 0222 /sys/kernel/tracing/trace_marker
8
9# Allow the shell group to enable (some) kernel tracing.
10    chown root shell /sys/kernel/debug/tracing/trace_clock
11    chown root shell /sys/kernel/tracing/trace_clock
12    chown root shell /sys/kernel/debug/tracing/buffer_size_kb
13    chown root shell /sys/kernel/tracing/buffer_size_kb
14    chown root shell /sys/kernel/debug/tracing/options/overwrite
15    chown root shell /sys/kernel/tracing/options/overwrite
16    chown root shell /sys/kernel/debug/tracing/options/print-tgid
17    chown root shell /sys/kernel/tracing/options/print-tgid
18    chown root shell /sys/kernel/debug/tracing/saved_cmdlines_size
19    chown root shell /sys/kernel/tracing/saved_cmdlines_size
20    chown root shell /sys/kernel/debug/tracing/events/sched/sched_switch/enable
21    chown root shell /sys/kernel/tracing/events/sched/sched_switch/enable
22    chown root shell /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
23    chown root shell /sys/kernel/tracing/events/sched/sched_wakeup/enable
24    chown root shell /sys/kernel/debug/tracing/events/sched/sched_blocked_reason/enable
25    chown root shell /sys/kernel/tracing/events/sched/sched_blocked_reason/enable
26    chown root shell /sys/kernel/debug/tracing/events/sched/sched_cpu_hotplug/enable
27    chown root shell /sys/kernel/tracing/events/sched/sched_cpu_hotplug/enable
28    chown root shell /sys/kernel/debug/tracing/events/power/cpu_frequency/enable
29    chown root shell /sys/kernel/tracing/events/power/cpu_frequency/enable
30    chown root shell /sys/kernel/debug/tracing/events/power/cpu_idle/enable
31    chown root shell /sys/kernel/tracing/events/power/cpu_idle/enable
32    chown root shell /sys/kernel/debug/tracing/events/power/clock_set_rate/enable
33    chown root shell /sys/kernel/tracing/events/power/clock_set_rate/enable
34    chown root shell /sys/kernel/debug/tracing/events/power/cpu_frequency_limits/enable
35    chown root shell /sys/kernel/tracing/events/power/cpu_frequency_limits/enable
36    chown root shell /sys/kernel/debug/tracing/events/cpufreq_interactive/enable
37    chown root shell /sys/kernel/tracing/events/cpufreq_interactive/enable
38    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable
39    chown root shell /sys/kernel/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable
40    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable
41    chown root shell /sys/kernel/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable
42    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable
43    chown root shell /sys/kernel/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable
44    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable
45    chown root shell /sys/kernel/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable
46    chown root shell /sys/kernel/debug/tracing/events/binder/binder_transaction/enable
47    chown root shell /sys/kernel/tracing/events/binder/binder_transaction/enable
48    chown root shell /sys/kernel/debug/tracing/events/binder/binder_transaction_received/enable
49    chown root shell /sys/kernel/tracing/events/binder/binder_transaction_received/enable
50    chown root shell /sys/kernel/debug/tracing/events/binder/binder_lock/enable
51    chown root shell /sys/kernel/tracing/events/binder/binder_lock/enable
52    chown root shell /sys/kernel/debug/tracing/events/binder/binder_locked/enable
53    chown root shell /sys/kernel/tracing/events/binder/binder_locked/enable
54    chown root shell /sys/kernel/debug/tracing/events/binder/binder_unlock/enable
55    chown root shell /sys/kernel/tracing/events/binder/binder_unlock/enable
56
57    chown root shell /sys/kernel/debug/tracing/tracing_on
58    chown root shell /sys/kernel/tracing/tracing_on
59
60    chmod 0664 /sys/kernel/debug/tracing/trace_clock
61    chmod 0664 /sys/kernel/tracing/trace_clock
62    chmod 0664 /sys/kernel/debug/tracing/buffer_size_kb
63    chmod 0664 /sys/kernel/tracing/buffer_size_kb
64    chmod 0664 /sys/kernel/debug/tracing/options/overwrite
65    chmod 0664 /sys/kernel/tracing/options/overwrite
66    chmod 0664 /sys/kernel/debug/tracing/options/print-tgid
67    chmod 0664 /sys/kernel/tracing/options/print-tgid
68    chmod 0664 /sys/kernel/debug/tracing/saved_cmdlines_size
69    chmod 0664 /sys/kernel/tracing/saved_cmdlines_size
70    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_switch/enable
71    chmod 0664 /sys/kernel/tracing/events/sched/sched_switch/enable
72    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
73    chmod 0664 /sys/kernel/tracing/events/sched/sched_wakeup/enable
74    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_blocked_reason/enable
75    chmod 0664 /sys/kernel/tracing/events/sched/sched_blocked_reason/enable
76    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_cpu_hotplug/enable
77    chmod 0664 /sys/kernel/tracing/events/sched/sched_cpu_hotplug/enable
78    chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_frequency/enable
79    chmod 0664 /sys/kernel/tracing/events/power/cpu_frequency/enable
80    chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_idle/enable
81    chmod 0664 /sys/kernel/tracing/events/power/cpu_idle/enable
82    chmod 0664 /sys/kernel/debug/tracing/events/power/clock_set_rate/enable
83    chmod 0664 /sys/kernel/tracing/events/power/clock_set_rate/enable
84    chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_frequency_limits/enable
85    chmod 0664 /sys/kernel/tracing/events/power/cpu_frequency_limits/enable
86    chmod 0664 /sys/kernel/debug/tracing/events/cpufreq_interactive/enable
87    chmod 0664 /sys/kernel/tracing/events/cpufreq_interactive/enable
88    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable
89    chmod 0664 /sys/kernel/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable
90    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable
91    chmod 0664 /sys/kernel/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable
92    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable
93    chmod 0664 /sys/kernel/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable
94    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable
95    chmod 0664 /sys/kernel/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable
96    chmod 0664 /sys/kernel/debug/tracing/tracing_on
97    chmod 0664 /sys/kernel/tracing/tracing_on
98    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_transaction/enable
99    chmod 0664 /sys/kernel/tracing/events/binder/binder_transaction/enable
100    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_transaction_received/enable
101    chmod 0664 /sys/kernel/tracing/events/binder/binder_transaction_received/enable
102    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_lock/enable
103    chmod 0664 /sys/kernel/tracing/events/binder/binder_lock/enable
104    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_locked/enable
105    chmod 0664 /sys/kernel/tracing/events/binder/binder_locked/enable
106    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_unlock/enable
107    chmod 0664 /sys/kernel/tracing/events/binder/binder_unlock/enable
108    chmod 0664 /sys/kernel/debug/tracing/events/i2c/enable
109    chmod 0664 /sys/kernel/tracing/events/i2c/enable
110    chmod 0664 /sys/kernel/debug/tracing/events/i2c/i2c_read/enable
111    chmod 0664 /sys/kernel/tracing/events/i2c/i2c_read/enable
112    chmod 0664 /sys/kernel/debug/tracing/events/i2c/i2c_write/enable
113    chmod 0664 /sys/kernel/tracing/events/i2c/i2c_write/enable
114    chmod 0664 /sys/kernel/debug/tracing/events/i2c/i2c_result/enable
115    chmod 0664 /sys/kernel/tracing/events/i2c/i2c_result/enable
116    chmod 0664 /sys/kernel/debug/tracing/events/i2c/i2c_reply/enable
117    chmod 0664 /sys/kernel/tracing/events/i2c/i2c_reply/enable
118    chmod 0664 /sys/kernel/debug/tracing/events/i2c/smbus_read/enable
119    chmod 0664 /sys/kernel/tracing/events/i2c/smbus_read/enable
120    chmod 0664 /sys/kernel/debug/tracing/events/i2c/smbus_write/enable
121    chmod 0664 /sys/kernel/tracing/events/i2c/smbus_write/enable
122    chmod 0664 /sys/kernel/debug/tracing/events/i2c/smbus_result/enable
123    chmod 0664 /sys/kernel/tracing/events/i2c/smbus_result/enable
124    chmod 0664 /sys/kernel/debug/tracing/events/i2c/smbus_reply/enable
125    chmod 0664 /sys/kernel/tracing/events/i2c/smbus_reply/enable
126
127    # Tracing disabled by default
128    write /sys/kernel/debug/tracing/tracing_on 0
129    write /sys/kernel/tracing/tracing_on 0
130
131# Allow only the shell group to read and truncate the kernel trace.
132    chown root shell /sys/kernel/debug/tracing/trace
133    chown root shell /sys/kernel/tracing/trace
134    chmod 0660 /sys/kernel/debug/tracing/trace
135    chmod 0660 /sys/kernel/tracing/trace
136
137on property:persist.debug.atrace.boottrace=1
138    start boottrace
139
140# Run atrace with the categories written in a file
141service boottrace /system/bin/atrace --async_start -f /data/misc/boottrace/categories
142    disabled
143    oneshot
144