【boottime】开机时间优化 boot up time quick breakdown

1. Make sure you are using user build. Also, system should be stable, no crashed logs can be seen on logcat/dmesg.
2. Kernel Footprint(config) check
For any performance issue, the first step is to check kernel footprint. On default qcom release code, perf footprint (msmxxx-perf_defconfig) will be built if build in 'user' variant. See  AndroidBoard.mk for details.
PLEASE MAKE SURE YOU ARE USING msmxxx-perf_defconfig, If you using your own defconfig, make sure below configs are not in $Android_Source/out/target/product/$TARGET/obj/KERNEL_OBJ/.config:
CONFIG_CGROUP_DEBUG
CONFIG_MODULE_SIG=y
CONFIG_MODULE_SIG_FORCE=y
CONFIG_MODULE_SIG_SHA512=y
CONFIG_SERIAL_MSM_HS=y
CONFIG_SERIAL_MSM_HSL=y
CONFIG_SERIAL_MSM_HSL_CONSOLE=y
CONFIG_MSM_ADSPRPC=y
CONFIG_REGULATOR_TPS65132=y
CONFIG_MSM_QUSB_PHY=y
CONFIG_USB_BAM=y
CONFIG_PFT=y
CONFIG_CORESIGHT=y
CONFIG_CORESIGHT_EVENT=y
CONFIG_CORESIGHT_FUSE=y
CONFIG_CORESIGHT_CTI=y
CONFIG_CORESIGHT_TMC=y
CONFIG_CORESIGHT_TPIU=y
CONFIG_CORESIGHT_FUNNEL=y
CONFIG_CORESIGHT_REPLICATOR=y
CONFIG_CORESIGHT_STM=y
CONFIG_CORESIGHT_HWEVENT=y
CONFIG_CORESIGHT_ETMV4=y
CONFIG_CORESIGHT_MODEM_ETM=y
CONFIG_CORESIGHT_WCN_ETM=y
CONFIG_CORESIGHT_RPM_ETM=y
CONFIG_CP_ACCESS64=y
CONFIG_MSM_SMD_DEBUG=y
CONFIG_MSM_DEBUG_LAR_UNLOCK=y
CONFIG_MSM_FORCE_WDOG_BITE_ON_PANIC=y
CONFIG_MSM_OCMEM_DEBUG=y
CONFIG_MSM_OCMEM_NONSECURE=y
CONFIG_MSM_TZ_LOG=y
CONFIG_LOCKUP_DETECTOR=y
CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DEBUG_MUTEXES=y
CONFIG_DEBUG_ATOMIC_SLEEP=y
CONFIG_DEBUG_STACK_USAGE=y
CONFIG_DEBUG_MEMORY_INIT=y
CONFIG_DEBUG_LIST=y
CONFIG_FAULT_INJECTION=y
CONFIG_FAIL_PAGE_ALLOC=y
CONFIG_FAULT_INJECTION_DEBUG_FS=y
CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
CONFIG_MSM_RTB=y
CONFIG_MSM_RTB_SEPARATE_CPUS=y
CONFIG_DYNAMIC_DEBUG=y
CONFIG_PANIC_ON_DATA_CORRUPTION=y
CONFIG_STRICT_MEMORY_RWX=y

3. Disable serial console 
Serial console will delay the bootup time, so please make sure you remove them. Remove CONFIG_SERIAL_MSM_HSL and CONFIG_SERIAL_MSM_HSL_CONSOLE from your kernel footprint file, as item2 said, firstly, you should sue msmxxxx-perf_defconfig instead of msmxxxx_defconfig, so remove CONFIG_SERIAL_MSM_HSL and CONFIG_SERIAL_MSM_HSL_CONSOLE from exactly the one you are using, below patch is just a example:
diff --git a/arch/arm(64)/configs/msmxxxx-perf_defconfig b/arch/arm(64)/configs/msmxxxx-perf_defconfig
@@ -269,8 +269,6 @@ CONFIG_INPUT_GPIO=m
 # CONFIG_SERIO_I8042 is not set
 # CONFIG_VT is not set
 CONFIG_SERIAL_MSM_HS=y
-CONFIG_SERIAL_MSM_HSL=y
-CONFIG_SERIAL_MSM_HSL_CONSOLE=y
 CONFIG_SERIAL_MSM_SMD=y
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y

4. Disable early printk
early print should be disable to shorten early bootup time. Find our the BoardConfig.mk file you are using, remove 'earlyprintk=msm_hsl_uart,0xf991e000'. Below is a example:
diff --git a/BoardConfig.mk b/BoardConfig.mk
@@ -48,7 +48,7 @@ TARGET_USES_ION := true
 TARGET_USES_NEW_ION_API :=true
 TARGET_USES_OVERLAY := true
 
-BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-3 earlyprintk=msm_hsl_uart,0xf991e000
+BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-3

Please make sure earlyprintk was removed by kernel config:
when device is booting, get the kernel config and find keywords 'Kernel command line' and you will find logs like below, make sure there is no any earlyprintk should be included:
<5>[    0.000000] Kernel command line: sched_enable_hmp=1 console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 androidboot.emmc=true androidboot.serialno=5541ec91 androidboot.baseband=msm mdss_mdp3.panel=1:dsi:0:qcom,mdss_dsi_hx8389b_qhd_video:1:none

5. number of bootup cores
For chipset has 6 or more cores (such as 8916/8939), you'd better to config how much cores can be onlined during booting. 
Below 3 patches should be applied (normally there are mainlined if your build is not too old):
https://www.codeaurora.org/cgit/quic/la//device/qcom/common/commit/?id=6df8a1ba549e6bf64fae2a73e2f6e3249bd72701
https://www.codeaurora.org/cgit/quic/la//kernel/msm-3.10/commit/?id=d77f3f9feded36585a41fa094b17493ee7bb6092
https://www.codeaurora.org/cgit/quic/la//platform/system/core/commit/?id=7f29bccd05b584dfb2028ba8579e04eaf7628f46
Please notice the patches may need to be adjusted to specific chipset, but the mechanism is same. Try to change below value to get a best bootup time:
+		bootargs = "boot_cpus=0 androidboot.earlyboot_cpus=2,4,6 sched_enable_hmp=1";
Please note that more core might be not better, since if more cores are up and the temperature will go up quickly, then thermal might kick in, which I will say on the next item.

6. please mind thermal
Normally, cpu is busy during booting and temperature goes up quickly, then thermal kickin and make cpu run slowly. 
How do I know is thermal kicking in:
check kernel config, below logs indicate you that thermal is affecting:
<6>[ 4.751118] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU0 max frequency to 806400. Temp:70
<6>[ 4.751198] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU1 max frequency to 806400. Temp:70
<6>[ 4.751275] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU2 max frequency to 806400. Temp:70
<6>[ 4.751352] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU3 max frequency to 806400. Temp:70
<6>[ 4.751430] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU4 max frequency to 200000. Temp:70
<6>[ 4.751508] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU5 max frequency to 200000. Temp:70
<6>[ 4.751585] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU6 max frequency to 200000. Temp:70
<6>[ 4.751662] [0: kworker/0:1: 39] msm_thermal:do_cluster_freq_ctrl Limiting CPU7 max frequency to 200000. Temp:70

If thermal is affecting ,then you might need power/thermal team to help to tune thermal config.

7. still need qcom's help to checking, logs are needed:
1) open a  window and collect kernel logs, make sure the logs are collect with very beginning:
    adb root
    adb shell dmesg > kernel.txt
2) at the same time, open a new window and collect event logcat:
    adb logcat -v threadtime -b events > logcat_events.txt

3) at the same time, open a new window and collect main/system logcat: 
    adb logcat -v threadtime > logcat.txt

share all above outputs files.

你可能感兴趣的:(Qualcomm经验总结)