All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx
@ 2016-10-25  3:24 Li Zhong
  2016-10-25  4:15 ` Paul Mackerras
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhong @ 2016-10-25  3:24 UTC (permalink / raw)
  To: PowerPC email list
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, shreyas, ego

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 <zhong@linux.vnet.ibm.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx
  2016-10-25  3:24 [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx Li Zhong
@ 2016-10-25  4:15 ` Paul Mackerras
  2016-10-25  5:09   ` Li Zhong
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2016-10-25  4:15 UTC (permalink / raw)
  To: Li Zhong
  Cc: PowerPC email list, Benjamin Herrenschmidt, Michael Ellerman,
	shreyas, ego

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx
  2016-10-25  4:15 ` Paul Mackerras
@ 2016-10-25  5:09   ` Li Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zhong @ 2016-10-25  5:09 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: shreyas, PowerPC email list, ego


> On 25 Oct 2016, at 12:15, Paul Mackerras <paulus@ozlabs.org> wrote:
>=20
> 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.
>>=20
>> This patch rechecks the lock bit after lwarx, and go back to loop if =
it
>> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-25  5:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25  3:24 [RFC PATCH] powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx Li Zhong
2016-10-25  4:15 ` Paul Mackerras
2016-10-25  5:09   ` Li Zhong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.