Re: [PATCH 04/13] locking/qspinlock: move pv lock word helpers into qspinlock.c

From: Waiman Long
Date: Tue Jul 05 2022 - 15:35:15 EST


On 7/4/22 10:38, Nicholas Piggin wrote:
There is no real reason not to keep all the bit manipulation together.

Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx>
---
kernel/locking/qspinlock.c | 107 ++++++++++++++++------------
kernel/locking/qspinlock_paravirt.h | 51 -------------
2 files changed, 63 insertions(+), 95 deletions(-)

diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
index 7360d643de29..8f2173e22479 100644
--- a/kernel/locking/qspinlock.c
+++ b/kernel/locking/qspinlock.c
@@ -141,7 +141,24 @@ struct qnode *grab_qnode(struct qnode *base, int idx)
#define _Q_LOCKED_PENDING_MASK (_Q_LOCKED_MASK | _Q_PENDING_MASK)
+/**
+ * set_pending - set the pending bit.
+ * @lock: Pointer to queued spinlock structure
+ *
+ * *,0,* -> *,1,*
+ *
+ * The pending bit is used by the queue head vCPU to indicate that it
+ * is actively spinning on the lock and no lock stealing is allowed.

The pending bit has different usage in pv and non-pv cases. The description here refers to the pv case. For non-pv, it is used to avoid loading the the extra node cacheline in likely contended case.

Cheers,
Longman