BUS_BIND_INTR(9)

πŸ’– BUS_BIND_INTR β€” bestie, let's pin that interrupt πŸ’–

ok so this is a page from the Kernel Developer's Manual, section 9. Yes it's the BUS_BIND_INTR one. Come sit with me, this is actually so good.


✨ NAME ✨

BUS_BIND_INTR, bus_bind_intr β€” bind an interrupt resource to a specific CPU πŸŽ€


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/bus.h>

int
BUS_BIND_INTR(device_t dev, device_t child, struct resource *irq,
    int cpu);

int
bus_bind_intr(device_t dev, struct resource *irq, int cpu);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the BUS_BIND_INTR() method lets you pin an interrupt resource to one specific CPU. like, "this one. only this one. periodt." πŸ’…

heads up bestie: the interrupt resource must already have an interrupt handler attached via BUS_SETUP_INTR(9). No handler, no binding, that's the vibe check.

The cpu parameter is the ID of a valid CPU in the system.

Here's what binding actually does, fr fr:

  • it restricts the cpuset(2) of any associated interrupt threads so they only include the specified CPU
  • it may also direct the low-level interrupt handling of the interrupt to the specified CPU as well β€” but this behavior is platform-dependent, so don't @ me

And if you pass NOCPU as the value for cpu? Then the interrupt gets β€œunbound” 🌈 which restores any associated interrupt threads back to the default cpuset. undoing the binding, iconic behavior.

⚠️ Non-sleepable locks such as mutexes should not be held across calls to these functions. like literally do not do that. 😭

The bus_bind_intr() function is just a simple wrapper around BUS_BIND_INTR(). tiny, adorable, does the same thing. 🫢

Note that currently there is no attempt made to arbitrate between multiple bind requests for the same interrupt β€” whether from the same device or from multiple devices. Also? There is no arbitration between interrupt binding requests submitted by userland via cpuset(2) and BUS_BIND_INTR(). So who wins?

The most recent binding request is the one that will be in effect. Last one in the group chat decides. that's the rule. πŸ‘‘


⭐ RETURN VALUES ⭐

Zero on success, bestie. ✨ Otherwise, an appropriate error is returned. πŸ˜”


🌈 SEE ALSO 🌈


πŸŽ€ HISTORY πŸŽ€

The BUS_BIND_INTR() method and the bus_bind_intr() functions first appeared in FreeBSD 7.2. throwback era honestly.


ok that's the whole page, you ate that πŸ’… this one came from the Debian crew and it's dated October 14, 2009 β€” so yes, this lore is old but it's still giving main character energy. go bind something (safely) πŸ¦‹βœ¨

πŸ“¦ where this page comes from