How to capture Boot-up trace
[DESCRIPTION]
Systrace allows collecting both kernel and Android traces during boot up. Visualization of systrace can help in analyzing specific problem during the boot-up. And we also can capture kernel trace to check the average number or accumulated number during the entire boot.
[SOLUTION]
============================================================== 1). Enables tracing during boot-up
Android O: In frameworks/native/atrace/atrace.rc, change: write /sys/kernel/debug/tracing/tracing_on 0 To: #write /sys/kernel/debug/tracing/tracing_on 0 This enables tracing (which is disabled by default). Android P0: In frameworks/native/cmds/atrace/atrace.rc # Tracing disabled by default write /sys/kernel/debug/tracing/tracing_on 0 To: # write /sys/kernel/debug/tracing/tracing_on 0 2). Set systrace tags In the device/mediatek/mt67××/device.mk file, add the following line: PRODUCT_PROPERTY_OVERRIDES += debug.atrace.tags.enableflags=0x1fe9fe For enableflagss bit, please refer to "system/core/include/cutils/trace.h" 3). Add ftrace tags which you wanted In the projects BoardConfig.mk file, add the following: BOARD_KERNEL_CMDLINE := ... trace_buf_size=64M trace_event=sched_wakeup,sched_switch,sched_blocked_reason,sched_wakeup_new,sched_waking,cpu_frequency,cpufreq_interactive,cpu_frequency_limits,cpu_idle For detailed I/O analysis, also add "block android_fs ext4..." trace tags If you want catch more trace log, you can increase trace_buf_size. But if the phone memory size is less then 1GB, you need reduce trace_buf_size, such as "trace_buf_size=32M" for 512MB devices. 4). Disable tracing after boot-up completed In the device-specific init.mt67**.rc file, make the following changes, such as: on property:sys.boot_completed=1 (this stops tracing on boot complete) write /sys/kernel/debug/tracing/tracing_on 0 write /sys/kernel/debug/tracing/events/ext4/enable 0 write /sys/kernel/debug/tracing/events/block/enable 0 write /sys/kernel/debug/tracing/events/android_fs/enable 0 5). After boot up, fetch trace adb root && adb shell "cat /d/tracing/trace" > boot_trace 6). Open trace
Use chrome://tracing can open boot_trace
============================================================== Reference: https://source.android.com/devices/tech/perf/boot-times
