AUTHOR: Joseph Yang (杨红刚) <[email protected]>
CONTENT: 对照ftrace跟踪cpufreq 的结果,分析cpufreq工作过程
NOTE: linux-3.0
LAST MODIFIED:09-19-2011
-----------------------------------------------------------------------------------------------------------
Distributed and Embedded System Lab (分布式嵌入式系统实验室,兰州大学)
//说明: 有些函数或宏无法跟踪到,
结构:
1. 操作步骤
2. 跟踪结果
3.跟踪结果分析
4. func_list_latest
=========================================================================
1 ------------------ 操作步骤
Snail:/home/snail/Desktop# mount -t debugfs nodev /sys/kernel/debug
Snail:/home/snail/Desktop# cd /sys/kernel/debug/tracing/
Snail:/sys/kernel/debug/tracing# cat /tmp/func_list_latest > set_ftrace_filter
Snail:/sys/kernel/debug/tracing# echo function_graph > current_tracer
Snail:/sys/kernel/debug/tracing# sysctl kernel.ftrace_enabled=1
kernel.ftrace_enabled = 1
Snail:/sys/kernel/debug/tracing# echo 1 > tracing_enabled
Snail:/sys/kernel/debug/tracing# cat trace_pipe > /tmp/result&
[1] 4618
//do sth
Snail:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_governor
performance
Snail:/sys/devices/system/cpu/cpu0/cpufreq# cat affected_cpus
0
Snail:/sys/devices/system/cpu/cpu0/cpufreq# cat related_cpus
0
Snail:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_available_governors
conservative ondemand userspace powersave performance
Snail:/sys/devices/system/cpu/cpu0/cpufreq# echo userspace > scaling_governor
Snail:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_available_frequencies
350000 700000 1050000 1400000 1750000 2100000 2450000 2800000
Snail:/sys/devices/system/cpu/cpu0/cpufreq# echo 2450000 > scaling_setspeed
Snail:/sys/devices/system/cpu/cpu0/cpufreq# cat stats/total_trans
1
//end trace
Snail:/sys/kernel/debug/tracing# echo 0 > tracing_enabled
Snail:/sys/kernel/debug/tracing#
[1]+ Done cat trace_pipe > /tmp/result
Snail:/sys/kernel/debug/tracing# vim /tmp/result
Snail:/sys/kernel/debug/tracing# cat /tmp/result > /home/snail/Desktop/cpufreq-trace/result_latest
2 -------------------跟踪结果
//cat scaling_governor
0) | show() {
0) 2.492 us | cpufreq_cpu_get();
0) 3.528 us | show_scaling_governor();
0) 0.170 us | unlock_policy_rwsem_read();
0) 0.873 us | cpufreq_cpu_put();
0) + 13.733 us | }
------------------------------------------
0) cat-4950 => cat-4975 // cat affected_cpus
------------------------------------------
0) | show() {
0) 2.742 us | cpufreq_cpu_get();
0) | show_affected_cpus() {
0) 4.386 us | show_cpus();
0) 5.438 us | }
0) 0.169 us | unlock_policy_rwsem_read();
0) 0.769 us | cpufreq_cpu_put();
0) + 15.400 us | }
------------------------------------------
0) cat-4975 => cat-4985 // cat related_cpus
------------------------------------------
0) | show() {
0) 2.571 us | cpufreq_cpu_get();
0) | show_related_cpus() {
0) 3.999 us | show_cpus();
0) 5.074 us | }
0) 0.167 us | unlock_policy_rwsem_read();
0) 0.827 us | cpufreq_cpu_put();
0) + 14.607 us | }
------------------------------------------
0) cat-4985 => cat-5013 //cat scaling_available_governors
------------------------------------------
0) | show() {
0) 2.667 us | cpufreq_cpu_get();
0) 5.805 us | show_scaling_available_governors();
0) 0.161 us | unlock_policy_rwsem_read();
0) 0.850 us | cpufreq_cpu_put();
0) + 15.648 us | }
------------------------------------------
0) cat-5013 => bash-4850 //echo userspace > scaling_governor
------------------------------------------
0) | store() {
0) 2.506 us | cpufreq_cpu_get();
0) | store_scaling_governor() {
0) | cpufreq_get_policy() {
0) 0.223 us | cpufreq_cpu_get();
0) 0.832 us | cpufreq_cpu_put();
0) 3.395 us | }
0) 1.398 us | __find_governor();
0) | __cpufreq_set_policy() {
0) 0.469 us | __cpufreq_governor();
0) | __cpufreq_governor() {
0) 1.050 us | cpufreq_register_notifier();
0) 4.993 us | }
0) | __cpufreq_governor() {
0) 0.777 us | __cpufreq_driver_target();
0) 3.198 us | }
0) + 16.492 us | }
0) + 26.564 us | }
0) 0.284 us | unlock_policy_rwsem_write();
0) 0.237 us | cpufreq_cpu_put();
0) + 35.884 us | }
------------------------------------------
0) bash-4850 => cat-5092 //cat scaling_available_frequencies
------------------------------------------
0) | show() {
0) 2.736 us | cpufreq_cpu_get();
0) 0.160 us | unlock_policy_rwsem_read();
0) 1.063 us | cpufreq_cpu_put();
0) + 16.599 us | }
------------------------------------------
0) cat-5092 => bash-4850 //echo 2450000 > scaling_setspeed
------------------------------------------
0) | store() {
0) 2.583 us | cpufreq_cpu_get();
0) | store_scaling_setspeed() {
0) | __cpufreq_driver_target() {
0) | cpufreq_notify_transition() {
0) 0.330 us | adjust_jiffies();
0) 7.025 us | }
0) | cpufreq_notify_transition() {
0) 0.170 us | adjust_jiffies();
0) 5.439 us | }
0) + 19.767 us | }
0) + 24.867 us | }
0) 0.300 us | unlock_policy_rwsem_write();
0) 0.979 us | cpufreq_cpu_put();
0) + 35.445 us | }
------------------------------------------
0) bash-4850 => cat-5153 //cat stats/total_trans
------------------------------------------
0) | show() {
0) 3.269 us | cpufreq_cpu_get();
0) 0.190 us | unlock_policy_rwsem_read();
0) 0.925 us | cpufreq_cpu_put();
0) + 17.763 us | }
3 ----------------------跟踪结果分析
4 -------------func_list_latest
unlock_policy_rwsem_read
unlock_policy_rwsem_write
cpufreq_cpu_get
cpufreq_cpu_put
adjust_jiffies
cpufreq_notify_transition
__find_governor
show_cpuinfo_cur_freq
show_scaling_governor
store_scaling_governor
show_scaling_driver
show_scaling_available_governors
show_cpus
show_related_cpus
show_affected_cpus
store_scaling_setspeed
show_scaling_setspeed
show_bios_limit
show
store
cpufreq_sysfs_release
cpufreq_add_dev
cpufreq_remove_dev
cpufreq_get
cpufreq_bp_suspend
cpufreq_bp_resume
cpufreq_register_notifier
cpufreq_unregister_notifier
__cpufreq_driver_target
cpufreq_driver_target
__cpufreq_driver_getavg
__cpufreq_governor
cpufreq_register_governor
cpufreq_unregister_governor
cpufreq_get_policy
__cpufreq_set_policy
cpufreq_update_policy
cpufreq_register_driver
cpufreq_unregister_driver