系统:Ubuntu18.04系统
内核版本:5.4.0-150-generic(通过uname -r查看)
一、在ubuntu中使用apt包下载Perf
输入perf命令,提示:
Command 'perf' not found, but can be installed with:
apt install linux-tools-common
Please ask your administrator.
按照提示安装linux-tools-common:
sudo apt-get install linux-tools-common
查看perf -v,提示:
WARNING: perf not found for kernel 5.4.0-150
You may need to install the following packages for this specific kernel:
linux-tools-5.4.0-150-generic
linux-cloud-tools-5.4.0-150-generic
You may also want to install one of the following packages to keep up to date:
linux-tools-generic
linux-cloud-tools-generic
由于linux有不同的发行版本,内核工具也不同,提示的意思是可以下载特定的内核版本下的tools,根据命令行的提示,使用uname -r 查看内核版本,并下载
sudo apt-get install linux-tools-5.4.0-150-generic
再次执行perf -v可以得到当前版本
perf version 5.4.233
参考博文:Perf的安装与简单使用
二、使用源码安装Perf,并移植到arm-linux环境下
perf是一种系统级性能分析工具,它涉及内核调用,所以安装需要知道内核版本。查看arm-linux平台的内核的版本,到官网上去下载特定的内核源码
在开发板终端输入
uname -r
5.4.31
去官网上下载内核源码,可以手动下载,也可以使用wget,以下操作在ubuntu平台
-
Linux内核源码下载网站:Index of /sites/ftp.kernel.org/pub/linux/kernel/ (sjtu.edu.cn) 或者 Index of /kernel/linux/kernel/
-
wget下载,例如:
wget http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/kernel/v5.x/linux-5.4.31.tar.gz
下载完毕之后,解压内核源代码
tar -zxvf linux-5.4.31.tar.gz
进入如下目录
cd linux-5.4

本文详细介绍了如何在Ubuntu18.04系统中通过apt安装和源码编译Perf,并将其移植到arm-linux环境下。在安装过程中,涉及到内核版本匹配、perf_event_paranoid权限设置等问题,最终成功使用perf进行性能分析。
1072

被折叠的 条评论
为什么被折叠?



