功耗分析-查看Suspend状态

0. 文章参考

http://www.wowotech.net/linux_kenrel/suspend_and_resume.html

在suspend状态(sleep mode)下,为了降低功耗,当系统做完需要做的事情,处于idle状态时会进入睡眠模式(用户将手机空置一段时间系统会自动sleep,或者按下power key强制系统进入sleep mode),此时系统时钟会由26M切换到32K,某些外部device的电源会被关闭,系统所需的相关core电压会被调到一个相对较低的值,系统在sleep mode下的耗电要关注如下两个指标:

  • 底电流:手机在sleep状态下消耗的最小电流,与整个系统的漏电相关;
  • 平均电流:在一段时间内,对手机取电流的平均值,与手机的wake up行为相关。

1. 判断是否进入suspend的关键信息

一个完整的suspend/唤醒log,应该包含关键字Chip_pm_enter、md_settle = 99, settle = 99和wake up byXXX。md_settle = 99, settle = 99是系统进入suspend前打印的最后一行log,正常的话这一行log的前后行log时间戳是不会变的,因为suspend之后kernel时间不会计算,只有32k时钟工作。

<6>[  922.885697]  (0)[1180:system_server]PM: suspend entry 2017-03-09 06:55:59.675845617 UTC
<6>[  922.885711]  (0)[1180:system_server]PM: Syncing filesystems ... done.
<3>[  922.993726]  (0)[1180:system_server][PBM] PM_SUSPEND_PREPARE:start
<3>[  922.993747]  (0)[1180:system_server][PBM] PM_SUSPEND_PREPARE:end
<7>[  923.097349] -(0)[1180:system_server][name:mt_sleep&][SLP] @@@Chip_pm_enter@@@
<6>[  923.097349] -(0)[1180:system_server][Power/clkmgr] [slp_check_pm_mtcmos_pll]
<6>[  923.097349] -(0)[1180:system_server][Power/clkmgr] SYS_MD1: on
<6>[  923.097349] -(0)[1180:system_server][Power/clkmgr] SYS_CONN: on
<2>[  923.097349] -(0)[1180:system_server][SPM-PMIC] [dlpt_R] pre_SOC=57 SOC=57 skip
<4>[  923.097349] -(0)[1180:system_server]Suspend  - 6328 - 0x248 - 0x7673 - 0xfeff - 0x7473 - 9
<4>[  923.097349] -(0)[1180:system_server]Suspend  - 6328 - 0x4d6 - 0x3021 - 0x0001 - 0x0020 - 0
<4>[  923.097349] -(0)[1180:system_server]Suspend  - 6328 - 0xa32 - 0xc102 - 0x000e - 0x0100 - 1
<4>[  923.097349] -(0)[1180:system_server]Suspend  - 6328 - 0xa3a - 0xc102 - 0x000e - 0x0000 - 1
<4>[  923.097349] -(0)[1180:system_server][SPM] md_settle = 99, settle = 99
<4>[  923.097349] -(0)[1180:system_server][SPM] sec = 900, wakesrc = 0xe04c5e4 (1)(1)
<4>[  923.097349] -(0)[1180:system_server][SPM] wake up byEINT, timer_out = 7440931, r13 = 0x10001000, debug_flag = 0x9f
<6>[  923.334796]  (1)[1180:system_server]PM: suspend exit 2017-03-09 06:59:47.201326615 UTC

2. 可以通过log确认suspend的时间点以及suspend的时长

2.1 确认 suspend 的时间点

关键字:PM: suspend entry

<6>[  922.885697]  (0)[1180:system_server]PM: suspend entry 2017-03-09 06:55:59.675845617 UTC
2.2 通过 suspend entry 和 md_settle 确定suspend时长

后面跟的时间就是当前的UTC time(跟上层的android time换算要加上时区)。
这个时间就是睡眠的粗略时间,精确时间就是再加上两句log的时间戳相减:

<6>[  922.885697]  (0)[1180:system_server]PM: suspend entry 2017-03-09 06:55:59.675845617 UTC

<4>[  923.097349] -(0)[1180:system_server][SPM] md_settle = 99, settle = 99

睡眠的准确时间点 = 06:55:59.675845617 + (923.097349 - 922.885697) = 06:55:59.887497617

2.3 PM: suspend exit的时间戳减去PM: suspend entry的时间戳
390: <6>[  868.695672] PM: suspend entry 2019-03-05 01:48:36.914426509 UTC 

394: <4>[  868.732182] Suspending console(s) (use no_console_suspend to debug) 
395: <6>[  868.740534] PM: Wakeup pending, aborting suspend 
397: <3>[  868.749441] PM: Some devices failed to suspend, or early wake event detected 
401: <6>[  868.797664] PM: suspend exit 2019-03-05 01:48:37.016425103 UTC 

睡眠的准确时间点 = 868.797664 - 868.695672 = 0.101992

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值