ネットワークインタフェースに関連するIRQをプログラムで決定

ネットワークインタフェースに関連するIRQをプログラムで決定

インターフェイス名(例:eth0)が指定されたネットワークインターフェイスに関連するIRQをプログラムで決定する最も信頼できる方法は何ですか?

私は最善のアプローチに同意しますが、さまざまなドライバ/構成で動作したい(つまり、各ドライバに対して特別な処理はありません)、誤解を避けたいと思います。また、sysfsと対話するルールに違反することを避けたいと思います。ここしかし、必要に応じてこれを破ることができます。以下の例でこれを分析します。

/proc/interruptsIRQに関連する名前はドライバごとに異なり、両方のデバイスが同じ名前のIRQを持つのを防ぐ方法がないため、解像度は理想的ではありません。

次のようなことができればいいと思います。

$ ls /sys/class/net/eth2/device/msi_irqs | cat /sys/class/net/eth2/device/irq
61  62  63

私はこれがこの場合私が探しているIRQであることを確認しました/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

興味のあるmsi_irqは、/sys/class/net/eth2シンボリックリンクの上の2つのディレクトリです。 msi_irqs上記の3つのディレクトリは私とは関係ありません。

Virtioインターフェース:

$ 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

興味のあるmsi_irqは、/sys/class/net/eth1シンボリックリンクの上部にある3つのディレクトリです。この階層には他の 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

IRQ情報がsysfsにないようです。独自の「hyperv」IRQを取得するには、grep /proc/interruptsに依存する必要がありました。

私が使った方法は、ディレクトリからファイルを検索します$(readlink -e /sys/class/net/eth0)が、含まないわけではありませんでした。/sys/devices/pci<domain>:<bus>/これにより、間違ったIRQが得られるのか心配になります。おそらく何らかの理由でインターフェイスに関連するIRQは公開されませんが、親デバイスのIRQは公開されます。私は先祖のIRQで終わります。これはおそらく私が望むものではありません。msi_irqsirqmsi_irqsirq

ネットワークインターフェイスに関連するIRQを確実にチェックするためのより良い方法はありますか?そうでない場合、上記のメソッドはインターフェースに依存しないIRQを返すことができますか?

ベストアンサー1

試してみましたdstatか?

enp025 イーサネットインターフェイスを例にしてみましょう。

dstat -i -N enp0s25 ----interrupts--- 33 34 35

5     0     0 
6     0     0 
8     0    26 
9     0     0 
7     0     0 
10     0     0 

さらに作業を行うには、マニュアルページをお読みください。

DSTAT(1) DSTAT(1)

名前dstat - システムリソース統計を生成するための多目的ツール

概要 dstat [-afv] [オプション..] [遅延[回数]]

説明 Dstat は、vmstat、iostat、および ifstat を置き換える汎用製品です。 Dstatはいくつかの制限を克服し、いくつかの追加機能を追加します。

   Dstat allows you to view all of your system resources instantly, you can eg. compare disk usage in combination with interrupts from
   your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).

   Dstat also cleverly gives you the most detailed information in columns and clearly indicates in what magnitude and unit the output is
   displayed. Less confusion, less mistakes, more efficient.

   Dstat is unique in letting you aggregate block device throughput for a certain diskset or network bandwidth for a group of interfaces,
   ie. you can see the throughput for all the block devices that make up a single filesystem or storage system.

   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.


   Note
   Users of Sleuthkit might find Sleuthkit’s dstat being renamed to datastat to avoid a name conflict. See Debian bug #283709 for more
   information.

オプション-c、--cpu CPU統計(システム、ユーザー、アイドル、スタンバイ、ハードウェア割り込み、ソフトウェア割り込み)を有効にします。

   -C 0,3,total
          include cpu0, cpu3 and total (when using -c/--cpu)

   -d, --disk
          enable disk stats (read, write)

   -D total,hda
          include total and hda (when using -d/--disk)

   -g, --page
          enable page stats (page in, page out)

   -i, --int
          enable interrupt stats

   -I 5,10
          include interrupt 5 and 10 (when using -i/--int)

   -l, --load
          enable load average stats (1 min, 5 mins, 15mins)

   -m, --mem
          enable memory stats (used, buffers, cache, free)

   -n, --net
          enable network stats (receive, send)
   -N eth1,total
          include eth1 and total (when using -n/--net)

   -p, --proc
          enable process stats (runnable, uninterruptible, new)

   -r, --io
          enable I/O request stats (read, write requests)

   -s, --swap
          enable swap stats (used, free)

   -S swap1,total
          include swap1 and total (when using -s/--swap)

   -t, --time
          enable time/date output

   -T, --epoch
          enable time counter (seconds since epoch)

   -y, --sys
          enable system stats (interrupts, context switches)

   --aio  enable aio stats (asynchronous I/O)

   --fs, --filesystem
          enable filesystem stats (open files, inodes)

   --ipc  enable ipc stats (message queue, semaphores, shared memory)

`

そして他の多くのオプション。

また見なさい: lspci -v -x

おすすめ記事