← Documents Documentation/core-api/irq/irq-affinity.rst GitHub 원문 ↗

Linux 6.18.37 · Core API

SMP IRQ affinity

procfs의 smp_affinity 비트마스크와 smp_affinity_list CPU 목록을 사용해 IRQ를 처리할 CPU 집합을 지정하는 방법을 설명합니다.

Source pathDocumentation/core-api/irq/irq-affinity.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

irq-affinity.rst:1-70

IRQ affinity는 특정 하드웨어 인터럽트를 처리할 CPU를 제한하는 기능입니다. `/proc/irq/IRQ#/smp_affinity`에는 비트마스크를, `/proc/irq/IRQ#/smp_affinity_list`에는 CPU 번호 또는 범위를 기록합니다.

비활성 IRQ의 초기값은 `/proc/irq/default_smp_affinity`가 결정합니다. 모든 CPU를 affinity에서 제외할 수 없고, 컨트롤러가 기능을 지원하지 않으면 설정값이 기본값에서 바뀌지 않습니다.

CPU 수가 많은 시스템에서는 긴 비트마스크보다 `smp_affinity_list`가 읽고 쓰기 쉽습니다. 예제는 IRQ44의 `/proc/interrupts` 카운터를 비교하여 인터럽트가 지정한 CPU 집합으로 이동했음을 확인합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ================
2 SMP IRQ affinity
3 ================
4
5 ChangeLog:
6 - Started by Ingo Molnar <mingo@redhat.com>
7 - Update by Max Krasnyansky <maxk@qualcomm.com>
8
9
10 /proc/irq/IRQ#/smp_affinity and /proc/irq/IRQ#/smp_affinity_list specify
11 which target CPUs are permitted for a given IRQ source. It's a bitmask
12 (smp_affinity) or CPU list (smp_affinity_list) of allowed CPUs. It's not
13 allowed to turn off all CPUs, and if an IRQ controller does not support
14 IRQ affinity then the value will not change from the default of all CPUs.
15
16 /proc/irq/default_smp_affinity specifies default affinity mask that applies
17 to all non-active IRQs. Once IRQ is allocated/activated its affinity bitmask
18 will be set to the default mask. It can then be changed as described above.
19 Default mask is 0xffffffff.
20
21 Here is an example of restricting IRQ44 (eth1) to CPU0-3 then restricting
22 it to CPU4-7 (this is an 8-CPU SMP box)::
23
24 [root@moon 44]# cd /proc/irq/44
25 [root@moon 44]# cat smp_affinity
26 ffffffff
27
28 [root@moon 44]# echo 0f > smp_affinity
29 [root@moon 44]# cat smp_affinity
30 0000000f
31 [root@moon 44]# ping -f h
32 PING hell (195.4.7.3): 56 data bytes
33 ...
34 --- hell ping statistics ---
35 6029 packets transmitted, 6027 packets received, 0% packet loss
36 round-trip min/avg/max = 0.1/0.1/0.4 ms
37 [root@moon 44]# cat /proc/interrupts | grep 'CPU\|44:'
38 CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
39 44: 1068 1785 1785 1783 0 0 0 0 IO-APIC-level eth1
40
41 As can be seen from the line above IRQ44 was delivered only to the first four
42 processors (0-3).
43 Now lets restrict that IRQ to CPU(4-7).
44
45 ::
46
47 [root@moon 44]# echo f0 > smp_affinity
48 [root@moon 44]# cat smp_affinity
49 000000f0
50 [root@moon 44]# ping -f h
51 PING hell (195.4.7.3): 56 data bytes
52 ..
53 --- hell ping statistics ---
54 2779 packets transmitted, 2777 packets received, 0% packet loss
55 round-trip min/avg/max = 0.1/0.5/585.4 ms
56 [root@moon 44]# cat /proc/interrupts | 'CPU\|44:'
57 CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
58 44: 1068 1785 1785 1783 1784 1069 1070 1069 IO-APIC-level eth1
59
60 This time around IRQ44 was delivered only to the last four processors.
61 i.e counters for the CPU0-3 did not change.
62
63 Here is an example of limiting that same IRQ (44) to CPUs 1024 to 1031::
64
65 [root@moon 44]# echo 1024-1031 > smp_affinity_list
66 [root@moon 44]# cat smp_affinity_list
67 1024-1031
68
69 Note that to do this with a bitmask would require 32 bitmasks of zero
70 to follow the pertinent one.
71

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

문서 정보

1-9

SMP IRQ affinity

변경 기록:

Ingo Molnar <mingo@redhat.com>가 문서를 시작했습니다.

Max Krasnyansky <maxk@qualcomm.com>가 문서를 갱신했습니다.

IRQ별 CPU 선호도 인터페이스

10-15

`/proc/irq/IRQ#/smp_affinity`와 `/proc/irq/IRQ#/smp_affinity_list`는 특정 IRQ 소스에 허용할 대상 CPU를 지정합니다. 허용 CPU를 각각 비트마스크인 `smp_affinity` 또는 CPU 목록인 `smp_affinity_list`로 표현합니다. 모든 CPU를 끄는 것은 허용되지 않으며, IRQ 컨트롤러가 IRQ affinity를 지원하지 않으면 값은 모든 CPU를 허용하는 기본값에서 바뀌지 않습니다.

기본 선호도 마스크

16-20

`/proc/irq/default_smp_affinity`는 활성화되지 않은 모든 IRQ에 적용할 기본 affinity 마스크를 지정합니다. IRQ가 할당되거나 활성화되면 해당 affinity 비트마스크가 기본 마스크로 설정되고, 이후에는 앞서 설명한 방식으로 바꿀 수 있습니다. 기본 마스크는 `0xffffffff`입니다.

IRQ44를 CPU0-3으로 제한

21-40

다음 예는 8 CPU SMP 시스템에서 IRQ44(`eth1`)를 먼저 CPU0-3으로 제한한 뒤 CPU4-7로 옮깁니다.

[root@moon 44]# cd /proc/irq/44
[root@moon 44]# cat smp_affinity
ffffffff

[root@moon 44]# echo 0f > smp_affinity
[root@moon 44]# cat smp_affinity
0000000f
[root@moon 44]# ping -f h
PING hell (195.4.7.3): 56 data bytes
...
--- hell ping statistics ---
6029 packets transmitted, 6027 packets received, 0% packet loss
round-trip min/avg/max = 0.1/0.1/0.4 ms
[root@moon 44]# cat /proc/interrupts | grep 'CPU\|44:'
        CPU0       CPU1       CPU2       CPU3      CPU4       CPU5        CPU6       CPU7
44:       1068       1785       1785       1783         0          0           0         0    IO-APIC-level  eth1

IRQ44를 CPU4-7로 이동

41-59

위 출력에서 IRQ44는 앞쪽 네 프로세서인 CPU0-3에만 전달되었습니다. 이제 같은 IRQ를 CPU4-7로 제한합니다.

::

        [root@moon 44]# echo f0 > smp_affinity
        [root@moon 44]# cat smp_affinity
        000000f0
        [root@moon 44]# ping -f h
        PING hell (195.4.7.3): 56 data bytes
        ..
        --- hell ping statistics ---
        2779 packets transmitted, 2777 packets received, 0% packet loss
        round-trip min/avg/max = 0.1/0.5/585.4 ms
        [root@moon 44]# cat /proc/interrupts |  'CPU\|44:'
                CPU0       CPU1       CPU2       CPU3      CPU4       CPU5        CPU6       CPU7
        44:       1068       1785       1785       1783      1784       1069        1070       1069   IO-APIC-level  eth1

두 번째 설정의 결과

60-62

이번에는 IRQ44가 뒤쪽 네 프로세서에만 전달되었습니다. 즉 CPU0-3의 카운터는 변하지 않았습니다.

큰 CPU 번호를 목록으로 지정

63-70

다음 예는 같은 IRQ44를 CPU 1024부터 1031까지로 제한합니다.

[root@moon 44]# echo 1024-1031 > smp_affinity_list
[root@moon 44]# cat smp_affinity_list
1024-1031

이를 비트마스크로 표현하려면 의미 있는 비트마스크 뒤에 값이 0인 32개의 비트마스크가 필요합니다.