not*_*ter 93

在 Ubuntu 上,我必须安装三个软件包:

apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r`
Run Code Online (Sandbox Code Playgroud)

  • @Martin-R linux-tools-generic 总是指向最新内核版本的工具。当运行旧内核时(例如,一个有几个月正常运行时间的服务器),如果你想在不重启到新内核的情况下获得性能,你必须明确安装与该内核配对的工具(因此是 `uname -r` shell 扩展)。 (6认同)
  • 当我尝试它时,只需使用`sudo apt-get install linux-tools-common linux-tools-generic`(跳过这部分,这取决于内核版本)就足够了。 (5认同)
  • ***sudo apt install linux-tools-generic*** 在 ubuntu 18.04 上 (3认同)
  • E:无法找到软件包 linux-tools-5.5.* 如何在内核 5.5 上运行 perf? (2认同)

Jam*_*dge 88

该perf实用程序可以在linux-tools 包中找到。

  • 您可能还想安装 [linux-tools-generic](http://packages.ubuntu.com/trusty/linux-tools-generic),因为它包含与 perf 交互的内核模块。 (14认同)

Mon*_*lal 34

确保为正确的内核版本安装此工具。如果你只是输入:

sudo apt-get install linux-tools

它将在您的机器中为最新的 Linux 版本安装它,如果您正在启动以前的版本(例如出于稳定性原因),它会出错。在我的情况下,它为 .45 而不是 .43 安装,我必须使用以下命令来安装它:

sudo apt-get install linux-tools-3.2.0.43

您可以通过键入以下内容找到您的内核版本: uname -r

为了确保它正常工作,您可以尝试以下操作: perf record /bin/ls

以防万一您要安装Zoom 工具,您需要安装 Perf 才能使用其所有实用程序。


小智 22

无论内核版本如何,都要获取最新版本的 perf(perf 版本与内核版本无关):

git clone --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux/tools/perf
make
cp perf /usr/bin
Run Code Online (Sandbox Code Playgroud)

perf --version 检查当前版本

  • 构建 deps 供参考`apt-get install build-essential git flex bison` (3认同)
  • 如果您使用较新的鸡舍,这是正确的答案。所有涉及使用 dpkg 和 apt 下载的答案都取决于 dpkg 存储库是否有权根据您的内核版本访问 perf。运行内核为 5.11 的最新 Ubuntu 映像 21.04,perf 在使用 dpkg 下载后会“安装”,但是当尝试运行“perf -h”时,系统会提示“警告:找不到内核 5.11.0-perf” 41`(或者您拥有的 perf 不属于哪个较新的内核)。必须从 linux-tools 手动编译该工具。 (2认同)

Dre*_*kes 7

在 14.04 中,linux-tools不存在不合格的包:

$ 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-virtual 3.13.0.36.43
  linux-tools-lowlatency 3.13.0.36.43
  linux-tools-generic-lts-trusty 3.13.0.36.43
  linux-tools-generic-lts-saucy 3.13.0.36.43
  linux-tools-generic 3.13.0.36.43
You should explicitly select one to install.

E: Package 'linux-tools' has no installation candidate
Run Code Online (Sandbox Code Playgroud)

相反,您可以安装列出的软件包之一,具体取决于您安装的内核。大多数用户会想要linux-tools-generic.


小智 5

在 ubuntu 上,“perf”是一个 shell 脚本,它调用内核特定的 perf 二进制文件。

但这实际上并不是必需的,perf 是兼容的。只需从 /usr/bin 中删除包装器并将任何性能二进制文件从 ./lib/linux-tools* 复制到其中。