hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/qspinlock.h
....@@ -11,20 +11,17 @@
1111 #define _Q_PENDING_LOOPS (1 << 9)
1212
1313 #define queued_fetch_set_pending_acquire queued_fetch_set_pending_acquire
14
-
15
-static __always_inline bool __queued_RMW_btsl(struct qspinlock *lock)
16
-{
17
- GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter,
18
- "I", _Q_PENDING_OFFSET, "%0", c);
19
-}
20
-
2114 static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
2215 {
23
- u32 val = 0;
16
+ u32 val;
2417
25
- if (__queued_RMW_btsl(lock))
26
- val |= _Q_PENDING_VAL;
27
-
18
+ /*
19
+ * We can't use GEN_BINARY_RMWcc() inside an if() stmt because asm goto
20
+ * and CONFIG_PROFILE_ALL_BRANCHES=y results in a label inside a
21
+ * statement expression, which GCC doesn't like.
22
+ */
23
+ val = GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
24
+ "I", _Q_PENDING_OFFSET) * _Q_PENDING_VAL;
2825 val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK;
2926
3027 return val;
....@@ -35,6 +32,7 @@
3532 extern void __pv_init_lock_hash(void);
3633 extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
3734 extern void __raw_callee_save___pv_queued_spin_unlock(struct qspinlock *lock);
35
+extern bool nopvspin;
3836
3937 #define queued_spin_unlock queued_spin_unlock
4038 /**
....@@ -66,10 +64,25 @@
6664 #endif
6765
6866 #ifdef CONFIG_PARAVIRT
67
+/*
68
+ * virt_spin_lock_key - enables (by default) the virt_spin_lock() hijack.
69
+ *
70
+ * Native (and PV wanting native due to vCPU pinning) should disable this key.
71
+ * It is done in this backwards fashion to only have a single direction change,
72
+ * which removes ordering between native_pv_spin_init() and HV setup.
73
+ */
6974 DECLARE_STATIC_KEY_TRUE(virt_spin_lock_key);
7075
7176 void native_pv_lock_init(void) __init;
7277
78
+/*
79
+ * Shortcut for the queued_spin_lock_slowpath() function that allows
80
+ * virt to hijack it.
81
+ *
82
+ * Returns:
83
+ * true - lock has been negotiated, all done;
84
+ * false - queued_spin_lock_slowpath() will do its thing.
85
+ */
7386 #define virt_spin_lock virt_spin_lock
7487 static inline bool virt_spin_lock(struct qspinlock *lock)
7588 {