Este conteúdo não está disponível no idioma selecionado.
2.4. Interrupt and Process Binding
Important
00000000000000000000000000000001
as a bitmask, 1
as a decimal, and 0x00000001
as a hexadecimal. The CPU mask for both CPU 0 and 1 is 00000000000000000000000000000011
as a bitmask, 3
as a decimal, and 0x00000003
as a hexadecimal.
Procedure 2.3. Disabling the irqbalance
Daemon
irqbalance
daemon is not required.
- Check the status of the
irqbalance
daemon.systemctl status irqbalance
~]# systemctl status irqbalance irqbalance.service - irqbalance daemon Loaded: loaded (/usr/lib/systemd/system/irqbalance.service; enabled) Active: active (running) …
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - If the
irqbalance
daemon is running, stop it.systemctl stop irqbalance
~]# systemctl stop irqbalance
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Ensure that
irqbalance
does not restart on boot.systemctl disable irqbalance
~]# systemctl disable irqbalance
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 2.4. Excluding CPUs from IRQ Balancing
/etc/sysconfig/irqbalance
configuration file contains a setting that allows CPUs to be excluded from consideration by the IRQ balacing service. This parameter is named IRQBALANCE_BANNED_CPUS
and is a 64-bit hexadecimal bit mask, where each bit of the mask represents a CPU core.
- Open
/etc/sysconfig/irqbalance
in your preferred text editor and find the section of the file titledIRQBALANCE_BANNED_CPUS
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Exclude CPUs 8 to 15 by uncommenting the variable
IRQBALANCE_BANNED_CPUS
and setting its value this way:IRQBALANCE_BANNED_CPUS=0000ff00
IRQBALANCE_BANNED_CPUS=0000ff00
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - This will cause the
irqbalance
process to ignore the CPUs that have bits set in the bitmask; in this case, bits 8 through 15. - If you are running a system with up to 64 CPU cores, separate each group of eight hexadecimal digits with a comma:
IRQBALANCE_BANNED_CPUS=00000001,0000ff00
IRQBALANCE_BANNED_CPUS=00000001,0000ff00
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The above mask excludes CPUs 8 to 15 as well as CPU 33 from IRQ balancing.
Note
irqbalance
tool automatically avoids IRQs on CPU cores isolated via the isolcpus=
kernel parameter if IRQBALANCE_BANNED_CPUS
is not set in the /etc/sysconfig/irqbalance
file.
Procedure 2.5. Manually Assigning CPU Affinity to Individual IRQs
- Check which IRQ is in use by each device by viewing the
/proc/interrupts
file:cat /proc/interrupts
~]# cat /proc/interrupts
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This file contains a list of IRQs. Each line shows the IRQ number, the number of interrupts that happened in each CPU, followed by the IRQ type and a description:CPU0 CPU1 0: 26575949 11 IO-APIC-edge timer 1: 14 7 IO-APIC-edge i8042 ...[output truncated]...
CPU0 CPU1 0: 26575949 11 IO-APIC-edge timer 1: 14 7 IO-APIC-edge i8042 ...[output truncated]...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To instruct an IRQ to run on only one processor, use the
echo
command to write the CPU mask, as a hexadecimal number, to thesmp_affinity
entry of the specific IRQ. In this example, we are instructing the interrupt with IRQ number 142 to run on CPU 0 only:echo 1 > /proc/irq/142/smp_affinity
~]# echo 1 > /proc/irq/142/smp_affinity
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - This change will only take effect once an interrupt has occurred. To test the settings, generate some disk activity, then check the
/proc/interrupts
file for changes. Assuming that you have caused an interrupt to occur, you will see that the number of interrupts on the chosen CPU have risen, while the numbers on the other CPUs have not changed.
Procedure 2.6. Binding Processes to CPUs Using the taskset
Utility
taskset
utility uses the process ID (PID) of a task to view or set the affinity, or can be used to launch a command with a chosen CPU affinity. In order to set the affinity, taskset
requires the CPU mask expressed as a decimal or hexadecimal number. The mask argument is a bitmask that specifies which CPU cores are legal for the command or PID being modified.
- To set the affinity of a process that is not currently running, use
taskset
and specify the CPU mask and the process. In this example,my_embedded_process
is being instructed to use only CPU 3 (using the decimal version of the CPU mask).taskset 8 /usr/local/bin/my_embedded_process
~]# taskset 8 /usr/local/bin/my_embedded_process
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - It is also possible to specify more than one CPU in the bitmask. In this example,
my_embedded_process
is being instructed to execute on processors 4, 5, 6, and 7 (using the hexadecimal version of the CPU mask).taskset 0xF0 /usr/local/bin/my_embedded_process
~]# taskset 0xF0 /usr/local/bin/my_embedded_process
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Additionally, you can set the CPU affinity for processes that are already running by using the
-p
(--pid
) option with the CPU mask and the PID of the process you wish to change. In this example, the process with a PID of 7013 is being instructed to run only on CPU 0.taskset -p 1 7013
~]# taskset -p 1 7013
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Lastly, using the
-c
parameter, you can specify a CPU list instead of a CPU mask. For example, in order to use CPU 0, 4 and CPUs 7 to 11, the command line would contain-c 0,4,7-11
. This invocation is more convenient in most cases.
Important
For more information, or for further reading, the following man pages are related to the information given in this section.
- chrt(1)
- taskset(1)
- nice(1)
- renice(1)
- sched_setscheduler(2) for a description of the Linux scheduling scheme.