Re: [PATCH] net-sysfs: expose IRQ number

From: Willem de Bruijn
Date: Mon Apr 29 2019 - 12:16:32 EST


On Mon, Apr 29, 2019 at 2:01 AM RafaÅ MiÅecki <zajec5@xxxxxxxxx> wrote:
>
> From: RafaÅ MiÅecki <rafal@xxxxxxxxxx>
>
> Knowing IRQ number makes e.g. reading /proc/interrupts much simpler.
> It's more reliable than guessing device name used by a driver when
> calling request_irq().
>
> Signed-off-by: RafaÅ MiÅecki <rafal@xxxxxxxxxx>
> ---
> I found a script parsing /proc/interrupts for a given interface name. It wasn't
> working for me as it assumed request_irq() was called with a device name. It's
> not a case for all drivers.
>
> I also found some other people looking for a proper solution for that:
> https://unix.stackexchange.com/questions/275075/programmatically-determine-the-irqs-associated-with-a-network-interface
> https://stackoverflow.com/questions/7516984/retrieving-irq-number-of-a-nic
>
> Let me know if this solution makes sense. I can say it works for me ;)

If parsing /proc/interrupts is problematic, also see the
/sys/kernel/irq interface added in commit ecb3f394c5db ("genirq:
Expose interrupt information through sysfs"). Does that address your
use-case as well? Though it does the inverse mapping from IRQ to name.

Another practical issue is that many network devices register more
than one interrupt. Perhaps one control interrupt, plus one per
receive queue and possibly one per transmit queue. Unfortunately those
cannot be identified in a driver-independent manner. Because an
interface /sys/class/net/$DEV/queues/rx-$i/irq would be useful.