Manual browser: xc_unicast(9)
|XCALL(9)||Kernel Developer's Manual||XCALL(9)|
NAMExcall, xc_broadcast, xc_unicast, xc_wait — cross-call interface
typedef void (*xcfunc_t)(void *, void *);
xc_broadcast(u_int flags, xcfunc_t func, void *arg1, void *arg2);
xc_unicast(u_int flags, xcfunc_t func, void *arg1, void *arg2, struct cpu_info *ci);
DESCRIPTIONThe machine-independent xcall interface allows any CPU in the system to request that an arbitrary function be executed on any other CPU.
Sometimes it is necessary to modify hardware state that is tied directly to individual CPUs (such as a CPU's local timer), and these updates can not be done remotely by another CPU. The LWP requesting the update may be unable to guarantee that it will be running on the CPU where the update must occur, when the update occurs.
Additionally, it is sometimes necessary to modify per-CPU software state from a remote CPU. Where these update operations are so rare or the access to the per-CPU data so frequent that the cost of using locking or atomic operations to provide coherency is prohibitive, another way must be found.
Cross calls help to solve these types of problem. However, since this facility is heavyweight, it is expected that it will not be used often.
xcall provides a mechanism for making “low priority” cross calls. The function to be executed runs on the remote CPU within a thread context, and not from a software interrupt, so it can ensure that it is not interrupting other code running on the CPU, and so has exclusive access to the CPU. Keep in mind that unless disabled, it may cause a kernel preemption.
xcall also provides a mechanism for making “high priority” cross calls. The function to be executed runs on the remote CPU within a IPL_SOFTSERIAL software interrupt context, possibly interrupting other lower-priority code running on the CPU.
NOTESFunctions being called should be relatively lightweight. They may block on locks, but carefully and minimally, to not interfere with other cross calls in the system.
- xc_broadcast(flags, func, arg1, arg2)
- Call (*func)(arg1, arg2); on all CPUs in the system. Return a uint64_t “ticket” to xc_wait() on for the cross-call to complete. flags should be XC_HIGHPRI for a "high priority" call, and 0 for a "low priority" call. xc_broadcast() should not be called from interrupt context.
- xc_unicast(flags, func, arg1, arg2, ci)
- Like xc_broadcast(), but call (*func)() on only the CPU indicated by ci. xc_unicast() also returns a “ticket”.
- Wait on the “ticket” returned by a prior xc_broadcast() or xc_unicast() for the corresponding cross-call to complete. xc_wait() should be called from a thread context.
CODE REFERENCESThe xcall interface is implemented within the file sys/kern/subr_xcall.c.
HISTORYThe xcall interface first appeared in NetBSD 5.0.
|November 26, 2013||NetBSD 7.0|