18c2ecf20Sopenharmony_ci================ 28c2ecf20Sopenharmony_ciSMP IRQ affinity 38c2ecf20Sopenharmony_ci================ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciChangeLog: 68c2ecf20Sopenharmony_ci - Started by Ingo Molnar <mingo@redhat.com> 78c2ecf20Sopenharmony_ci - Update by Max Krasnyansky <maxk@qualcomm.com> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/proc/irq/IRQ#/smp_affinity and /proc/irq/IRQ#/smp_affinity_list specify 118c2ecf20Sopenharmony_ciwhich target CPUs are permitted for a given IRQ source. It's a bitmask 128c2ecf20Sopenharmony_ci(smp_affinity) or cpu list (smp_affinity_list) of allowed CPUs. It's not 138c2ecf20Sopenharmony_ciallowed to turn off all CPUs, and if an IRQ controller does not support 148c2ecf20Sopenharmony_ciIRQ affinity then the value will not change from the default of all cpus. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/proc/irq/default_smp_affinity specifies default affinity mask that applies 178c2ecf20Sopenharmony_cito all non-active IRQs. Once IRQ is allocated/activated its affinity bitmask 188c2ecf20Sopenharmony_ciwill be set to the default mask. It can then be changed as described above. 198c2ecf20Sopenharmony_ciDefault mask is 0xffffffff. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciHere is an example of restricting IRQ44 (eth1) to CPU0-3 then restricting 228c2ecf20Sopenharmony_ciit to CPU4-7 (this is an 8-CPU SMP box):: 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci [root@moon 44]# cd /proc/irq/44 258c2ecf20Sopenharmony_ci [root@moon 44]# cat smp_affinity 268c2ecf20Sopenharmony_ci ffffffff 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci [root@moon 44]# echo 0f > smp_affinity 298c2ecf20Sopenharmony_ci [root@moon 44]# cat smp_affinity 308c2ecf20Sopenharmony_ci 0000000f 318c2ecf20Sopenharmony_ci [root@moon 44]# ping -f h 328c2ecf20Sopenharmony_ci PING hell (195.4.7.3): 56 data bytes 338c2ecf20Sopenharmony_ci ... 348c2ecf20Sopenharmony_ci --- hell ping statistics --- 358c2ecf20Sopenharmony_ci 6029 packets transmitted, 6027 packets received, 0% packet loss 368c2ecf20Sopenharmony_ci round-trip min/avg/max = 0.1/0.1/0.4 ms 378c2ecf20Sopenharmony_ci [root@moon 44]# cat /proc/interrupts | grep 'CPU\|44:' 388c2ecf20Sopenharmony_ci CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 398c2ecf20Sopenharmony_ci 44: 1068 1785 1785 1783 0 0 0 0 IO-APIC-level eth1 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciAs can be seen from the line above IRQ44 was delivered only to the first four 428c2ecf20Sopenharmony_ciprocessors (0-3). 438c2ecf20Sopenharmony_ciNow lets restrict that IRQ to CPU(4-7). 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci:: 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci [root@moon 44]# echo f0 > smp_affinity 488c2ecf20Sopenharmony_ci [root@moon 44]# cat smp_affinity 498c2ecf20Sopenharmony_ci 000000f0 508c2ecf20Sopenharmony_ci [root@moon 44]# ping -f h 518c2ecf20Sopenharmony_ci PING hell (195.4.7.3): 56 data bytes 528c2ecf20Sopenharmony_ci .. 538c2ecf20Sopenharmony_ci --- hell ping statistics --- 548c2ecf20Sopenharmony_ci 2779 packets transmitted, 2777 packets received, 0% packet loss 558c2ecf20Sopenharmony_ci round-trip min/avg/max = 0.1/0.5/585.4 ms 568c2ecf20Sopenharmony_ci [root@moon 44]# cat /proc/interrupts | 'CPU\|44:' 578c2ecf20Sopenharmony_ci CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 588c2ecf20Sopenharmony_ci 44: 1068 1785 1785 1783 1784 1069 1070 1069 IO-APIC-level eth1 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ciThis time around IRQ44 was delivered only to the last four processors. 618c2ecf20Sopenharmony_cii.e counters for the CPU0-3 did not change. 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciHere is an example of limiting that same irq (44) to cpus 1024 to 1031:: 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci [root@moon 44]# echo 1024-1031 > smp_affinity_list 668c2ecf20Sopenharmony_ci [root@moon 44]# cat smp_affinity_list 678c2ecf20Sopenharmony_ci 1024-1031 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciNote that to do this with a bitmask would require 32 bitmasks of zero 708c2ecf20Sopenharmony_cito follow the pertinent one. 71