Android/Linux boot time优化

时间:2022-06-14 05:19:23

基于analyze_boot.py分析Android/Linux的kernel boot时间

1.修改HiKey的BoardConfig.mk文件,使能initcall_debug,增加dmesg buffer大小。

diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index 6d17130..64e8789 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -4,7 +4,7 @@ TARGET_BOARD_PLATFORM := hikey
ifeq ($(TARGET_KERNEL_USE_4_1), true)
BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noru
else
-BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
+BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime initcall_debug log_buf_len=16M
endif
 
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736

2.adb shell dmesg保存内核log到dmesg.txt中。

adb shell dmesg > dmesg.txt

3.使用analyze_boot.py分析dmesg.txt,生成从kernel启动到启动用户空间init之间timeline图表。

./analyze_boot.py -dmesg dmesg.txt
          Host: lenovo-Product
     Test time: 2017-01-09_19:16:25
     Boot time: 1970-01-01_08:00:03
Kernel Version: 4.4.0-31-generic
  Kernel start: 0.000
    init start: 5977.254

4.结果分析。

整个boot情况概况如下:

Android/Linux boot time优化

查看某一个细节的启动时间,如hisi_thermal_driver_init:

Android/Linux boot time优化

工具代码分析

analyze_boot.py:https://github.com/arnoldlu/suspendresume/blob/master/analyze_boot.py

参考资料:

http://processors.wiki.ti.com/index.php/Android_Boot_Time_Optimization

http://blog.****.net/weiqifa0/article/details/48996033

http://blog.****.net/springdia/article/details/8308914

http://elinux.org/Using_Bootchart_on_Android

http://elinux.org/Improving_Android_Boot_Time_Outline

http://androidzaurus.seesaa.net/article/111434080.html