request_percpu_nmi(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– request_percpu_nmi(9) β€” the Kernel API Manual, bestie edition πŸ’–

okay so you found yourself in the request_percpu_nmi(9) page of the Kernel API Manual and honestly? you're in the right place. this one's about grabbing a percpu interrupt line and dedicating it to NMI delivery. let's get into it ✨


🌸 NAME 🌸

request_percpu_nmi β€” allocate a percpu interrupt line for NMI delivery

like, that's the whole vibe. you're claiming a percpu IRQ so it can deliver NMIs. no cap.


πŸŽ€ SYNOPSIS πŸŽ€

int request_percpu_nmi (unsigned int irq , irq_handler_t handler , const
       char *name , const struct cpumask *affinity , void __percpu *dev_id );

yes she's a five-argument function and yes you're gonna need all of them. stay with me 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • irq β€” the interrupt line you're allocating. this is the one, the main character, the line you're claiming for yourself πŸ’…
  • handler β€” the function that gets called when the IRQ occurs. your callback. your moment. πŸ”₯
  • name β€” an ascii name for the claiming device. it's giving "put your name on it" energy, because you literally do.
  • affinity β€” a cpumask describing the target CPUs for this interrupt. this is you choosing which CPUs are in the group chat 🌈
  • dev_id β€” a percpu cookie passed back to the handler function. a little treat that comes back to you later πŸ“

✨ DESCRIPTION ✨

so what does this call actually do? it allocates interrupt resources for a per CPU NMI. that's the whole thing. but here's the tea β€” per CPU NMIs have to be setup on each CPU by calling prepare_percpu_nmi before being enabled on the same CPU by using enable_percpu_nmi. so it's a two-step before you get to the slay, and per-CPU means per-CPU, fr fr. πŸ‘‘

dev_id must be globally unique. like, globally unique unique. it is a per-cpu variable, and the handler gets called with the interrupted CPU's instance of that variable. so each CPU gets its own little copy, and your handler sees the one belonging to whichever CPU got interrupted. iconic behavior honestly 🧚

interrupt lines requested for NMI delivering should have auto enabling setting disabled. noted. don't skip that part. πŸ™ˆ

and if the interrupt line cannot be used to deliver NMIs, the function will fail returning a negative value. so like. vibe check failed, you get a negative number back. 😭

lowkey important: the prepare_percpu_nmi β†’ enable_percpu_nmi pairing has to happen per CPU, and the auto enabling setting needs to be off for NMI delivery lines. don't come for me later if you skipped it πŸ’€

πŸ’œ SEE ALSO πŸ’œ

the whole extended universe, in order:

like, read them. they're all connected. iykyk πŸ’…


aaand that's the page bestie!! this lil masterpiece lives in ./kernel/irq and it's dated October 2026 β€” so yeah, screenshot it, cite it, love it. mwah πŸ’‹βœ¨πŸŒΈ

πŸ“¦ where this page comes from