在CentOS7 上编译运行 RT-test工具cyclictest 及patch kernel

来源:互联网 发布:windows安装bugfree 编辑:程序博客网 时间:2024/06/07 13:31

realtime 工具使用cyclictest ,我的linux环境是CentOS7 

分为两部分:安装RT-test cyclictest ; 给kernel 打patch


第一部分,下载安装Cyclictest , 我下载的是rt-test-1.0

# wget https:://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git

#cd rt-tests

[root@localhost RT_test]# cd rt-tests-1.0/
[root@localhost rt-tests-1.0]# ls

[root@localhost RT_test]# make all 

此时编译报错:compile failure because numa.h can't be found

需要执行以下步骤

[root@localhost rt-tests-1.0]# yum install numactl-devel

再次make就compile成功

[root@localhost rt-tests-1.0]# cyclictest --help
cyclictest V 1.00
Usage:
cyclictest <options>

-a [CPUSET] --affinity     Run thread #N on processor #N, if possible, or if CPUSET
                           given, pin threads to that set of processors in round-
                           robin order.  E.g. -a 2 pins all threads to CPU 2,
                           but -a 3-5,0 -t 5 will run the first and fifth
                           threads on CPU (0),thread #2 on CPU 3, thread #3
                           on CPU 4, and thread #5 on CPU 5.
-A USEC  --aligned=USEC    align thread wakeups to a specific offset
-b USEC  --breaktrace=USEC send break trace command when latency > USEC
-B       --preemptirqs     both preempt and irqsoff tracing (used with -b)
-c CLOCK --clock=CLOCK     select clock
                           0 = CLOCK_MONOTONIC (default)

...

可以查看到各项命令,安装成功

开始使用工具:

[root@localhost rt-tests-1.0]# cyclictest -c CLOCK

报错:

Unable to changescheduling policy!

Probably missingcapabilities, either run as root or increase RLIMIT_RTPRIO limits.

这时需要给kernel  打 patch 


部分二,下载相应kernel 版本及patch,kernel 和 patch 的版本应尽量相同,不然后续会出现其他问题

首先查看我的kernel版本

[root@localhost rt-tests-1.0]# uname -r
3.10.0-327.36.3.el7.x86_64

查看原先版本

[root@localhost rt-tests-1.0]# ls /boot/config-*

然后我选择下载3.12.66 版本,patch为patch-3.12.66-rt88.patch.gz

[root@localhost rt-tests-1.0]# wget  https://www.kernel.org/pub/linux/kernel/projects/rt/3.12/patch-3.12.66-rt88.patch.gz
[root@localhost rt-tests-1.0]#  wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.12.66.tar.gz

[root@localhost rt-tests-1.0]# tar -xvzf linux-3.12.66.tar.gz

[root@localhost rt-tests-1.0]# ls
bld            linux-3.12.66.tar.gz         pmqtest          signaltest
COPYING        MAINTAINERS                  ptsematest       sigwaittest
cyclictest     Makefile                     README.markdown  src
hackbench      patch-3.12.66-rt88.patch.gz  rt-migrate-test  svsematest
hwlatdetect    pip_stress                   RT_test
linux-3.12.66  pi_stress                    sendme
[root@localhost rt-tests-1.0]# cd linux-3.12.66/

开始patch

[root@localhost linux-3.12.66]# zcat ../patch-3.10.75-rt80.patch.gz | patch -p1

将原先存在的.config 文件写到kernel source

[root@localhost linux-3.12.66]# cp /boot/config-3.10.0-327.36.3.el7.x86_64 .config

compile 原始kernel,更改一些参数

[root@localhost linux-3.12.66]# make oldconfig

...
PreemptionModel
  1.NoForcedPreemption(Server)(PREEMPT_NONE)
>2.VoluntaryKernelPreemption(Desktop)(PREEMPT_VOLUNTARY)
  3.PreemptibleKernel(Low-LatencyDesktop)(PREEMPT__LL)(NEW)
  4.PreemptibleKernel(BasicRT)(PREEMPT_RTB)(NEW)
  5.FullyPreemptibleKernel(RT)(PREEMPT_RT_FULL)(NEW)
choice[1-5]:5
...
Debugpreemptiblekernel(DEBUG_PREEMPT)[Y/n/?](NEW)n
...
  Preemption-offLatencyTracer(PREEMPT_TRACER)[N/y/?](NEW)
  SchedulingLatencyTracer(SCHED_TRACER)[Y/n/?]y
    SchedulingLatencyHistogram(WAKEUP_LATENCY_HIST)[N/y/?](NEW)
  MissedTimerOffsetsHistogram(MISSED_TIMER_OFFSETS_HIST)[N/y/?](NEW)
...
EnableRCUpriorityboosting(RCU_BOOST)[Y/n/?](NEW)
  Real-timeprioritytoboostRCUreadersto(RCU_BOOST_PRIO)[1](NEW)
  MillisecondstodelayboostingafterRCUgrace-periodstart(RCU_BOOST_DELAY)[500](NEW)
...
#
#configurationwrittento.config

得到 .config 文件编译kernel

[root@localhost linux-3.12.66]# make

compile the modules which were marked in .config and install them in the required locations:

[root@localhost linux-3.12.66]# make modules_install install


Update the boot configuration for Grub

[root@localhost linux-3.12.66]# /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg


reboot 查看kernel version

[root@localhost linux-3.12.66]# uname -r
3.12.66-rt88

 然后开始使用 cyclictest  RT- test 工具


如果reboot 后还是启动原先版本,需要更改 /boot/grub2/grub.cfg 里面的参数,见上篇blog













0 0
原创粉丝点击