Skip to contentSkip to conversation

locking: Add __percpu tag to decode_tail qnode argument

PATCH Applied Kumar Kartikeya Dwivedi 2 participants 2 messages Mar 19, 2025

Subsystems (2)
lore
Share & tools
lore

Kumar Kartikeya Dwivedi

author maintainer
#0 lore raw

PATCH 1/1 locking: Add __percpu tag to decode_tail qnode argument

The decode_tail function now takes a qnode argument to use distinct qnodes for qspinlock and rqspinlock. Add a __percpu tag to avoid warnings and errors and reflect that the qnodes are per-cpu. There is no actual bug here as the value was not dereferenced directly and passed to per_cpu_ptr, so this is just to suppress the warning/errors at compile time.

Fixes 06988910ee2d ("locking: Move common qspinlock helpers to a private header")
---
 kernel/locking/qspinlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock.h +1 -1
index d4ceb9490365..f63b6e04ddd4 100644
@@ -59,7 +59,7 @@ static inline __pure u32 encode_tail(int cpu, int idx)
 	return tail;
 }
 
-static inline __pure struct mcs_spinlock *decode_tail(u32 tail, struct qnode *qnodes)
+static inline __pure struct mcs_spinlock *decode_tail(u32 tail, struct qnode __percpu *qnodes)
 {
 	int cpu = (tail >> _Q_TAIL_CPU_OFFSET) - 1;
 	int idx = (tail &  _Q_TAIL_IDX_MASK) >> _Q_TAIL_IDX_OFFSET;

--
2.47.1

#1 lore raw
Quoted 19 lines · Kumar Kartikeya Dwivedi

The decode_tail function now takes a qnode argument to use distinct qnodes for qspinlock and rqspinlock. Add a __percpu tag to avoid warnings and errors and reflect that the qnodes are per-cpu. There is no actual bug here as the value was not dereferenced directly and passed to per_cpu_ptr, so this is just to suppress the warning/errors at compile time.

Fixes 06988910ee2d ("locking: Move common qspinlock helpers to a private header")
---
 kernel/locking/qspinlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock.h +0 -0
index d4ceb9490365..f63b6e04ddd4 100644

kernel/locking/qspinlock.h static inline __pure u32 encode_tail(int cpu, int idx) · line 62

Quoted 5 lines
kernel/locking/qspinlock.h +1 -1
@@ -59,7 +59,7 @@ static inline __pure u32 encode_tail(int cpu, int idx)
        return tail;
 }
 
-static inline __pure struct mcs_spinlock *decode_tail(u32 tail, struct qnode *qnodes)
+static inline __pure struct mcs_spinlock *decode_tail(u32 tail, struct qnode __percpu *qnodes)

Applied. Decided to squash it in and adjusted to
new line to make it shorter.