首页 > > > Android Power键唤醒速度慢分析
echo N > /sys/module/printk/parameters/console_suspend
echo 1 > /sys/power/pm_print_times
打印出每个设备唤醒的耗时」
要优化的话,就要这样debug了,看那边时间长,然后去优化对应模块咯
diff --git a/init/main.c b/init/main.c
index acbb01c..39a3b89 100755
--- a/init/main.c
+++ b/init/main.c
@ -652,7 +652,7 @ static void __init do_ctors(void)
#endif
}
-int initcall_debug;
+int initcall_debug=1;
core_param(initcall_debug, initcall_debug, bool, 0644);
12-07 07:40:15.930 2717 2787 W System.err: at java.lang.Thread.run(Thread.java:761)
12-07 07:40:15.930 2717 2787 W System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.baidu.cloudsdk.common.http.RequestParams" on path: DexPathList[[zip file "/data/app/com.baidu.appsearch-2/base.apk"],nativeLibraryDirectories=[/data/app/com.baidu.appsearch-2/lib/arm, /system/fake-libs, /data/app/com.baidu.appsearch-2/base.apk!/lib/armeabi, /system/lib, /vendor/lib]]
12-07 07:40:15.930 2717 2787 W System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-07 07:40:15.930 2717 2787 W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
12-07 07:40:15.930 2717 2787 W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
12-07 07:40:15.930 2717 2787 W System.err: ... 10 more
12-07 07:40:15.952 585 684 D SurfaceControl: Excessive delay in setPowerMode(): 139ms
12-07 07:40:15.952 585 684 E Lights Hal: write_int failed to open /sys/class/backlight/rk28_bl/brightness
12-07 07:40:15.958 585 684 E Lights Hal: write_int failed to open /sys/class/backlight/rk28_bl/brightness
12-07 07:40:15.982 585 684 E Lights Hal: write_int failed to open /sys/class/backlight/rk28_bl/brightness
12-07 07:40:15.997 585 684 E Lights Hal: write_int failed to open /sys/class/backlight/rk28_bl/brightness
12-07 07:40:16.014 585 684 E Lights Hal: write_int failed to open /sys/class/backlight/rk28_bl/brightness
这个是RK3399 的日志,setPowerMode 这里是 139ms
明显比RK3288 快的多得多!参考
Introduction
Passing the option "initcall_debug" on the kernel command line will cause timing information to be printed to the console for each initcall. initcalls are used to initialize statically linked kernel drivers and subsystems and contribute a significant amount of time to the Linux boot process. The output looks like this:
calling ipc_init+0x0/0x28 @ 1 msgmni has been set to 42 initcall ipc_init+0x0/0x28 returned 0 after 1872 usecs
You can use 'dmesg' to see the messages after the kernel has booted. With a short 'sed' script, you can reorder the final 'timing' line, and sort the initcalls numerically by duration. Here is a command to do this:
dmesg -s 128000 | grep "initcall" | sed "s/\(.*\)after\(.*\)/\2 \1/g" | sort -n
Sample output
Here is some sample output from the above command sequence. This was on an old X86-based desktop system. Printk Times was turned on (hence the extra timestamp on each line.)
24 msecs [ 2.237177] initcall acpi_button_init+0x0/0x51 returned 0
28 msecs [ 0.763503] initcall init_acpi_pm_clocksource+0x0/0x16c returned 0
32 msecs [ 0.348241] initcall acpi_pci_link_init+0x0/0x43 returned 0
33 msecs [ 0.919004] initcall inet_init+0x0/0x1c7 returned 0
33 msecs [ 5.282722] initcall psmouse_init+0x0/0x5e returned 0
54 msecs [ 2.979825] initcall e100_init_module+0x0/0x4d returned 0
71 msecs [ 0.650325] initcall pnp_system_init+0x0/0xf returned 0
91 msecs [ 0.872402] initcall pcibios_assign_resources+0x0/0x85 returned 0
187 msecs [ 4.369187] initcall ehci_hcd_init+0x0/0x70 returned 0
245 msecs [ 2.777161] initcall serial8250_init+0x0/0x100 returned 0
673 msecs [ 5.098052] initcall uhci_hcd_init+0x0/0xc1 returned 0
830 msecs [ 4.067279] initcall piix_init+0x0/0x27 returned 0
1490 msecs [ 8.290606] initcall ip_auto_config+0x0/0xd70 returned 0Notes
Using initcall_debug increases the amount of messages produced by the kernel during system boot. It's a good idea to increase the printk log buffer size to avoid overflowing the log buffer. To do this, increase the value of CONFIG_LOG_BUF_SHIFT from 14 to 18. This increases the log buffer from the default size of 16k to 256K.
You will need to enable CONFIG_PRINTK_TIME and CONFIG_KALLSYMS in your kernel configuration for this to work correctly. The first option displays printk timings and the second option ensures that function names are printed rather than memory addresses.
欢迎关注微信公众号-嵌入式Linux
觉得不错,请帮忙转发,点赞,您的每一次支持,我都将铭记于心
原文作者:;如有侵权,请联系管理员删除。