Content-Length: 270415 | pFad | https://www.slideshare.net/syuu1228/procirqltirqsmpaffinity

/proc/irq/<irq>/smp_affinity | PPT
SlideShare a Scribd company logo
/proc/irq/<IRQ>/
                 smp_affinity
                    @syuu1228




12年9月22日土曜日
cat /proc/interrupts




12年9月22日土曜日
$ cat /proc/interrupts
                         CPU0       CPU1
                0:      36843      61973   IO-APIC-edge      timer
                1:        518        591   IO-APIC-edge      i8042
                8:          1          0   IO-APIC-edge      rtc0
                9:        387        321   IO-APIC-fasteoi   acpi
               12:      11236         79   IO-APIC-edge      i8042
               16:          0          0   IO-APIC-fasteoi   uhci_hcd:usb6
               17:         12         11   IO-APIC-fasteoi   uhci_hcd:usb7
               18:          0          0   IO-APIC-fasteoi   uhci_hcd:usb8
               19:       6531        235   IO-APIC-fasteoi   ehci_hcd:usb2
               20:          0          0   IO-APIC-fasteoi   uhci_hcd:usb3
               21:         85         69   IO-APIC-fasteoi   uhci_hcd:usb4
               22:          0          0   IO-APIC-fasteoi   uhci_hcd:usb5
               23:         20         15   IO-APIC-fasteoi   ehci_hcd:usb1
               40:          0          0   PCI-MSI-edge      PCIe PME, pciehp
               41:          0          0   PCI-MSI-edge      PCIe PME, pciehp
               42:          0          0   PCI-MSI-edge      PCIe PME, pciehp
               43:      33199      31756   PCI-MSI-edge      ahci
               44:         19       1583   PCI-MSI-edge      eth0
               45:         10         11   PCI-MSI-edge      mei
               46:      41104      59303   PCI-MSI-edge      i915
               47:     170268        708   PCI-MSI-edge      iwlwifi
               48:         78         77   PCI-MSI-edge      snd_hda_intel
              NMI:       1406       1430   Non-maskable interrupts
              LOC:     342351     327074   Local timer interrupts
              SPU:          0          0   Spurious interrupts
              PMI:       1406       1430   Performance monitoring interrupts
              IWI:          0          0   IRQ work interrupts
              RES:      83855     108903   Rescheduling interrupts
              CAL:        223        195   Function call interrupts
              TLB:       1486       1665   TLB shootdowns
              TRM:          0          6   Thermal event interrupts
              THR:          0          0   Threshold APIC interrupts
              MCE:          0          0   Machine check exceptions
              MCP:         11         11   Machine check polls
              ERR:
              MIS:
                            0
                            0  丁度良く複数コアへ分散されてる?
12年9月22日土曜日
smp_affinity
                # cat /proc/irq/43/smp_affinity
                3
                # echo 1 > /proc/irq/43/smp_affinity



              割り込み先CPU群をビットで指定する
              と、指定されたCPU群にラウンドロビ
              ンで割り込まれる
                         これを書き換えればいいのか!

12年9月22日土曜日
ー完ー




12年9月22日土曜日
それでは#kernelvmらしくない
                # cat /proc/irq/43/smp_affinity
                3
                # echo 1 > /proc/irq/43/smp_affinity




              bitの立ってるコアへ割り込み分散

              bitが一つならいつもそこへ割り込み

                         これ、どうなってるんだろう?

12年9月22日土曜日
イマドキなx86の割り込み
                    CPU                    CPU            CPU

                                         Local APIC     Local APIC
                    Timer
                                                                Legacy PCI
               Local APIC                        IPI

              MSI           8259A Intr


                 MSI                                       Legacy
                Capable                   I/O APIC          PCI
                Devices                                    Devices
                                         8259A PIC
                                    ICH(South bridge)


12年9月22日土曜日
Local APIC
                            CPU                    CPU            CPU

                                                 Local APIC     Local APIC
                            Timer
                                                                        Legacy PCI
                       Local APIC                        IPI

                      MSI           8259A Intr


                         MSI                                       Legacy
                        Capable                   I/O APIC          PCI
                        Devices                                    Devices
                                                 8259A PIC
                                            ICH(South bridge)


              CPU毎の割り込みコントローラ 割り込みを許可・マスクした
              り、EOIしたり

              システム全体で一意なAPIC IDを持つ

              他のLAPICへ割り込める(IPI: Inter-processor Interrupt)

12年9月22日土曜日
I/O APIC
                           CPU                    CPU            CPU

                                                Local APIC     Local APIC
                           Timer
                                                                       Legacy PCI
                      Local APIC                        IPI

                     MSI           8259A Intr


                        MSI                                       Legacy
                       Capable                   I/O APIC          PCI
                       Devices                                    Devices
                                                8259A PIC
                                           ICH(South bridge)



              限られたIRQを複数のPCIデバイスで共有

              各IRQをどのLAPICへ転送するかを定義するRedirection Table(I/
              O APIC上のレジスタ群)を持つ

              PCIデバイスはI/O APICを通じてLAPICへ割り込みメッセージを送信


12年9月22日土曜日
MSI capable PCI devices
                           CPU                    CPU            CPU

                                                Local APIC     Local APIC
                           Timer
                                                                       Legacy PCI
                      Local APIC                        IPI

                     MSI           8259A Intr


                          MSI                                     Legacy
                         Capable                 I/O APIC          PCI
                         Devices                                  Devices
                                                8259A PIC
                                           ICH(South bridge)


              各デバイスが任意の数のIRQを持てる

              各IRQの割り込み先LAPICはPCIデバイスのPCI Configuration
              Spaceに持つ

              PCIデバイスは直接LAPICへ割り込みメッセージを送信

12年9月22日土曜日
割り込み先の指定方法
              Physical Destination Mode
                 Destination FieldにAPIC IDを指定
                 「常に同じCPUへ割り込み」を実現

              Logical Destination Mode(Flat Model)
                 Destination Fieldのbitで宛先LAPIC群の範囲を表現

                 Delivery Mode
                     Fixed
                     指定範囲の全てのLAPICへ割り込み

                     Lowest Priority
                     指定範囲の中で、最もTPR(Task Priority Register)の
                     値が低いCPUへ割り込み



12年9月22日土曜日
Lowest Priority Mode

              指定範囲の中で、最もTPR(Task
              Priority Register)の値が低いLAPIC
              へ割り込み

              最小値のTPRを持つLAPICが複数ある
              場合はラウンドロビンで1つ選択


12年9月22日土曜日
echo 1 > /proc/irq/<IRQ>/
              smp_affinityした時に何が起きるのか
              MSIなPCIeデバイスで確かめてみる

              Intel Pro/1000(e1000e)
              PCI Configuration Spaceはrootな
              ら/sys/bus/pciから読める
              →ユーザランドから読める
              →もしかして:lspci

12年9月22日土曜日
_人人 人人_

              >   lspci   <

               ̄Y^Y^Y^Y ̄




12年9月22日土曜日
# lspci -vvvv -s 00:19.0
  00:19.0 Ethernet controller: Intel Corporation 82567LM Gigabit Network Connection (rev 03)
       Subsystem: Lenovo Device 20ee
       Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+
       Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
       Latency: 0
       Interrupt: pin A routed to IRQ 44
       Region 0: Memory at f2600000 (32-bit, non-prefetchable) [size=128K]
       Region 1: Memory at f2625000 (32-bit, non-prefetchable) [size=4K]
       Region 2: I/O ports at 1840 [size=32]
       Capabilities: [c8] Power Management version 2
            Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
            Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
       Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
            Address: 00000000fee0300c Data: 41b9
       Capabilities: [e0] PCI Advanced Features
            AFCap: TP+ FLR+
            AFCtrl: FLR-
            AFStatus: TP-
       Kernel driver in use: e1000e
       Kernel modules: e1000e

               赤く塗った所がMSIのフィールドだけれど、こ
               れだと良く分からないのでlspciをforkして
               MSIフィールドを表示するツールを作成
               https://gist.github.com/1568777
12年9月22日土曜日
# gcc -lpci msireg.c
  # ./a.out 00:19.0
  Message Signalled Interrupts: 64bit+ Queue=0/0 Enable+
  address_hi=0
  address_lo=fee0300c dest_mode=logical redirection=lowpri dest_id=3
  data=41b9 trigger=edge level=assert delivery_mode=lowpri vector=185


              Logical modeでLowpri、destid=3、
              vector=185になってる
  # echo 1 > /proc/irq/44/smp_affinity
  # ./a.out 00:19.0
  Message Signalled Interrupts: 64bit+ Queue=0/0 Enable+
  address_hi=0
  address_lo=fee0100c dest_mode=logical redirection=lowpri dest_id=1
  data=41b9 trigger=edge level=assert delivery_mode=lowpri vector=185


              dest_idが1に書き換わった!



12年9月22日土曜日
余談

              調子に乗ってユーザランドからフィー
              ルド書き換えたら何かおかしくなりま
              した

              カーネルさんと喧嘩してるか、フィー
              ルドの書き方間違えたか…


12年9月22日土曜日
参考資料
              Intel® 64 and IA-32 Architectures Software Developer
              Manuals
              Intel® I/O Controller Hub 10 (ICH10) Family Datasheet
              linux/Documentation/IRQ-affinity.txt
              Understanding the Linux Kernel, 3rd Edition
              PCI Local Bus Specification Revision 3.0
              最近のPCアーキテクチャにおける割り込みルーティングの仕組み

              /proc/irq/<IRQ>/smp_affinityの書き換えでPCIコンフィグレ
              ーション空間はどのように書き換わるか

              Interrupts on xv6



12年9月22日土曜日

More Related Content

/proc/irq/&lt;irq>/smp_affinity

  • 1. /proc/irq/<IRQ>/ smp_affinity @syuu1228 12年9月22日土曜日
  • 3. $ cat /proc/interrupts CPU0 CPU1 0: 36843 61973 IO-APIC-edge timer 1: 518 591 IO-APIC-edge i8042 8: 1 0 IO-APIC-edge rtc0 9: 387 321 IO-APIC-fasteoi acpi 12: 11236 79 IO-APIC-edge i8042 16: 0 0 IO-APIC-fasteoi uhci_hcd:usb6 17: 12 11 IO-APIC-fasteoi uhci_hcd:usb7 18: 0 0 IO-APIC-fasteoi uhci_hcd:usb8 19: 6531 235 IO-APIC-fasteoi ehci_hcd:usb2 20: 0 0 IO-APIC-fasteoi uhci_hcd:usb3 21: 85 69 IO-APIC-fasteoi uhci_hcd:usb4 22: 0 0 IO-APIC-fasteoi uhci_hcd:usb5 23: 20 15 IO-APIC-fasteoi ehci_hcd:usb1 40: 0 0 PCI-MSI-edge PCIe PME, pciehp 41: 0 0 PCI-MSI-edge PCIe PME, pciehp 42: 0 0 PCI-MSI-edge PCIe PME, pciehp 43: 33199 31756 PCI-MSI-edge ahci 44: 19 1583 PCI-MSI-edge eth0 45: 10 11 PCI-MSI-edge mei 46: 41104 59303 PCI-MSI-edge i915 47: 170268 708 PCI-MSI-edge iwlwifi 48: 78 77 PCI-MSI-edge snd_hda_intel NMI: 1406 1430 Non-maskable interrupts LOC: 342351 327074 Local timer interrupts SPU: 0 0 Spurious interrupts PMI: 1406 1430 Performance monitoring interrupts IWI: 0 0 IRQ work interrupts RES: 83855 108903 Rescheduling interrupts CAL: 223 195 Function call interrupts TLB: 1486 1665 TLB shootdowns TRM: 0 6 Thermal event interrupts THR: 0 0 Threshold APIC interrupts MCE: 0 0 Machine check exceptions MCP: 11 11 Machine check polls ERR: MIS: 0 0 丁度良く複数コアへ分散されてる? 12年9月22日土曜日
  • 4. smp_affinity # cat /proc/irq/43/smp_affinity 3 # echo 1 > /proc/irq/43/smp_affinity 割り込み先CPU群をビットで指定する と、指定されたCPU群にラウンドロビ ンで割り込まれる これを書き換えればいいのか! 12年9月22日土曜日
  • 6. それでは#kernelvmらしくない # cat /proc/irq/43/smp_affinity 3 # echo 1 > /proc/irq/43/smp_affinity bitの立ってるコアへ割り込み分散 bitが一つならいつもそこへ割り込み これ、どうなってるんだろう? 12年9月22日土曜日
  • 7. イマドキなx86の割り込み CPU CPU CPU Local APIC Local APIC Timer Legacy PCI Local APIC IPI MSI 8259A Intr MSI Legacy Capable I/O APIC PCI Devices Devices 8259A PIC ICH(South bridge) 12年9月22日土曜日
  • 8. Local APIC CPU CPU CPU Local APIC Local APIC Timer Legacy PCI Local APIC IPI MSI 8259A Intr MSI Legacy Capable I/O APIC PCI Devices Devices 8259A PIC ICH(South bridge) CPU毎の割り込みコントローラ 割り込みを許可・マスクした り、EOIしたり システム全体で一意なAPIC IDを持つ 他のLAPICへ割り込める(IPI: Inter-processor Interrupt) 12年9月22日土曜日
  • 9. I/O APIC CPU CPU CPU Local APIC Local APIC Timer Legacy PCI Local APIC IPI MSI 8259A Intr MSI Legacy Capable I/O APIC PCI Devices Devices 8259A PIC ICH(South bridge) 限られたIRQを複数のPCIデバイスで共有 各IRQをどのLAPICへ転送するかを定義するRedirection Table(I/ O APIC上のレジスタ群)を持つ PCIデバイスはI/O APICを通じてLAPICへ割り込みメッセージを送信 12年9月22日土曜日
  • 10. MSI capable PCI devices CPU CPU CPU Local APIC Local APIC Timer Legacy PCI Local APIC IPI MSI 8259A Intr MSI Legacy Capable I/O APIC PCI Devices Devices 8259A PIC ICH(South bridge) 各デバイスが任意の数のIRQを持てる 各IRQの割り込み先LAPICはPCIデバイスのPCI Configuration Spaceに持つ PCIデバイスは直接LAPICへ割り込みメッセージを送信 12年9月22日土曜日
  • 11. 割り込み先の指定方法 Physical Destination Mode Destination FieldにAPIC IDを指定 「常に同じCPUへ割り込み」を実現 Logical Destination Mode(Flat Model) Destination Fieldのbitで宛先LAPIC群の範囲を表現 Delivery Mode Fixed 指定範囲の全てのLAPICへ割り込み Lowest Priority 指定範囲の中で、最もTPR(Task Priority Register)の 値が低いCPUへ割り込み 12年9月22日土曜日
  • 12. Lowest Priority Mode 指定範囲の中で、最もTPR(Task Priority Register)の値が低いLAPIC へ割り込み 最小値のTPRを持つLAPICが複数ある 場合はラウンドロビンで1つ選択 12年9月22日土曜日
  • 13. echo 1 > /proc/irq/<IRQ>/ smp_affinityした時に何が起きるのか MSIなPCIeデバイスで確かめてみる Intel Pro/1000(e1000e) PCI Configuration Spaceはrootな ら/sys/bus/pciから読める →ユーザランドから読める →もしかして:lspci 12年9月22日土曜日
  • 14. _人人 人人_ > lspci <  ̄Y^Y^Y^Y ̄ 12年9月22日土曜日
  • 15. # lspci -vvvv -s 00:19.0 00:19.0 Ethernet controller: Intel Corporation 82567LM Gigabit Network Connection (rev 03) Subsystem: Lenovo Device 20ee Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+ Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- Latency: 0 Interrupt: pin A routed to IRQ 44 Region 0: Memory at f2600000 (32-bit, non-prefetchable) [size=128K] Region 1: Memory at f2625000 (32-bit, non-prefetchable) [size=4K] Region 2: I/O ports at 1840 [size=32] Capabilities: [c8] Power Management version 2 Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+) Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME- Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+ Address: 00000000fee0300c Data: 41b9 Capabilities: [e0] PCI Advanced Features AFCap: TP+ FLR+ AFCtrl: FLR- AFStatus: TP- Kernel driver in use: e1000e Kernel modules: e1000e 赤く塗った所がMSIのフィールドだけれど、こ れだと良く分からないのでlspciをforkして MSIフィールドを表示するツールを作成 https://gist.github.com/1568777 12年9月22日土曜日
  • 16. # gcc -lpci msireg.c # ./a.out 00:19.0 Message Signalled Interrupts: 64bit+ Queue=0/0 Enable+ address_hi=0 address_lo=fee0300c dest_mode=logical redirection=lowpri dest_id=3 data=41b9 trigger=edge level=assert delivery_mode=lowpri vector=185 Logical modeでLowpri、destid=3、 vector=185になってる # echo 1 > /proc/irq/44/smp_affinity # ./a.out 00:19.0 Message Signalled Interrupts: 64bit+ Queue=0/0 Enable+ address_hi=0 address_lo=fee0100c dest_mode=logical redirection=lowpri dest_id=1 data=41b9 trigger=edge level=assert delivery_mode=lowpri vector=185 dest_idが1に書き換わった! 12年9月22日土曜日
  • 17. 余談 調子に乗ってユーザランドからフィー ルド書き換えたら何かおかしくなりま した カーネルさんと喧嘩してるか、フィー ルドの書き方間違えたか… 12年9月22日土曜日
  • 18. 参考資料 Intel® 64 and IA-32 Architectures Software Developer Manuals Intel® I/O Controller Hub 10 (ICH10) Family Datasheet linux/Documentation/IRQ-affinity.txt Understanding the Linux Kernel, 3rd Edition PCI Local Bus Specification Revision 3.0 最近のPCアーキテクチャにおける割り込みルーティングの仕組み /proc/irq/<IRQ>/smp_affinityの書き換えでPCIコンフィグレ ーション空間はどのように書き換わるか Interrupts on xv6 12年9月22日土曜日

Editor's Notes









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.slideshare.net/syuu1228/procirqltirqsmpaffinity

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy