]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/processor.h
1 /* Misc low level processor primitives */
2 #ifndef _LINUX_PROCESSOR_H
3 #define _LINUX_PROCESSOR_H
5 #include <asm/processor.h>
8 * spin_begin is used before beginning a busy-wait loop, and must be paired
9 * with spin_end when the loop is exited. spin_cpu_relax must be called
12 * The loop body should be as small and fast as possible, on the order of
13 * tens of instructions/cycles as a guide. It should and avoid calling
14 * cpu_relax, or any "spin" or sleep type of primitive including nested uses
15 * of these primitives. It should not lock or take any other resource.
16 * Violations of these guidelies will not cause a bug, but may cause sub
17 * optimal performance.
19 * These loops are optimized to be used where wait times are expected to be
20 * less than the cost of a context switch (and associated overhead).
22 * Detection of resource owner and decision to spin or sleep or guest-yield
23 * (e.g., spin lock holder vcpu preempted, or mutex owner not on CPU) can be
24 * tested within the loop body.
30 #ifndef spin_cpu_relax
31 #define spin_cpu_relax() cpu_relax()
35 * spin_cpu_yield may be called to yield (undirected) to the hypervisor if
36 * necessary. This should be used if the wait is expected to take longer
37 * than context switch overhead, but we can't sleep or do a directed yield.
39 #ifndef spin_cpu_yield
40 #define spin_cpu_yield() cpu_relax_yield()
48 * spin_until_cond can be used to wait for a condition to become true. It
49 * may be expected that the first iteration will true in the common case
50 * (no spinning), so that callers should not require a first "likely" test
51 * for the uncontended case before using this primitive.
53 * Usage and implementation guidelines are the same as for the spin_begin
56 #ifndef spin_until_cond
57 #define spin_until_cond(cond) \
59 if (unlikely(!(cond))) { \
70 #endif /* _LINUX_PROCESSOR_H */