diff options
Diffstat (limited to 'arch/loongarch/include/asm/qspinlock.h')
| -rw-r--r-- | arch/loongarch/include/asm/qspinlock.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/arch/loongarch/include/asm/qspinlock.h b/arch/loongarch/include/asm/qspinlock.h index e76d3aa1e1eb..fbfc6be82f26 100644 --- a/arch/loongarch/include/asm/qspinlock.h +++ b/arch/loongarch/include/asm/qspinlock.h @@ -2,12 +2,11 @@ #ifndef _ASM_LOONGARCH_QSPINLOCK_H #define _ASM_LOONGARCH_QSPINLOCK_H -#include <linux/jump_label.h> +#include <asm/kvm_para.h> +#include <asm/paravirt.h> #ifdef CONFIG_PARAVIRT -DECLARE_STATIC_KEY_FALSE(virt_spin_lock_key); - #define virt_spin_lock virt_spin_lock static inline bool virt_spin_lock(struct qspinlock *lock) @@ -34,6 +33,26 @@ __retry: return true; } +/* + * Macro is better than inline function here + * With macro, parameter cpu is parsed only when it is used. + * With inline function, parameter cpu is parsed even though it is not used. + * This may cause cache line thrashing across NUMA nodes. + */ +#define vcpu_is_preempted(cpu) \ +({ \ + bool __val; \ + \ + if (!static_branch_unlikely(&virt_preempt_key)) \ + __val = false; \ + else { \ + struct kvm_steal_time *src; \ + src = &per_cpu(steal_time, cpu); \ + __val = !!(READ_ONCE(src->preempted) & KVM_VCPU_PREEMPTED); \ + } \ + __val; \ +}) + #endif /* CONFIG_PARAVIRT */ #include <asm-generic/qspinlock.h> |
