欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

编译一个抢占式内核 安装 cyclictest 测试内核实时性(ubuntu / centos)

程序员文章站 2022-07-03 11:05:57
...

Table of Contents

1、简介
2、编译内核
3、cyclictest安装
4、使用

简介

Cyclictest 是 rt-tests 下的一个测试工具,也是 rt-tests 下使用最广泛的测试工具,一般主要用来测试使用内核的延迟,从而判断内核的实时性。

编译内核

#  cd /usr/src/linux-4.17.3
#  patch -p1 < patch-4.17.3-rt65.patch
#  mkdir /opt/linux-4.17.3-rt
#  make localmodconfig    # 根据目前系统内核的配置生成配置文件 .config ; 
#  或者  cp /boot/config-4.9.0-42-generic ./.config  # 替代上一句,也可以直接copy /boot 目录下面的已配置好的config文件,建议直接copy
#  sudo apt-get install bison flex libncurses-dev libssl-dev
#  make menuconfig   

设置 Processor type and features —> Preemption Model —> Preemptible Kernel(Low-Latency Desktop)

设置 Processor type and features —> Enable seccomp to safely compute untrusted bytecode 下的 Timer frequency —> 1000HZ

#  cp .config /opt/linux-4.17.3-rt/.config  # 拷贝到指定的编译目录
#  make mrproper                            # 清空
#  make bzImage -j4 O=/opt/linux-4.17.3-rt
#  make modules -j4 O=/opt/linux-4.17.3-rt
#  cd /opt/linux-4.17.3-rt
#  sudo make modules_install
#  sudo make install
#  sudo update-grub

注意,如果没有 make modules_install 重启过程中可能会出错,提示驱动错误:如

slackware kernel: snd_hda_codec: version magic '4.17.3-smp SMP mod_unload 686 ' should be '4.17.3-smp SMP preempt mod_unload 686 ' 

cyclictest 安装

·基于包管理软件安装
Debian / Ubuntu 系统下可以直接使用apt-get install rt-tests 来安装 cyclictest。

·基于 git 源码安装

#  git clone git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git
#  cd rt-tests
#  git branch testing   
#  git checkout testing  
#  make install

可能会出现编译出错的情况:

   **致命错误:numa.h:没有那个文件或目录**

CentOS 安装:

# sudo yum install numactl-devel

Ubuntu 安装:

# apt-get install libnuma-dev 

使用

#sudo cyclictest -t1 -p 80 -n -i 10000 -l 10000

结果如下:
T: 0 (17769) P:80 I:10000 C: 10000 Min: 3 Act: 13 Avg: 14 Max: 36

步骤相关截图

1、需要安装的rt-linux源
编译一个抢占式内核 安装 cyclictest 测试内核实时性(ubuntu / centos)
2、编译结果
编译一个抢占式内核 安装 cyclictest 测试内核实时性(ubuntu / centos)
3、测试结果分析
编译一个抢占式内核 安装 cyclictest 测试内核实时性(ubuntu / centos)