p Other synchronization interfaces are built using the MI IPI interface. For a general purpose inter-processor cross-calls or remote interrupts, use the .Xr xcall 9 or .Xr softint 9 interfaces.
p
The primary use cases of the MI IPIs include the following:
l -hyphen -compact t provide a facility for the
.Xr softint 9
subsystem to schedule software interrupts on remote CPUs
t provide a facility for the
.Xr xcall 9
subsystem
t abstract IPI handling and facilitate machine-dependent code
.El
-----
.Ss Asynchronous IPI interface
This interface allows dynamic registration of IPI handlers with a constant
argument and asynchronous triggering of interrupts.
l -tag -width compact t Fn ipi_register "func" "arg" Register an IPI handler
.Fa func
with an arbitrary argument
.Fa arg .
Returns a non-zero IPI identifier on success and zero on failure.
t Fn ipi_unregister "ipi_id" Unregister the IPI handler identified by the
.Fa ipi_id .
t Fn ipi_trigger "ipi_id" "ci" Trigger an IPI identified by
.Fa ipi_id
on a remote CPU specified by
.Fa ci .
This function must be called with kernel preemption disabled and
the target CPU must be remote.
t Fn ipi_trigger_multi "ipi_id" "target" Trigger an IPI identified by
.Fa ipi_id
on all of the CPUs in the set specified by
.Fa target .
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 processes synchronously.
t Fn ipi_trigger_broadcast "ipi_id" "skip_self" Trigger an IPI identified by
.Fa ipi_id
on all of the attached CPUs.
This function must be called with kernel preemption disabled.
Optionally, the sending CPU may be skipped by passing
.Dv true
for
.Fa skip_self .
.El
-----
.Ss 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
.Vt ipi_msg_t
structure which has the following public members:
d -literal ipi_func_t func;
void arg;
.Ed
p The .Ar func member specifies a function to invoke and .Ar arg is the argument to be passed to the function. l -tag -width compact t Fn ipi_unicast "msg" "ci" Send an IPI to a remote CPU specified by .Fa ci . t Fn ipi_multicast "msg" "target" Send IPIs to a CPU set specified by .Fa target . t Fn ipi_broadcast "msg" "skip_self" Send IPIs to all CPUs. Optionally, the sending CPU may be skipped by passing .Dv true for .Fa skip_self . t Fn ipi_wait "msg" Wait until all IPIs complete. .El
p
All described functions, except
.Fn ipi_wait ,
must be called with the kernel preemption disabled.
All synchronous IPI invocations must be completed (wait for them with the
.Fn ipi_wait
function) before the IPI message structure can be destroyed or new
cross-call requests can be performed.
-----
.Sh MEMORY ORDER
All memory operations that happen before triggering an IPI, via
.Fn ipi_trigger ,
.Fn ipi_trigger_multi ,
.Fn ipi_trigger_broadcast ,
.Fn ipi_unicast ,
.Fn ipi_multicast ,
or
.Fn ipi_broadcast ,
also happen before any memory operations in the IPI handler function on
the remote CPU.
p
For synchronous IPIs, all memory operations that happen before the IPI
handler function has returned on the remote CPU also happen before
.Fn ipi_wait
returns on the waiting CPU.
-----
.Sh NOTES
Functions being called must be lightweight.
They run at
.Dv IPL_HIGH
and should generally not use any other synchronization interfaces
such as
.Xr mutex 9 .
If spin-locks are used, they must be used carefully and have no contention.
-----
.Sh CODE REFERENCES
The
.Nm
interface is implemented within the file
a sys/kern/subr_ipi.c .
-----
.Sh SEE ALSO
.Xr kcpuset 9 ,
.Xr kpreempt 9 ,
.Xr softint 9 ,
.Xr spl 9 ,
.Xr xcall 9
.Sh HISTORY
The
.Nm
interface first appeared in
.Nx 7.0 .
.Sh AUTHORS
.An Mindaugas Rasiukevicius Aq Mt rmind (at] NetBSD.org