[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 enableflags's bit, please refer to "system/core/include/cutils/trace.h"
3). Add ftrace tags which you wanted
In the project's 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
本文介绍如何使用Systrace工具收集并分析Android启动期间的内核和应用层跟踪数据。通过调整配置文件,如启用跟踪、设置标记、增加缓冲区大小等步骤,可以详细地诊断启动过程中的性能瓶颈。

3868

被折叠的 条评论
为什么被折叠?



