how to install perf on customized kernel

**
关于有哪些方法perf线上运行的程序
**
https://stackoverflow.com/questions/375913/how-can-i-profile-c-code-running-on-linux
https://zhuanlan.zhihu.com/p/71437161

如果使用的是 perf:

  1. 下载kernel代码
make -C <kernel source root directory>/tools/perf
  1. 找一个最接近的版本安装:
sudo apt-get install linux-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package linux-tools is a virtual package provided by:
  linux-tools-oem-osp1 5.0.0.1028.32
  ...
  linux-tools-virtual 4.15.0.70.72
  linux-tools-oracle-lts-18.04 4.15.0.1029.34
  linux-tools-oracle-edge 5.0.0.1007.6
  linux-tools-oracle 4.15.0.1029.34
  linux-tools-lowlatency-hwe-18.04 5.0.0.36.94
  linux-tools-generic 4.15.0.70.72
	...
You should explicitly select one to install.

然后安装一个通用的:

sudo apt-get install  linux-tools-generic
cd /usr/lib/linux-tools/linux-tools-4.15.0-70/     # 默认安装在 /usr/lib/linux-toos/xxx 下面
sudo ./perf ...

sudo ./perf top  # 类似 top 的动态显示方式

# Sampling CPU stacks at 99 Hertz (-F 99), for the entire system (-a, for all CPUs), with stack traces (-g, for call graphs), for 30 seconds:
sudo ./perf record -F 99 -a -g -- sleep 30

# Sample CPU stack traces for the PID, using dwarf (dbg info, or use `-g` == `--call-graph fp`, i.e frame pointer) to unwind stacks, at 99 Hertz, for 20 seconds:
sudo ./perf record -F 99  --call-graph dwarf  -p <PID>  sleep 20  # 这个比较清晰

# Sample on-CPU user instructions precisely (using PEBS), for 10 seconds:
perf record -e cycles:up -a -- sleep 10 

# Show perf.data as a text report, with data coalesced and percentages:
sudo ./perf report --stdio -i ./perf.data    # -g folded   or  --show-total-period,

sudo ./perf record -e syscalls:sys_enter_*  -p <PID>  # 统计系统所有调用
  1. http://www.brendangregg.com/perf.html
  2. https://perf.wiki.kernel.org/index.php/Tutorial
  3. https://baptiste-wicht.com/posts/2011/07/profile-applications-linux-perf-tools.html

A good example to perf c++ user function:
http://notes.secretsauce.net/notes/2019/12/16_c-probes-with-perf.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值