在 Linux 内核上禁用定时器中断

Mos*_*ben 5 centos real-time linux-kernel

我想禁用我的机器上某些核心 (1-2) 上的计时器中断,该机器是运行 centos 7 并带有 rt 补丁的 x86,两个核心都是带有 , 的隔离核心(您可以看到nohz_fullcmdline),但计时器中断继续中断 core1 和 core2 上运行的实时进程。

1. uname -r
3.10.0-693.11.1.rt56.632.el7.x86_64

2. cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-693.11.1.rt56.632.el7.x86_64 \
   root=/dev/mapper/centos-root ro crashkernel=auto \
   rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet \ 
   default_hugepagesz=2M hugepagesz=2M hugepages=1024 \
   intel_iommu=on isolcpus=1-2 irqaffinity=0 intel_idle.max_cstate=0 \
   processor.max_cstate=0 idle=mwait tsc=perfect rcu_nocbs=1-2 rcu_nocb_poll \
   nohz_full=1-2 nmi_watchdog=0

 3. cat /proc/interrupts
           CPU0       CPU1       CPU2
  0:         29          0          0   IO-APIC-edge      timer
.....
......

NMI:          0          0          0   Non-maskable interrupts
LOC:  835205157  308723100  308384525   Local timer interrupts
SPU:          0          0          0   Spurious interrupts
PMI:          0          0          0   Performance monitoring interrupts
IWI:          0          0          0   IRQ work interrupts
RTR:          0          0          0   APIC ICR read retries
RES:  347330843  309191325  308417790   Rescheduling interrupts
CAL:          0        935        935   Function call interrupts
TLB:        320         22         58   TLB shootdowns
TRM:          0          0          0   Thermal event interrupts
THR:          0          0          0   Threshold APIC interrupts
DFR:          0          0          0   Deferred Error APIC interrupts
MCE:          0          0          0   Machine check exceptions
MCP:          2          2          2   Machine check polls
Run Code Online (Sandbox Code Playgroud)

CPU/时钟源:

4. lscpu | grep CPU.s
CPU(s):                3
On-line CPU(s) list:   0-2
NUMA node0 CPU(s):     0-2

5. cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助。摩西

max*_*zig 3

即使nohz_full=您在隔离的 CPU 上得到了一些滴答声:

一些进程处理操作仍然需要偶尔的调度时钟滴答。这些操作包括计算CPU负载、维护sched平均值、计算CFS实体vruntime、计算avenrun以及进行负载均衡。目前,它们是通过每秒左右的调度时钟滴答来容纳的。正在进行的工作将消除对这些不频繁的调度时钟滴答的需要。(Documentation/timers/NO_HZ.txt,参见3.10 LWN,2013中的(几乎)完全无滴答操作)

因此,您必须检查本地计时器的速率,例如:

$ perf stat -a -A -e irq_vectors:local_timer_entry sleep 120
Run Code Online (Sandbox Code Playgroud)

(当您的隔离线程/进程正在运行时)

此外,nohz_full=仅当每个独立核心上只有一个可运行任务时才有效。您可以使用例如ps -L -e -o pid,tid,user,state,psr,cmd和进行检查cat /proc/sched_debug

也许您需要将一些(内核)任务移至您的内务核心,例如:

# tuna -U -t '*' -c 0-4 -m
Run Code Online (Sandbox Code Playgroud)

通过查看,您可以更深入地了解哪些计时器仍然处于活动状态/proc/timer_list

调查可能中断原因的另一种方法是使用功能跟踪器 ( ftrace )。另请参阅减少由于每 CPU 的 kthreads 造成的操作系统抖动以获取一些示例。

nmi_watchdog=0在你的内核参数中看到了,但你没有禁用软看门狗。也许这是 ftrace 中显示的另一个计时器滴答源。

您可以使用 禁用所有看门狗nowatchdog

顺便说一句,你的一些内核参数似乎关闭了:

  • tsc=perfect- 你的意思是tsc=reliable?内核文档中没有记录“完美”值
  • idle=mwait- 你的意思是idle=poll?同样,我在内核文档中找不到“mwait”值
  • intel_iommu=on- 这样做的目的是什么?