![]()
測試環境為 CentOS7 x86_64 (虛擬機, CPUx2)
/proc/interrupts
IRQ (Interrupt request) 是當週邊裝置需要資料的傳輸時會產生一個中斷請求給 CPU ,並請 CPU 停止工作並幫忙處理處理週邊資料的傳輸,每個 I/O 會有各自的 IRQ (中斷) ,對應的 IRQ 可以參考檔案 /proc/interrupts
[root@localhost ~]# cat /proc/interrupts
CPU0 CPU1
0: 82 0 IO-APIC-edge timer
1: 10 0 IO-APIC-edge i8042
8: 1 0 IO-APIC-edge rtc0
9: 0 0 IO-APIC-fasteoi acpi
12: 16 0 IO-APIC-edge i8042
14: 0 0 IO-APIC-edge ata_piix
15: 108 7072 IO-APIC-edge ata_piix
16: 335 0 IO-APIC-fasteoi vmwgfx, snd_ens1371
17: 10432 7735 IO-APIC-fasteoi ehci_hcd:usb1, ioc0
18: 157 0 IO-APIC-fasteoi uhci_hcd:usb2
19: 11461 585 IO-APIC-fasteoi ens33
24: 0 0 PCI-MSI-edge PCIe PME, pciehp
25: 0 0 PCI-MSI-edge PCIe PME, pciehp
26: 0 0 PCI-MSI-edge PCIe PME, pciehp
27: 0 0 PCI-MSI-edge PCIe PME, pciehp
28: 0 0 PCI-MSI-edge PCIe PME, pciehp
29: 0 0 PCI-MSI-edge PCIe PME, pciehp
30: 0 0 PCI-MSI-edge PCIe PME, pciehp
31: 0 0 PCI-MSI-edge PCIe PME, pciehp
32: 0 0 PCI-MSI-edge PCIe PME, pciehp
33: 0 0 PCI-MSI-edge PCIe PME, pciehp
34: 0 0 PCI-MSI-edge PCIe PME, pciehp
35: 0 0 PCI-MSI-edge PCIe PME, pciehp
36: 0 0 PCI-MSI-edge PCIe PME, pciehp
37: 0 0 PCI-MSI-edge PCIe PME, pciehp
38: 0 0 PCI-MSI-edge PCIe PME, pciehp
39: 0 0 PCI-MSI-edge PCIe PME, pciehp
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: 0 0 PCI-MSI-edge PCIe PME, pciehp
44: 0 0 PCI-MSI-edge PCIe PME, pciehp
45: 0 0 PCI-MSI-edge PCIe PME, pciehp
46: 0 0 PCI-MSI-edge PCIe PME, pciehp
47: 0 0 PCI-MSI-edge PCIe PME, pciehp
48: 0 0 PCI-MSI-edge PCIe PME, pciehp
49: 0 0 PCI-MSI-edge PCIe PME, pciehp
50: 0 0 PCI-MSI-edge PCIe PME, pciehp
51: 0 0 PCI-MSI-edge PCIe PME, pciehp
52: 0 0 PCI-MSI-edge PCIe PME, pciehp
53: 0 0 PCI-MSI-edge PCIe PME, pciehp
54: 0 0 PCI-MSI-edge PCIe PME, pciehp
55: 0 0 PCI-MSI-edge PCIe PME, pciehp
56: 14 1126 PCI-MSI-edge vmw_vmci
57: 0 0 PCI-MSI-edge vmw_vmci
NMI: 0 0 Non-maskable interrupts
LOC: 269073 381094 Local timer interrupts
SPU: 0 0 Spurious interrupts
PMI: 0 0 Performance monitoring interrupts
IWI: 2921 3304 IRQ work interrupts
RTR: 0 0 APIC ICR read retries
RES: 16738 17488 Rescheduling interrupts
CAL: 5197 6003 Function call interrupts
TLB: 2722 607 TLB shootdowns
TRM: 0 0 Thermal event interrupts
THR: 0 0 Threshold APIC interrupts
DFR: 0 0 Deferred Error APIC interrupts
MCE: 0 0 Machine check exceptions
MCP: 25 25 Machine check polls
ERR: 0
MIS: 0
PIN: 0 0 Posted-interrupt notification event
PIW: 0 0 Posted-interrupt wakeup event
- 第一個數字
所代表的是 IRQ - 後面兩個數字
代表的是該 IRQ 使用 CPU0 與 CPU1 的累計次數 - 中斷的種類
中斷的種類如下:- Level-signalled interrupts
使用專用的中斷線來產生中斷. - Message-signalled interrupts
如 PCI Express 採用的就是 MSI 的中斷產生的方式,採用 in-band (控制訊號與資料同線路) 的方式,有分兩種 MSI 與 MSI-X .
MSI (PCI 2.2 開始採用) 支援 1, 2, 4, 8, 16 或 32 中斷上限,MSI-X (PCI 3.0 開始採用) 支援 2048 中斷上限. - Non-maskable interrupts
當中斷為 masked 時 CPU 是可以忽略它的,但是當收到 NMI (Non-maskable interrupts) 中斷時代表是相當嚴重的硬體錯誤不能被忽略. - System management interrupts
SMI 與 NMI 類似,它們直接在 CPU 使用特殊的線路,並且通常不能被屏蔽. - Advanced programmable interrupt controller
APIC (Advanced Programmable Interrupt Controller) 為進階的 IRQ 管理器,APIC 有兩種 local APIC (LAPIC) 以及 I/O APIC- local APIC (LAPIC)
每一個 CPU 都有自己的 LAPIC,主要用於管理 SMP(Symmetric multiprocessing) 系統中某些特定處理器的所有外部中斷,此外,它們都能夠接受和產生 LAPICs 之間的 inter-processor interrupts (IPIs).
處理器間中斷 (Inter-Processor Interrupt,IPI) 在多處理器系統中當一個處理器向另一個處理器發出的中斷行為即為 IPI - I/O APIC
另外一種是 I/O 的 APIC 用來處理關於 I/O 設備引起的中斷,這 I/O APIC 存在主板上,包含 redirection table ,用來路由周邊設備中斷到一個或多個 Local APIC.
- local APIC (LAPIC)
在 interrupts 檔案常見的中斷有.
- IO-APIC-fasteoi
The -fasteoi interrupts are level interrupts that are triggered until the interrupt event is acknowledged in the programmable interrupt controller (PIC).
當裝置發送中斷信號時,直到 CPU 處理中斷之前都會保持特定的狀態. - IO-APIC-edge
The -edge interrupt are edge triggered. This is a rising level on the interrupt line.
發出中斷請求後立即結束中斷. - PCI-MSI-edge
MSI(Message Signaled Interrupts) 是 PCI Express 中斷產生的方式.
- Level-signalled interrupts
- 最後就是裝置 IO 名稱
其他沒有 IRQ 數字的屬於特殊中斷,如 NMI (Non-Maskable Interrupts) 與 SMI (System Management Interrupts).
Linux 系統有一個 irqbalance 服務會定期強制中斷應用程式,讓每個應用程式能更公平的方式分享 CPU 的資源,請參考 https://benjr.tw/93539
我們也可以強制指定 IRQ 要使用哪一個 CPU 核心來處理,透過設定 /proc/irq/IRQ_NUMBER/smp_affinity 來指定 IRQ 中斷 與 CPU 的關聯 (一個或是多個 CPU 核心),請參考 CPU Affinity taskset (cpuset) – https://benjr.tw/99353
/proc/iomem
IO 裝置對應到的記憶體位址可以參考這個檔案.
[root@localhost ~]# cat /proc/iomem
00000000-00000fff : reserved
00001000-0009ebff : System RAM
0009ec00-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
000c0000-000c7fff : Video ROM
000ca000-000cafff : Adapter ROM
000cc000-000cffff : PCI Bus 0000:00
000d0000-000d3fff : PCI Bus 0000:00
000d4000-000d7fff : PCI Bus 0000:00
000d8000-000dbfff : PCI Bus 0000:00
000dc000-000fffff : reserved
000f0000-000fffff : System ROM
00100000-3fedffff : System RAM
01000000-016c72fe : Kernel code
016c72ff-01b3b4bf : Kernel data
01d04000-01ffffff : Kernel bss
3fee0000-3fefefff : ACPI Tables
3feff000-3fefffff : ACPI Non-volatile Storage
3ff00000-3fffffff : System RAM
c0000000-febfffff : PCI Bus 0000:00
c0000000-c0007fff : 0000:00:0f.0
c0008000-c000bfff : 0000:00:10.0
e5b00000-e5bfffff : PCI Bus 0000:22
e5c00000-e5cfffff : PCI Bus 0000:1a
e5d00000-e5dfffff : PCI Bus 0000:12
e5e00000-e5efffff : PCI Bus 0000:0a
e5f00000-e5ffffff : PCI Bus 0000:21
e6000000-e60fffff : PCI Bus 0000:19
e6100000-e61fffff : PCI Bus 0000:11
e6200000-e62fffff : PCI Bus 0000:09
e6300000-e63fffff : PCI Bus 0000:20
e6400000-e64fffff : PCI Bus 0000:18
e6500000-e65fffff : PCI Bus 0000:10
e6600000-e66fffff : PCI Bus 0000:08
e6700000-e67fffff : PCI Bus 0000:1f
e6800000-e68fffff : PCI Bus 0000:17
e6900000-e69fffff : PCI Bus 0000:0f
e6a00000-e6afffff : PCI Bus 0000:07
e6b00000-e6bfffff : PCI Bus 0000:1e
e6c00000-e6cfffff : PCI Bus 0000:16
e6d00000-e6dfffff : PCI Bus 0000:0e
e6e00000-e6efffff : PCI Bus 0000:06
e6f00000-e6ffffff : PCI Bus 0000:1d
e7000000-e70fffff : PCI Bus 0000:15
e7100000-e71fffff : PCI Bus 0000:0d
e7200000-e72fffff : PCI Bus 0000:05
e7300000-e73fffff : PCI Bus 0000:1c
e7400000-e74fffff : PCI Bus 0000:14
e7500000-e75fffff : PCI Bus 0000:0c
e7600000-e76fffff : PCI Bus 0000:04
e7700000-e77fffff : PCI Bus 0000:1b
e7800000-e78fffff : PCI Bus 0000:13
e7900000-e79fffff : PCI Bus 0000:0b
e7a00000-e7afffff : PCI Bus 0000:03
e7b00000-e7ffffff : PCI Bus 0000:02
e8000000-efffffff : 0000:00:0f.0
e8000000-efffffff : vmwgfx probe
f0000000-f7ffffff : PCI MMCONFIG 0000 [bus 00-7f]
f0000000-f7ffffff : reserved
f0000000-f7ffffff : pnp 00:06
fb500000-fb5fffff : PCI Bus 0000:22
fb600000-fb6fffff : PCI Bus 0000:1a
fb700000-fb7fffff : PCI Bus 0000:12
fb800000-fb8fffff : PCI Bus 0000:0a
fb900000-fb9fffff : PCI Bus 0000:21
fba00000-fbafffff : PCI Bus 0000:19
fbb00000-fbbfffff : PCI Bus 0000:11
fbc00000-fbcfffff : PCI Bus 0000:09
fbd00000-fbdfffff : PCI Bus 0000:20
fbe00000-fbefffff : PCI Bus 0000:18
fbf00000-fbffffff : PCI Bus 0000:10
fc000000-fc0fffff : PCI Bus 0000:08
fc100000-fc1fffff : PCI Bus 0000:1f
fc200000-fc2fffff : PCI Bus 0000:17
fc300000-fc3fffff : PCI Bus 0000:0f
fc400000-fc4fffff : PCI Bus 0000:07
fc500000-fc5fffff : PCI Bus 0000:1e
fc600000-fc6fffff : PCI Bus 0000:16
fc700000-fc7fffff : PCI Bus 0000:0e
fc800000-fc8fffff : PCI Bus 0000:06
fc900000-fc9fffff : PCI Bus 0000:1d
fca00000-fcafffff : PCI Bus 0000:15
fcb00000-fcbfffff : PCI Bus 0000:0d
fcc00000-fccfffff : PCI Bus 0000:05
fcd00000-fcdfffff : PCI Bus 0000:1c
fce00000-fcefffff : PCI Bus 0000:14
fcf00000-fcffffff : PCI Bus 0000:0c
fd000000-fd0fffff : PCI Bus 0000:04
fd100000-fd1fffff : PCI Bus 0000:1b
fd200000-fd2fffff : PCI Bus 0000:13
fd300000-fd3fffff : PCI Bus 0000:0b
fd400000-fd4fffff : PCI Bus 0000:03
fd500000-fdffffff : PCI Bus 0000:02
fd500000-fd50ffff : 0000:02:01.0
fd5c0000-fd5dffff : 0000:02:01.0
fd5c0000-fd5dffff : e1000
fd5ef000-fd5effff : 0000:02:03.0
fd5ef000-fd5effff : ehci_hcd
fdff0000-fdffffff : 0000:02:01.0
fdff0000-fdffffff : e1000
fe000000-fe7fffff : 0000:00:0f.0
fe000000-fe7fffff : vmwgfx probe
fe800000-fe9fffff : pnp 00:06
feba0000-febbffff : 0000:00:10.0
feba0000-febbffff : mpt
febc0000-febdffff : 0000:00:10.0
febc0000-febdffff : mpt
febfe000-febfffff : 0000:00:07.7
fec00000-fec0ffff : reserved
fec00000-fec003ff : IOAPIC 0
fed00000-fed003ff : HPET 0
fed00000-fed003ff : pnp 00:04
fee00000-fee00fff : Local APIC
fee00000-fee00fff : reserved
fffe0000-ffffffff : reserved
- 第一行數字
代表記憶體位址 - 第二行有文字也有數字
數字代表 PCI 的裝置編號 , 如 e1000 的 0000:02:01.0
匯流排(bus number) 0000:02
裝置(device number) 01
功能(function number) 0
/proc/ioports
IO 裝置位址對應的名稱可以參考這個檔案.
[root@localhost ~]# cat /proc/ioports
0000-0cf7 : PCI Bus 0000:00
0000-001f : dma1
0020-0021 : PNP0001:00
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0061-0061 : PNP0800:00
0064-0064 : keyboard
0070-0071 : rtc0
0080-008f : dma page reg
00a0-00a1 : PNP0001:00
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : 0000:00:07.1
0170-0177 : ata_piix
01f0-01f7 : 0000:00:07.1
01f0-01f7 : ata_piix
0376-0376 : 0000:00:07.1
0376-0376 : ata_piix
03c0-03df : vga+
03f6-03f6 : 0000:00:07.1
03f6-03f6 : ata_piix
03f8-03ff : serial
04d0-04d1 : PNP0001:00
0cf0-0cf1 : pnp 00:00
0cf8-0cff : PCI conf1
0d00-feff : PCI Bus 0000:00
1000-103f : 0000:00:07.3
1000-1003 : ACPI PM1a_EVT_BLK
1004-1005 : ACPI PM1a_CNT_BLK
1008-100b : ACPI PM_TMR
100c-100f : ACPI GPE0_BLK
1010-1015 : ACPI CPU throttle
1040-104f : 0000:00:07.3
1040-104f : pnp 00:00
1060-106f : 0000:00:07.1
1060-106f : ata_piix
1070-107f : 0000:00:0f.0
1070-107f : vmwgfx probe
1080-10bf : 0000:00:07.7
1080-10bf : vmw_vmci
1400-14ff : 0000:00:10.0
2000-3fff : PCI Bus 0000:02
2000-203f : 0000:02:01.0
2000-203f : e1000
2040-207f : 0000:02:02.0
2040-207f : Ensoniq AudioPCI
2080-209f : 0000:02:00.0
2080-209f : uhci_hcd
4000-4fff : PCI Bus 0000:03
5000-5fff : PCI Bus 0000:0b
6000-6fff : PCI Bus 0000:13
7000-7fff : PCI Bus 0000:1b
8000-8fff : PCI Bus 0000:04
9000-9fff : PCI Bus 0000:0c
a000-afff : PCI Bus 0000:14
b000-bfff : PCI Bus 0000:1c
c000-cfff : PCI Bus 0000:05
d000-dfff : PCI Bus 0000:0d
e000-efff : PCI Bus 0000:15
fce0-fcff : pnp 00:06
沒有解決問題,試試搜尋本站其他內容