Recommended
PDF
PPTX
PDF
Decompressed vmlinux: linux kernel initialization from page table configurati...
PDF
Network Programming: Data Plane Development Kit (DPDK)
PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
PDF
LinuxCon 2015 Linux Kernel Networking Walkthrough
PPTX
PPTX
Slab Allocator in Linux Kernel
PDF
Memory Mapping Implementation (mmap) in Linux Kernel
PDF
Kernel Recipes 2017: Using Linux perf at Netflix
PDF
20111015 勉強会 (PCIe / SR-IOV)
PDF
PDF
Page cache in Linux kernel
PDF
[232] 성능어디까지쥐어짜봤니 송태웅
PDF
malloc & vmalloc in Linux
PDF
PDF
Physical Memory Models.pdf
PDF
PDF
DPDK: Multi Architecture High Performance Packet Processing
PPTX
The TCP/IP Stack in the Linux Kernel
PPTX
PPSX
FD.io Vector Packet Processing (VPP)
PDF
PDF
Embedded linux network device driver development
PPTX
Linux Initialization Process (2)
ODP
PPTX
Linux MMAP & Ioremap introduction
PDF
DPDK in Containers Hands-on Lab
PDF
OSC2011 Tokyo/Fall 濃いバナ(virtio)
PDF
More Related Content
PDF
PPTX
PDF
Decompressed vmlinux: linux kernel initialization from page table configurati...
PDF
Network Programming: Data Plane Development Kit (DPDK)
PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
PDF
LinuxCon 2015 Linux Kernel Networking Walkthrough
PPTX
PPTX
Slab Allocator in Linux Kernel
What's hot
PDF
Memory Mapping Implementation (mmap) in Linux Kernel
PDF
Kernel Recipes 2017: Using Linux perf at Netflix
PDF
20111015 勉強会 (PCIe / SR-IOV)
PDF
PDF
Page cache in Linux kernel
PDF
[232] 성능어디까지쥐어짜봤니 송태웅
PDF
malloc & vmalloc in Linux
PDF
PDF
Physical Memory Models.pdf
PDF
PDF
DPDK: Multi Architecture High Performance Packet Processing
PPTX
The TCP/IP Stack in the Linux Kernel
PPTX
PPSX
FD.io Vector Packet Processing (VPP)
PDF
PDF
Embedded linux network device driver development
PPTX
Linux Initialization Process (2)
ODP
PPTX
Linux MMAP & Ioremap introduction
PDF
DPDK in Containers Hands-on Lab
Similar to /proc/irq/<irq>/smp_affinity
PDF
OSC2011 Tokyo/Fall 濃いバナ(virtio)
PDF
PPTX
PDF
PDF
PDF
A35 SQL Server と NUMA by 熊澤幸生
PDF
第11回ACRiウェビナー_インテル/竹村様ご講演資料
PDF
PDF
PDF
エバンジェリストが語るパワーシステム特論 ~ 第3回:IBMオフコンはいかにして生き残れたのか?~第二章~
PDF
PPTX
ftp.jaist.ac.jpの低レイヤーの話 on 第九回 カーネル/VM探検隊
PDF
20120519_qpstudy 2012.05 いやらしい@hasegawのI/O入門
PDF
PDF
PDF
PDF
PDF
PDF
PDF
More from Takuya ASADA
PDF
PDF
PDF
PPTX
Seastar:高スループットなサーバアプリケーションの為の新しいフレームワーク
PDF
PDF
PDF
PDF
Presentation on your terminal
PDF
PDF
PDF
Implements BIOS emulation support for BHyVe: A BSD Hypervisor
PDF
BHyVeでOSvを起動したい
〜BIOSがなくてもこの先生きのこるには〜
PDF
PDF
高スループットなサーバアプリケーションの為の新しいフレームワーク
「Seastar」
PPTX
Seastar in 歌舞伎座.tech#8「C++初心者会」
PDF
PDF
PDF
OSvのご紹介 in OSC2014 Tokyo/Fall
PDF
OSvのご紹介 in
Java 8 HotSpot meeting
PDF
Recently uploaded
PDF
ST2024_PM1_2_Case_study_of_local_newspaper_company.pdf
PDF
Team Topology Adaptive Organizational Design for Rapid Delivery of Valuable S...
PDF
第21回 Gen AI 勉強会「NotebookLMで60ページ超の スライドを作成してみた」
PDF
2025→2026宙畑ゆく年くる年レポート_100社を超える企業アンケート総まとめ!!_企業まとめ_1229_3版
PDF
PMBOK 7th Edition_Project Management Context Diagram
PDF
100年後の知財業界-生成AIスライドアドリブプレゼン イーパテントYouTube配信
PDF
Starlink Direct-to-Cell (D2C) 技術の概要と将来の展望
PDF
Reiwa 7 IT Strategist Afternoon I Question-1 3C Analysis
PDF
FY2025 IT Strategist Afternoon I Question-1 Balanced Scorecard
PDF
Reiwa 7 IT Strategist Afternoon I Question-1 Ansoff's Growth Vector
PDF
PMBOK 7th Edition_Project Management Process_WF Type Development
/proc/irq/<irq>/smp_affinity 1. 2. 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日土曜日
5. 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日土曜日