首页 > 解决方案 > Disable timer interrupt on Linux kernel

问题描述

I want to disable the timer interrupt on some of the cores (1-2) on my machine which is a x86 running centos 7 with rt patch, both cores are isolated cores with nohz_full, (you can see the cmdline) but timer interrupt continues to interrupt the real time process which are running on core1 and 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

CPUs/Clocksource:

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

Thanks a lot for any help. Moses

标签: linux-kernelcentosreal-time

解决方案


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

一些进程处理操作仍然需要偶尔的调度时钟滴答。这些操作包括计算CPU负载、维护sched average、计算CFS实体vruntime、计算avenrun和进行负载均衡。它们目前由每秒左右的调度时钟滴答来适应。即使对这些不频繁的调度时钟滴答声,正在进行的工作也将不再需要。(Documentation/timers/NO_HZ.txt,参见3.10 LWN,2013中的(几乎)完全无滴答操作)

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

$ perf stat -a -A -e irq_vectors:local_timer_entry sleep 120

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

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

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

# tuna -U -t '*' -c 0-4 -m

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

另一种调查可能中断原因的方法是使用功能跟踪器 ( ftrace )。有关一些示例,另请参阅减少由于每个 cpu kthreads 导致的操作系统抖动。

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

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

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

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

推荐阅读