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

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

要注意,上面这段文字,是这个页面唯一可信的东西。
而且我还装了一些其它的东西,也不清楚有没有用:
不建议操作。

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!

如何编译

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 输出

在这里插入图片描述

如何安装

sudo make install

初步启动

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:

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

### 安装 Ubuntu 24.04.01 LTS 服务器版 #### 准备工作 为了准备安装环境,需先从官方渠道获取操作系统的ISO文件。可以从Ubuntu中文官网下载所需的操作系统镜像[^2]。 #### 创建启动介质 使用合适的写盘工具(例如UltraISO或其他可靠的USB创建工具),将下载的Ubuntu 24.04.01 LTS ISO映像写入到U盘中。此过程的具体细节因所选工具而异,通常按照软件提示即可完成配置和写入操作[^1]。 #### 启动并进入安装程序 重启目标计算机,在BIOS/UEFI设置界面通过按下特定键(对于NF5468M6型号来说通常是`F11`)选择之前制作好的U盘作为引导设备来启动机器。 #### 开始安装流程 一旦成功从U盘启动,屏幕上会显示语言选项菜单;选择适合的语言后继续前进至欢迎页面。这里可以选择尝试不改变磁盘上的任何东西或者直接开始安装Ubuntu Server版本: - **网络连接检测**:自动探测可用的互联网接入方式。 - **更新和其他软件的选择**:决定是否要安装第三方驱动、多媒体编码解码器等附加组件。 - **身份验证信息设定**:定义新用户的全名、用户名以及登录密码。 - **分区布局规划**:可以采用全自动模式让系统处理硬盘空间分配,也可手动指定各逻辑卷的位置大小。 - **确认更改并部署**:最后一步是审查所有即将执行的动作列表,如果一切无误则点击“Continue”。 等待一段时间直到整个过程结束,期间可能会经历多次进度条加载直至最终提示移除安装媒介并重新启动计算机以体验全新的Ubuntu 24.04.01 LTS服务器环境。 ```bash sudo reboot now ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值