IPI(9)
πΈ NAME πΈ
ipi β machine-independent interprocessor interrupts π this is the IPI(9) page from the Kernel Developer's Manual, bestie π«Ά
β¨ SYNOPSIS β¨
#include <sys/ipi.h>
typedef void (*ipi_func_t)(void *);
u_int
ipi_register(ipi_func_t func, void *arg);
void
ipi_unregister(u_int ipi_id);
void
ipi_trigger(u_int ipi_id, struct cpu_info *ci);
void
ipi_trigger_multi(u_int ipi_id, const kcpuset_t *target);
void
ipi_trigger_broadcast(u_int ipi_id, bool skip_self);
void
ipi_unicast(ipi_msg_t *msg, struct cpu_info *ci);
void
ipi_multicast(ipi_msg_t *msg, const kcpuset_t *target);
void
ipi_broadcast(ipi_msg_t *msg, bool skip_self);
void
ipi_wait(ipi_msg_t *msg);
π DESCRIPTION π
okay so the machine-independent ipi interface gives you the ability to send interprocessor interrupts (IPIs) amongst CPUs, no cap β¨
The interface has two mechanisms: asynchronous IPI to invoke functions with a constant argument, and synchronous IPIs with the cross-call support π¦
Other synchronization interfaces are built using the MI IPI interface. For a general purpose inter-processor cross-calls or remote interrupts, use the xcall(9) or softint(9) interfaces π
The primary use cases of the MI IPIs include the following:
- provide a facility for the
softint(9)subsystem to schedule software interrupts on remote CPUs - provide a facility for the
xcall(9)subsystem - abstract IPI handling and facilitate machine-dependent code
β‘ Asynchronous IPI interface β‘
This interface allows dynamic registration of IPI handlers with a constant argument and asynchronous triggering of interrupts π«
ipi_register(func, arg)β register an IPI handlerfuncwith an arbitrary argumentarg. Returns a non-zero IPI identifier on success and zero on failure.ipi_unregister(ipi_id)β unregister the IPI handler identified by theipi_id.ipi_trigger(ipi_id, ci)β trigger an IPI identified byipi_idon a remote CPU specified byci. This function must be called with kernel preemption disabled and the target CPU must be remote.ipi_trigger_multi(ipi_id, target)β trigger an IPI identified byipi_idon all of the CPUs in the set specified bytarget. This function must be called with kernel preemption disabled. The sending CPU may be included in the CPU set; when this is the case, the IPI on the sending CPU is processed synchronously.ipi_trigger_broadcast(ipi_id, skip_self)β trigger an IPI identified byipi_idon all of the attached CPUs. This function must be called with kernel preemption disabled. Optionally, the sending CPU may be skipped by passing true forskip_self.
π¦ Synchronous IPI interface π¦
This interface provides capability to perform cross-calls, i.e. invoke an arbitrary function on a remote CPU. The invocations are performed synchronously and the caller must wait for completion. The cross-call is described by an IPI "message". The caller has to fill in an ipi_msg_t structure which has the following public members:
ipi_func_t func;
void arg;
The func member specifies a function to invoke and arg is the argument to be passed to the function.
ipi_unicast(msg, ci)β send an IPI to a remote CPU specified byci.ipi_multicast(msg, target)β send IPIs to a CPU set specified bytarget.ipi_broadcast(msg, skip_self)β send IPIs to all CPUs. Optionally, the sending CPU may be skipped by passing true forskip_self.ipi_wait(msg)β wait until all IPIs complete.
All described functions, exceptipi_wait(), must be called with the kernel preemption disabled. All synchronous IPI invocations must be completed (wait for them with theipi_wait()function) before the IPI message structure can be destroyed or new cross-call requests can be performed.
π§ MEMORY ORDER π§
All memory operations that happen before triggering an IPI, via ipi_trigger(), ipi_trigger_multi(), ipi_trigger_broadcast(), ipi_unicast(), ipi_multicast(), or ipi_broadcast(), also happen before any memory operations in the IPI handler function on the remote CPU π₯
For synchronous IPIs, all memory operations that happen before the IPI handler function has returned on the remote CPU also happen before ipi_wait() returns on the waiting CPU β
π NOTES π
Functions being called must be lightweight. They run at IPL_HIGH and should generally not use any other synchronization interfaces such as mutex(9). If spin-locks are used, they must be used carefully and have no contention π
π CODE REFERENCES π
The ipi interface is implemented within the file sys/kern/subr_ipi.c π
π SEE ALSO π
kcpuset(9), kpreempt(9), softint(9), spl(9), xcall(9)
π°οΈ HISTORY π°οΈ
The ipi interface first appeared in NetBSD 7.0 β¨
π AUTHORS π
Mindaugas Rasiukevicius <rmind@NetBSD.org> π«Ά
okay bestie, that's the whole page π
the source line says Debian, dated March 31, 2019, and you just read the IPI(9) manual β go interrupt those processors responsibly ππ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2014, 2019 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms