[RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3604d

3 messages, 2 authors, 2016-10-25 · open the first message on its own page

[RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx

From: Li Zhong <hidden>
Date: 2016-10-25 03:24:45

The core_idle_lock_held loops when the lock bit is held by others.
However, it is possible that after the lock bit is cleared, some one
else sees it first and sets the lock bit. And lwarx loads a value with
lock bit set, and the lock bit may be cleared in the following stwcx.
It is possible the first one is still executing in the critical section.

This patch rechecks the lock bit after lwarx, and go back to loop if it
is set.

Signed-off-by: Li Zhong <redacted>
---
 arch/powerpc/kernel/idle_book3s.S | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index bd739fe..ce07b3f 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -99,6 +99,8 @@ core_idle_lock_held:
 	bne	3b
 	HMT_MEDIUM
 	lwarx	r15,0,r14
+	andi.	r9,r15,PNV_CORE_IDLE_LOCK_BIT
+	bne-	core_idle_lock_held
 	blr
 
 /*
-- 
1.9.1

Re: [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx

From: Paul Mackerras <hidden>
Date: 2016-10-25 04:15:33

On Tue, Oct 25, 2016 at 11:24:34AM +0800, Li Zhong wrote:
The core_idle_lock_held loops when the lock bit is held by others.
However, it is possible that after the lock bit is cleared, some one
else sees it first and sets the lock bit. And lwarx loads a value with
lock bit set, and the lock bit may be cleared in the following stwcx.
It is possible the first one is still executing in the critical section.

This patch rechecks the lock bit after lwarx, and go back to loop if it
is set.
You're quite correct, in fact I posted almost exactly the same patch a
few days ago...  See http://patchwork.ozlabs.org/patch/684963/.

Thanks,
Paul.

Re: [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx

From: Li Zhong <hidden>
Date: 2016-10-25 05:11:57

On 25 Oct 2016, at 12:15, Paul Mackerras [off-list ref] wrote:
=20
On Tue, Oct 25, 2016 at 11:24:34AM +0800, Li Zhong wrote:
quoted
The core_idle_lock_held loops when the lock bit is held by others.
However, it is possible that after the lock bit is cleared, some one
else sees it first and sets the lock bit. And lwarx loads a value =
with
quoted
lock bit set, and the lock bit may be cleared in the following stwcx.
It is possible the first one is still executing in the critical =
section.
quoted
=20
This patch rechecks the lock bit after lwarx, and go back to loop if =
it
quoted
is set.
=20
You're quite correct, in fact I posted almost exactly the same patch a
few days ago...  See http://patchwork.ozlabs.org/patch/684963/.

Forget to check the list before sending =E2=80=A6=20

One minor difference, maybe we can use bne- for the rechecking :)

Thanks, Zhong
=20
Thanks,
Paul.
=20
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help