linux 内核perf,Linux下的内核测试工具——perf使用简介

4.精确制导——定位程序瓶颈perf record && perf report

4.1查找时间上的热点函数

perf record – e cpu-clock ./test1

perf report

43b4558c9fe9dbe5584a70535967b4c0.png

3个问题:

1)perf未能定位本地符号表对应的symbol和地址的对应关系:0x000003d4对应的什么函数?

2)采样频率不够高,失去了一些函数的信息:显然一些内核函数没有显示在上面的结果中,因为采样频率如果不够高,那么势必会有一些函数中的采样点没有/

3)如何克服采样的随机性带来的问题:为了在测量更加逼近正确值,我们采用多次重复取平均值的方法来逼近真实值。(这里可以用-r来指定重复次数)

对于问题2),我们可以用perf record -F count 来指定采样频率加以解决:

root@hyk-linux:/home/hyk/program/cprogram# perf record -F 50000 -e cpu-clock ./test1

[ perf record: Woken up 3 times to write data ]

[ perf record: Captured and wrote 0.532 MB perf.data (~23245 samples) ]

root@hyk-linux:/home/hyk/program/cprogram# perf report

# ========

# captured on: Mon Aug 26 09:54:45 2013

# hostname : hyk-linux

# os release : 3.10.9

# perf version : 3.10.9

# arch : i686

# nrcpus online : 4

# nrcpus avail : 4

# cpudesc : Intel(R) Core(TM) i5-2430M CPU @ 2.40GHz

# cpuid : GenuineIntel,6,42,7

# total memory : 4084184 kB

# cmdline : /media/usr/src/linux-3.10.9/tools/perf/perf record -F 50000 -e cpu-c

# event : name = cpu-clock, type = 1, config = 0x0, config1 = 0x0, config2 = 0x0

# HEADER_CPU_TOPOLOGY info available, use -I to display

# pmu mappings: cpu = 4, software = 1, tracepoint = 2, uncore_cbox_0 = 6, uncore

# ========

#

# Samples: 13K of event 'cpu-clock'

# Event count (approx.): 273580000

#

# Overhead  Command      Shared Object                           Symbol

# ........  .......  .................  ...............................

#

99.77%    test1  test1              [.] 0x000003c3

0.07%    test1  ld-2.15.so         [.] 0x00004c99

0.02%    test1  [kernel.kallsyms]  [k] __wake_up_bit

0.01%    test1  [kernel.kallsyms]  [k] __kunmap_atomic

0.01%    test1  [kernel.kallsyms]  [k] load_elf_binary

0.01%    test1  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore

0.01%    test1  libc-2.15.so       [.] 0x00097d8e

0.01%    test1  [kernel.kallsyms]  [k] exit_itimers

0.01%    test1  [kernel.kallsyms]  [k] profile_munmap

0.01%    test1  [kernel.kallsyms]  [k] get_page_from_freelist

0.01%    test1  [kernel.kallsyms]  [k] vma_interval_tree_remove

0.01%    test1  [kernel.kallsyms]  [k] change_protection

0.01%    test1  [kernel.kallsyms]  [k] link_path_walk

0.01%    test1  [kernel.kallsyms]  [k] prepend_path

0.01%    test1  [kernel.kallsyms]  [k] __inode_wait_for_writeback

0.01%    test1  [kernel.kallsyms]  [k] aa_free_task_context

0.01%    test1  [kernel.kallsyms]  [k] radix_tree_lookup_element

0.01%    test1  [kernel.kallsyms]  [k] _raw_spin_lock  

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值