Skip to contentSkip to conversation

powerpc/powernv: recheck lock bit in core_idle_lock_held after lwarx

RFC PATCH In review Li Zhong 2 participants 3 messages Oct 25, 2016 PowerPC

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

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

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.

---
 arch/powerpc/kernel/idle_book3s.S | 2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/kernel/idle_book3s.S +2 -0
index bd739fe..ce07b3f 100644
@@ -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
 
 /*
Signature · 1 line
1.9.1
#1 lore raw
Quoted 8 lines · Li Zhong

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.

author
#2 lore raw
Quoted 7 lines · Paul Mackerras

=20

Quoted 3 lines · Li Zhong

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 2 lines
Quoted 2 lines

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 2 lines
Quoted 2 lines

=20
This patch rechecks the lock bit after lwarx, and go back to loop if =

it

Quoted 4 lines
Quoted 1 line

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

Quoted 4 lines

=20
Thanks,
Paul.
=20