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操作,

相关推荐
Cx330❀10 小时前
【MySQL基础】一文吃透“表的约束”:从 Null/Default 到主外键的终极安全法则
linux·服务器·数据库·c++·mysql·安全
程序员JerrySUN10 小时前
Jetson 刷机深度解析:flash.sh vs l4t_initrd_flash.sh(含安全与磁盘加密对比)
linux·网络·arm开发·安全·系统安全
六点_dn11 小时前
Linux学习笔记-printf命令
linux·运维·算法
蜡台11 小时前
Linux Python 安装使用
linux·运维·服务器
欧神附体12311 小时前
在虚拟机中添加网卡,修改网卡名并关闭SElinux
linux·服务器·网络
brave_zhao13 小时前
openEuler下安装tar包解压工具
linux·服务器·数据库
小宏运维有点菜13 小时前
JumpServer
linux·运维
是个西兰花14 小时前
Linux:死锁与生产者消费者模型解析
linux·运维·服务器·c++·死锁·生产者消费者模型
RisunJan14 小时前
Linux命令-rsync(远程/本地文件同步 —— 增量传输的备份与镜像神器)
linux·运维·服务器
爆浇牛肉面15 小时前
Linux进阶命令:测开必学的curl和jq
linux