当前位置: 首页>>技术教程>>正文


linux – 如何在Ubuntu上使用IRQBALANCE_BANNED_CPUS禁止硬件中断?

, , ,

问题描述

我想禁止某些CPU的中断。我听说了IRQBALANCE_BANNED_CPUS选项。我看到irqbalance在我的计算机的后台运行。我在哪里进行编辑以及如何配置该选项?例如,我要从中断中排除cpus 2、3、4、5。参数descriptor为:

Provides a mask of cpus which irqbalance should ignore and never assign interrupts to

口罩是什么意思?以及在哪里使用该选项配置irqbalance?

EDIT1:如何知道我的配置正在生效,换句话说,我的CPU没有收到中断?我正在检查/proc /interrupts,但那里的数字正在增加。

EDIT2:现在我以IRQBALANCE_BANNED_CPUS = 3e引导了我的机器,因此不禁止从中断中禁止仅CPU 0。所以我应该期望看到cpo0接收到很多中断,而另一个cpus没有接收到中断,对吗?这是我的/proc /interrupts。粗体字表示所有cpus。 22、24、35和LOC行正在更改。

            CPU0       CPU1       CPU2       CPU3       CPU4       CPU5       
   0:         26          0          0          0          0          0   IO-APIC-edge      timer
   1:          2          0          0          0          0          0   IO-APIC-edge      i8042
   6:          3          0          0          0          0          0   IO-APIC-edge      floppy
   8:          1          0          0          0          0          0   IO-APIC-edge      rtc0
   9:          0          0          0          0          0          0   IO-APIC-fasteoi   acpi
  12:          4          0          0          0          0          0   IO-APIC-edge      i8042
  14:      13556          0          0          0          0          0   IO-APIC-edge      ata_piix
  15:          0          0          0          0          0          0   IO-APIC-edge      ata_piix
  18:          0          0          0          0          0          0   IO-APIC-fasteoi   ata_piix
  19:          2          0          0          0          0          0   IO-APIC-fasteoi   ohci1394
  20:          3          0          0          0          0          0   IO-APIC-fasteoi   ehci_hcd:usb2, uhci_hcd:usb3, uhci_hcd:usb6
  21:        197        635         39          0          0          0   IO-APIC-fasteoi   uhci_hcd:usb4, uhci_hcd:usb7, HDA Intel
  22:        344       3506          0        702          0          0   IO-APIC-fasteoi   ehci_hcd:usb1, uhci_hcd:usb5, uhci_hcd:usb8
  24:        162         48          0          0          0          0   IO-APIC-fasteoi   nvidia
  35:        174          0         47          0          0          0   IO-APIC-fasteoi   nvidia
  53:       3517          0          0          0          0          0   PCI-MSI-edge      eth0
 NMI:          0          0          0          0          0          0   Non-maskable interrupts
 LOC:      11007       8840       6480       5652       4272       3046   Local timer interrupts
 SPU:          0          0          0          0          0          0   Spurious interrupts
 PMI:          0          0          0          0          0          0   Performance monitoring interrupts
 PND:          0          0          0          0          0          0   Performance pending work
 RES:        292        169        217        125        122        126   Rescheduling interrupts
 CAL:         86        280        254        292        293        291   Function call interrupts
 TLB:       1147       1031       1348        616        177        322   TLB shootdowns
 TRM:          0          0          0          0          0          0   Thermal event interrupts
 THR:          0          0          0          0          0          0   Threshold APIC interrupts
 MCE:          0          0          0          0          0          0   Machine check exceptions
 MCP:          2          2          2          2          2          2   Machine check polls
 ERR:          5
 MIS:          0

EDIT3:看起来IRQBALANCE_BANNED_CPUS选项在Ubuntu上完全被忽略。我尝试用1、3e重新启动计算机,并全部中断。就在我通过设置ENABLED = 0禁用irqbalance时,我只在cpu0上获得了干净的/proc /interrupts,而没有其他cpu。

最佳办法

您可以在/etc /default /irqbalance中设置IRQBALANCE_BANNED_CPUS。我是在/etc/init.d/irqbalance中找到的。但是该设置的有效值是多少?从红帽的手册页:

This is a hex mask without the leading ‘0x’, on systems with large numbers of processors each group of eight hex digits is sepearated ba a comma ‘,’. i.e. export IRQBALANCE_BANNED_CPUS=fc0 would prevent irqbalance from assigning irqs to the 7th-12th cpus (cpu6-cpu11) or export IRQBALANCE_BANNED_CPUS=ff000000,00000001 would prevent irqbalance from assigning irqs to the 1st (cpu0) and 57th-64th cpus (cpu56-cpu63).

在维基百科上解释了concept of a mask。阅读后再回来。让我们分解一下Red Hat的第一个例子。以十六进制形式写为fc0的数字以二进制形式写为111111000000。从右向左扫描(即从least significant bitmost significant bit),有六个零。这意味着可以分配1st-5th cpus(cpu0-cpu5)中断。然后,有六个。这意味着不会分配第7-12个cpus(cpu6-cpu11)中断。

听起来您想允许cpu0和cpu1接收中断,但阻止为cpu2,cpu3,cpu4和cpu5分配中断。这意味着您需要两个零和四个一,或111100。这是十六进制的3C。因此,您将使用内容创建/etc /default /irqbalance

ENABLED="1"
ONESHOT="0"
IRQBALANCE_BANNED_CPUS="3f"

要查看发生了什么,请尝试

$ sudo service irqbalance stop
Stopping SMP IRQ Balancer: irqbalance.
$ source /etc/default/irqbalance 
$ sudo irqbalance --debug

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/7850.html,未经允许,请勿转载。