tgn*_*ham 7 devices interrupt sysfs network-interface
给定接口名称(例如 eth0),以编程方式确定与网络接口关联的 IRQ 的最可靠方法是什么?
我对尽力而为的方法没问题,但我希望它适用于各种驱动程序/配置(即没有对每个驱动程序进行特殊处理),并且我想避免误报。我还想避免违反此处概述的与 sysfs 交互的规则,但我可以在必要时打破它们。我将在下面的示例中打破它们。
解析/proc/interrupts
并不理想,因为与 IRQ 关联的名称是特定于驱动程序的,并且不可靠,因为没有什么可以阻止两个设备具有相同名称的 IRQ。
如果我可以执行以下操作,那就太好了:
$ ls /sys/class/net/eth2/device/msi_irqs | cat /sys/class/net/eth2/device/irq
61 62 63
Run Code Online (Sandbox Code Playgroud)
我已经使用/proc/interrupts
.
但这并不适用于所有驱动程序。感兴趣的 IRQ 文件位于不同的位置,或者无处可寻。
vmxnet3 接口:
$ readlink -e /sys/class/net/eth2
/sys/devices/pci0000:00/0000:00:16.0/0000:0b:00.0/net/eth2
$ ls $(readlink -e /sys/class/net/eth2)/../../msi_irqs
61 62 63
Run Code Online (Sandbox Code Playgroud)
感兴趣的 msi_irqs 是从 /sys/class/net/eth2 符号链接向上的两个目录。msi_irqs 三个目录上面都跟我无关。
虚拟界面:
$ readlink -e /sys/class/net/eth1
/sys/devices/pci0000:00/0000:00:03.0/virtio0/net/eth1
ls $(readlink -e /sys/class/net/eth1)/../../../msi_irqs
26 27 28
Run Code Online (Sandbox Code Playgroud)
感兴趣的 msi_irqs 是从 /sys/class/net/eth1 符号链接向上的三个目录。此层次结构中没有其他 msi_irqs 文件。
hv_netvsc 接口:
$ readlink -e /sys/class/net/eth0
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:07/VMBus:00/vmbus_0_11/net/eth0
Run Code Online (Sandbox Code Playgroud)
IRQ 信息似乎不在 sysfs 中。对于唯一的“hyperv”IRQ,我不得不求助于 grepping /proc/interrupts。
我使用的方法是从目录中搜索$(readlink -e /sys/class/net/eth0)
up to but not include /sys/devices/pci<domain>:<bus>/
for the msi_irqs
or irq
file 。我担心这样做可能会得到错误的 IRQ。可能由于某种原因,与接口关联的 IRQ 不会发布到msi_irqs
或irq
,但会发布祖先设备的 IRQ。我最终会得到祖先设备的 IRQ,这可能不是我想要的。
是否有更好的方法来可靠地确定与网络接口关联的 IRQ?如果不是,上述方法是否可以返回与接口无关的 IRQ?
你有没有尝试过dstat
?
以我的 enp025 以太网接口为例:
\n\ndstat -i -N enp0s25\n ----interrupts---\n33 34 35
5 0 0 \n6 0 0 \n8 0 26 \n9 0 0 \n7 0 0 \n10 0 0 \n
Run Code Online (Sandbox Code Playgroud)\n\n要执行更多操作,请阅读手册页:
\n\nDSTAT(1) DSTAT(1)
\n\nNAME\n dstat - 用于生成系统资源统计信息的多功能工具
\n\n概要\n dstat [-afv] [选项..] [延迟 [计数]]
\n\n描述\n Dstat 是 vmstat、iostat 和 ifstat 的通用替代品。Dstat 克服了一些限制并添加了一些额外的功能。
\n\n Dstat allows you to view all of your system resources instantly, you can eg. compare disk usage in combination with interrupts from\n your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).\n\n Dstat also cleverly gives you the most detailed information in columns and clearly indicates in what magnitude and unit the output is\n displayed. Less confusion, less mistakes, more efficient.\n\n Dstat is unique in letting you aggregate block device throughput for a certain diskset or network bandwidth for a group of interfaces,\n ie. you can see the throughput for all the block devices that make up a single filesystem or storage system.\n\n Dstat allows its data to be directly written to a CSV file to be imported and used by OpenOffice, Gnumeric or Excel to create graphs.\n\n\n Note\n Users of Sleuthkit might find Sleuthkit\xe2\x80\x99s dstat being renamed to datastat to avoid a name conflict. See Debian bug #283709 for more\n information.\n
Run Code Online (Sandbox Code Playgroud)\n\n选项\n -c, --cpu\n 启用 CPU 统计信息(系统、用户、空闲、等待、硬件中断、软件中断)
\n\n -C 0,3,total\n include cpu0, cpu3 and total (when using -c/--cpu)\n\n -d, --disk\n enable disk stats (read, write)\n\n -D total,hda\n include total and hda (when using -d/--disk)\n\n -g, --page\n enable page stats (page in, page out)\n\n -i, --int\n enable interrupt stats\n\n -I 5,10\n include interrupt 5 and 10 (when using -i/--int)\n\n -l, --load\n enable load average stats (1 min, 5 mins, 15mins)\n\n -m, --mem\n enable memory stats (used, buffers, cache, free)\n\n -n, --net\n enable network stats (receive, send)\n -N eth1,total\n include eth1 and total (when using -n/--net)\n\n -p, --proc\n enable process stats (runnable, uninterruptible, new)\n\n -r, --io\n enable I/O request stats (read, write requests)\n\n -s, --swap\n enable swap stats (used, free)\n\n -S swap1,total\n include swap1 and total (when using -s/--swap)\n\n -t, --time\n enable time/date output\n\n -T, --epoch\n enable time counter (seconds since epoch)\n\n -y, --sys\n enable system stats (interrupts, context switches)\n\n --aio enable aio stats (asynchronous I/O)\n\n --fs, --filesystem\n enable filesystem stats (open files, inodes)\n\n --ipc enable ipc stats (message queue, semaphores, shared memory)\n
Run Code Online (Sandbox Code Playgroud)\n\n`
\n\n和很多其他选择。
\n\n也可以看看 : lspci -v -x
归档时间: |
|
查看次数: |
3695 次 |
最近记录: |