Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1443169 > unrolled thread
| Started by | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| First post | 2016-07-14 10:20 +0200 |
| Last post | 2016-07-14 13:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2] locking/pvqspinlock: restore/set vcpu_hashed state after failing adaptive locking spinning Wanpeng Li <kernellwp@gmail.com> - 2016-07-14 10:20 +0200
Re: [PATCH v2] locking/pvqspinlock: restore/set vcpu_hashed state after failing adaptive locking spinning Peter Zijlstra <peterz@infradead.org> - 2016-07-14 13:30 +0200
Re: [PATCH v2] locking/pvqspinlock: restore/set vcpu_hashed state after failing adaptive locking spinning Wanpeng Li <kernellwp@gmail.com> - 2016-07-14 13:30 +0200
| From | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| Date | 2016-07-14 10:20 +0200 |
| Subject | [PATCH v2] locking/pvqspinlock: restore/set vcpu_hashed state after failing adaptive locking spinning |
| Message-ID | <rUK2l-75j-221@gated-at.bofh.it> |
From: Wanpeng Li <wanpeng.li@hotmail.com>
When the lock holder vCPU is racing with the queue head:
CPU 0 (lock holder) CPU1 (queue head)
=================== =================
spin_lock(); spin_lock();
pv_kick_node(): pv_wait_head_or_lock():
if (!lp) {
lp = pv_hash(lock, pn);
xchg(&l->locked, _Q_SLOW_VAL);
}
WRITE_ONCE(pn->state, vcpu_halted);
cmpxchg(&pn->state,
vcpu_halted, vcpu_hashed);
WRITE_ONCE(l->locked, _Q_SLOW_VAL);
(void)pv_hash(lock, pn);
In this case, lock holder inserts the pv_node of queue head into the
hash table and set _Q_SLOW_VAL unnecessary. This patch avoids it by
restoring/setting vcpu_halted state after failing adaptive locking
spinning.
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Waiman Long <Waiman.Long@hpe.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
v1 -> v2:
* adjust patch description
kernel/locking/qspinlock_paravirt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h
index 21ede57..ac7d20b 100644
--- a/kernel/locking/qspinlock_paravirt.h
+++ b/kernel/locking/qspinlock_paravirt.h
@@ -450,7 +450,7 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node)
goto gotlock;
}
}
- WRITE_ONCE(pn->state, vcpu_halted);
+ WRITE_ONCE(pn->state, vcpu_hashed);
qstat_inc(qstat_pv_wait_head, true);
qstat_inc(qstat_pv_wait_again, waitcnt);
pv_wait(&l->locked, _Q_SLOW_VAL);
--
1.9.1
[toc] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-07-14 13:30 +0200 |
| Subject | Re: [PATCH v2] locking/pvqspinlock: restore/set vcpu_hashed state after failing adaptive locking spinning |
| Message-ID | <rUN06-BW-19@gated-at.bofh.it> |
| In reply to | #1443169 |
On Thu, Jul 14, 2016 at 04:15:56PM +0800, Wanpeng Li wrote:
> In this case, lock holder inserts the pv_node of queue head into the
> hash table and set _Q_SLOW_VAL unnecessary. This patch avoids it by
> restoring/setting vcpu_halted state after failing adaptive locking
^^^^^^
> spinning.
>
> - WRITE_ONCE(pn->state, vcpu_halted);
> + WRITE_ONCE(pn->state, vcpu_hashed);
^^^^^^
The Changelog meant so say vcpu_hashed, surely?
[toc] | [prev] | [next] | [standalone]
| From | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| Date | 2016-07-14 13:30 +0200 |
| Subject | Re: [PATCH v2] locking/pvqspinlock: restore/set vcpu_hashed state after failing adaptive locking spinning |
| Message-ID | <rUN06-BW-21@gated-at.bofh.it> |
| In reply to | #1443367 |
2016-07-14 19:26 GMT+08:00 Peter Zijlstra <peterz@infradead.org>: > On Thu, Jul 14, 2016 at 04:15:56PM +0800, Wanpeng Li wrote: >> In this case, lock holder inserts the pv_node of queue head into the >> hash table and set _Q_SLOW_VAL unnecessary. This patch avoids it by >> restoring/setting vcpu_halted state after failing adaptive locking > ^^^^^^ >> spinning. >> > >> - WRITE_ONCE(pn->state, vcpu_halted); >> + WRITE_ONCE(pn->state, vcpu_hashed); > ^^^^^^ > > The Changelog meant so say vcpu_hashed, surely? Oh, there is a typo in changelog, I will fix it. Regards, Wanpeng Li
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web