KernelShark在ubuntu24.04.01的编译

KernelShark在ubuntu24.04.01的编译

来看我的文章,必有所得。
平凡中,总有我帮您踩过的坑。

写在前面

调研了TrackCompass后,感觉并不理想。

另一个工具是KernelShark。在接连搞坏ubuntu 20.04和22.04两个虚拟机后,我痛下决心,下载了新的ubuntu24.04.01,来编译kernelshark。

也不清楚我是不是这样做太过于执着。聪明人有时确会执着,但蠢人也会。现在还不清楚。。。是哪个。

具体过程

装ubuntu24.04.01

下载:

复制代码
https://mirrors.xjtu.edu.cn/ubuntu-releases/24.04.1/ubuntu-24.04.1-desktop-amd64.iso

处理完一些其它工作后,装了新的ubuntu24.04.01这个不累述。

这个版本,并没有什么特别的,是因为qt6。

20.04装不了qt6,22.04装好,也可能不行。当然,也可能是我操作有误。

一会再说这个可能的错误。

不过,不管怎么说,我还是建议您重装一个干净的ubuntu来做这件事,因为我已经因为这事搞坏了我的两个虚拟机。而且没有事先做snap~

安装depends

然后,参见这个页面:

https://github.com/yordan-karadzhov/kernel-shark

bash 复制代码
1. In order to install the packages on Ubuntu do the following:
    sudo apt-get install build-essential git cmake libjson-c-dev -y
    sudo apt-get install freeglut3-dev libxmu-dev libxi-dev -y
    sudo apt-get install flex bison -y
    sudo apt-get install fonts-freefont-ttf -y
    sudo apt-get install qt6-base-dev qt6-scxml-dev -y
    sudo apt-get install libtraceevent-dev libtracefs-dev libtracecmd-dev trace-cmd -y

1.1 If you want to be able to generate Doxygen documentation:
    sudo apt-get install graphviz doxygen-gui -y

要注意,上面这段文字,是这个页面唯一可信的东西。

而且我还装了一些其它的东西,也不清楚有没有用:

不建议操作。

bash 复制代码
sudo apt-get install build-essential git cmake libjson-c-dev -y
sudo apt-get install graphviz doxygen-gui -y
sudo dnf install gcc gcc-c++ git cmake json-c-devel -y
sudo apt install -y libzstd-dev
sudo apt install libdwarf-dev
sudo apt install build-essential cmake ninja-build git libqt6serialport6-dev 
sudo apt install libqt6serialport6-dev
sudo apt install -y build-essential cmake git libgtk-3-dev libtraceevent-dev libbabeltrace-dev   libglib2.0-dev libssl-dev pkg-config python3-mako libxml2-dev libncurses5-dev

其中一部分来自于这里:

https://forum.qt.io/topic/142233/cannot-build-qtcreator-from-source/7

下载代码

git clone git@github.com:yordan-karadzhov/kernel-shark.git

或者

https://github.com/yordan-karadzhov/kernel-shark.git

为什么,这段,要单写,是因为一定要用这套代码。

现在的head commit 是

复制代码
commit 59aeaca7afd6cc415bd7127bee528603535ddae5 (HEAD -> kernelshark, origin/kernelshark, origin/HEAD)
Author: Yordan Karadzhov <y.karadz@gmail.com>
Date:   Thu Sep 12 19:53:12 2024 +0300

    kernel-shark: In CI switch to v4 of the artefact actions

    This change is not relevant for KernelShark itself but only for
    the Github action CI. With the introduction of v4,  Github
    deprecates v1 and v2 of upload-artefact/download-artefact actions.

    Signed-off-by: Yordan Karadzhov <y.karadz@gmail.com>

那么来还有别的代码吗?

是的。如下图,而且,这套代码,就是主页说明里!
我不好说什么,如果你像我一样,认为official更有权威,那么,很可能,你要走弯路了。

那套代码,我想可能也是能编出来的,我是说也,就是我没有成功。因为需要依赖一些其它的需要手工编的代码:

复制代码
 project: Kernel Shark: (version: 2.3.1)

CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find TraceEvent (missing: TraceEvent_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  build/FindTraceEvent.cmake:57 (find_package_handle_standard_args)
  CMakeLists.txt:48 (find_package)
-- Configuring incomplete, errors occurred!

如何编译

bash 复制代码
cd build
cmake ..
make

cmake 输出

复制代码
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done

 project: Kernel Shark: (version: 2.3.1)

-- Found TraceEvent: /usr/lib/x86_64-linux-gnu/libtraceevent.so
-- Found TraceFS: /usr/lib/x86_64-linux-gnu/libtracefs.so
-- Found TraceCmd: /usr/lib/x86_64-linux-gnu/libtracecmd.so
-- Found JSONC: /usr/lib/x86_64-linux-gnu/libjson-c.so
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.8") found components: doxygen dot
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so
-- Found font: /usr/share/fonts/truetype/freefont/FreeSans.ttf
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Found WrapOpenGL: TRUE
-- Found XKB: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found suitable version "1.6.0", minimum required is "0.5.0")
-- Found WrapVulkanHeaders: /usr/include
-- Could NOT find Boost (missing: Boost_INCLUDE_DIR unit_test_framework)

 Build type: RelWithDebInfo

-- C flags      :  -Wall -Wextra -pthread -fPIC -fno-common
-- CXX flags    :  -Wall -Wextra -pthread -fPIC -fno-common
-- Linker flags :

 src ...
-- libkshark
-- libkshark-plot
-- libkshark-gui
-- kernelshark
-- kshark-record

 src/plugins ...
-- sched_events
-- event_field_plot
-- latency_plot
-- kvm_combo
-- missed_events

 examples ...
-- dataload
-- datafilter
-- multibufferload
-- datahisto
-- confogio
-- dataplot
-- widgetdemo
-- cmd_split

-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /data/shark/github/kernel-shark/build

make 输出

如何安装

bash 复制代码
sudo make install

初步启动

bash 复制代码
kernelshark

Add the User to the perf Group

KernelShark requires access to trace data, which typically requires root permissions. To avoid running KernelShark as root, you can add your user to the perf group:

bash 复制代码
sudo usermod -aG perf $USER

Then log out and log back in for the changes to take effect.

简单的使用

这里有篇文章,入门很好。

先说一下我后面的计划,尽管与本文无关。

其实我们本质的计划是将用户面的事件与 kernel的事件联合显示。

并且,我需要在界面上,画上时隙线。在5G通信中,每种子载波间隔对应的采样频率的不同,对应着不同的时隙值。

我们需要将这些间隔画出来。

所以,选了我比较熟的C++和QT.

所以,后面一方面,需要了解日志的格式,如何将google nanolog这类log转化为 ctf格式,或其它的格式,另一方面,由基于kernelshark或其它的工具,或它们的插件,来绘制我们某个专业的 并行计算的流程分析的 二维图。

这些是需要投入的部分。

在这之前,需要先学习一下kernelshark如何使用。

这里有篇文章。

https://blog.csdn.net/21cnbao/article/details/108414081

trace-cmd抓包

新建一个目录,cd 之后

复制代码
sudo trace-cmd record -e 'sched_wakeup*' -e sched_switch -e 'sched_migrate*'

过一会,^+c退出。

然后键入

kernelshark

或者

sudo kernelshark
这里稍解释一点:

trace.data是默认的文件名,kernleshark,也会默认加载这个文件。

或者这样写也可以:

kernelshark trace.dat

上面的脚本可以在MobaXterm ssh的shell中执行。刚装好的vmware的ubuntu24.04.01在vmware中,黑屏了。不能操作。所以,让它在后台运行了。都是通后ssh操作,

相关推荐
AlfredZhao5 小时前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
戴为沐1 天前
Linux内存扩容指南
linux
zylyehuo2 天前
Linux 彻底且安全地删除文件
linux
用户805533698032 天前
主线 U-Boot 上 RK3506:和闭源 rkbin 拔河的三个隐性契约
linux·嵌入式
用户034095297912 天前
linux fcitx 5 雾凇拼音 设置在中文输入法下仍然输入英文标点
linux
Web3探索者4 天前
可视化服务器管理和传统命令行区别是什么?新手教程:Linux 运维到底该用图形界面还是 SSH 命令行?
linux·ssh
zylyehuo4 天前
Linux系统中网线与USB网络共享冲突
linux
Sokach10155 天前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
AlfredZhao6 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3107 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql