on_each_cpu_cond_mask(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… on_each_cpu_cond_mask(9) β€” Kernel API Manual, section 9

okay bestie, buckle up. this is a page from the Kernel API Manual, and it's about yelling at a bunch of CPUs at once β€” but like, only the ones that pass the vibe check 🫢

✨ NAME ✨

on_each_cpu_cond_mask β€” Call a function on each processor for which the supplied function cond_func returns true, optionally waiting for all the required CPUs to finish. This may include the local processor. πŸ‘‘

🌸 SYNOPSIS 🌸

void on_each_cpu_cond_mask (smp_cond_func_t cond_func , smp_call_func_t
func , void *info , bool wait , const struct cpumask *mask );

πŸŽ€ ARGUMENTS πŸŽ€

  • cond_func β€” A callback function that is passed a cpu id and the info parameter. The function is called with preemption disabled. The function should return a boolean value indicating whether to IPI the specified CPU. so like, it's the bouncer at the club door πŸ’… "you in? you not? boolean, babes."
  • func β€” The function to run on all applicable CPUs. This must be fast and non-blocking. fr fr, no cap β€” do not be doing your whole slow little routine in here. πŸƒβ€β™€οΈπŸ’¨
  • info β€” An arbitrary pointer to pass to both functions. a little gift bag 🎁 you hand to both of them.
  • wait β€” If true, wait until function has completed on other CPUs. like standing at the door until everyone texts you back 😭
  • mask β€” The set of cpus to run on (only runs on online subset). the guest list, but only the ones who actually showed up 🌈

πŸ¦‹ DESCRIPTION πŸ¦‹

Target CPU selection and work queueing are done with preemption disabled. this is the protective shield okay πŸ›‘οΈ It protects against CPUs going offline, but not against CPUs coming online concurrently; newly online CPUs are not guaranteed to be seen or sent an IPI. so if a CPU clocks in late, bestie, nobody promised it gets an invite πŸ’€

If wait is true, the final wait for remote completion happens after that preemption-disabled section. note the timing, it matters πŸ”₯

⚠️ You must not call this function with disabled interrupts or from a hardware interrupt handler or from a bottom half handler. like, absolutely not. that is not the vibe. do not do that. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./kernel/smp.c and its little friends: csd_lock_is_stuck(9), generic_smp_call_function_single_interrupt(9), __flush_smp_call_function_queue(9), flush_smp_call_function_queue(9), smp_call_function_single(9), smp_call_function_single_async(9), smp_call_function_any(9), smp_call_function_many(9), smp_call_function(9), kick_all_cpus_sync(9), wake_up_all_idle_cpus(9), cpus_peek_for_pending_ipi(9), struct smp_call_on_cpu_struct(9), smp_call_on_cpu(9)


✨ mwah, that's a wrap ✨ this icon came from the ./kernel source, version date October 2026, and it lives under on_each_cpu_cond_mask(9). go forth and IPI responsibly, iykyk πŸ§šπŸ’œ

πŸ“¦ where this page comes from