]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/x86/include/asm/qspinlock.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_QSPINLOCK_H
3 #define _ASM_X86_QSPINLOCK_H
5 #include <asm/cpufeature.h>
6 #include <asm-generic/qspinlock_types.h>
7 #include <asm/paravirt.h>
9 #define queued_spin_unlock queued_spin_unlock
11 * queued_spin_unlock - release a queued spinlock
12 * @lock : Pointer to queued spinlock structure
14 * A smp_store_release() on the least-significant byte.
16 static inline void native_queued_spin_unlock(struct qspinlock
*lock
)
18 smp_store_release((u8
*)lock
, 0);
21 #ifdef CONFIG_PARAVIRT_SPINLOCKS
22 extern void native_queued_spin_lock_slowpath(struct qspinlock
*lock
, u32 val
);
23 extern void __pv_init_lock_hash(void);
24 extern void __pv_queued_spin_lock_slowpath(struct qspinlock
*lock
, u32 val
);
25 extern void __raw_callee_save___pv_queued_spin_unlock(struct qspinlock
*lock
);
27 static inline void queued_spin_lock_slowpath(struct qspinlock
*lock
, u32 val
)
29 pv_queued_spin_lock_slowpath(lock
, val
);
32 static inline void queued_spin_unlock(struct qspinlock
*lock
)
34 pv_queued_spin_unlock(lock
);
37 #define vcpu_is_preempted vcpu_is_preempted
38 static inline bool vcpu_is_preempted(long cpu
)
40 return pv_vcpu_is_preempted(cpu
);
43 static inline void queued_spin_unlock(struct qspinlock
*lock
)
45 native_queued_spin_unlock(lock
);
49 #ifdef CONFIG_PARAVIRT
50 #define virt_spin_lock virt_spin_lock
51 static inline bool virt_spin_lock(struct qspinlock
*lock
)
53 if (!static_cpu_has(X86_FEATURE_HYPERVISOR
))
57 * On hypervisors without PARAVIRT_SPINLOCKS support we fall
58 * back to a Test-and-Set spinlock, because fair locks have
59 * horrible lock 'holder' preemption issues.
63 while (atomic_read(&lock
->val
) != 0)
65 } while (atomic_cmpxchg(&lock
->val
, 0, _Q_LOCKED_VAL
) != 0);
69 #endif /* CONFIG_PARAVIRT */
71 #include <asm-generic/qspinlock.h>
73 #endif /* _ASM_X86_QSPINLOCK_H */