* [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'
@ 2020-03-26 20:37 Leonardo Bras
2020-03-26 21:40 ` Paul Mackerras
0 siblings, 1 reply; 5+ messages in thread
From: Leonardo Bras @ 2020-03-26 20:37 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Leonardo Bras, Allison Randal, Greg Kroah-Hartman,
Thomas Gleixner
Cc: linuxppc-dev, linux-kernel
spin_until_cond() will wait until nmi_ipi_busy == false, and
nmi_ipi_lock_start() does not seem to change nmi_ipi_busy, so there is
no way this while will ever repeat.
Replace this 'while' by an 'if', so it does not look like it can repeat.
Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
arch/powerpc/kernel/smp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index ea6adbf6a221..7c904d6fb4d2 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -473,7 +473,7 @@ static int __smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *),
return 0;
nmi_ipi_lock_start(&flags);
- while (nmi_ipi_busy) {
+ if (nmi_ipi_busy) {
nmi_ipi_unlock_end(&flags);
spin_until_cond(!nmi_ipi_busy);
nmi_ipi_lock_start(&flags);
--
2.24.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'
2020-03-26 20:37 [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if' Leonardo Bras
@ 2020-03-26 21:40 ` Paul Mackerras
0 siblings, 0 replies; 5+ messages in thread
From: Paul Mackerras @ 2020-03-26 21:40 UTC (permalink / raw)
To: Leonardo Bras
Cc: Benjamin Herrenschmidt, Michael Ellerman, Allison Randal,
Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev, linux-kernel
On Thu, Mar 26, 2020 at 05:37:52PM -0300, Leonardo Bras wrote:
> spin_until_cond() will wait until nmi_ipi_busy == false, and
> nmi_ipi_lock_start() does not seem to change nmi_ipi_busy, so there is
> no way this while will ever repeat.
>
> Replace this 'while' by an 'if', so it does not look like it can repeat.
Nack, it can repeat. The scenario is that cpu A is in this code,
inside spin_until_cond(); cpu B has previously set nmi_ipi_busy, and
cpu C is also waiting for nmi_ipi_busy to be cleared, like cpu A.
When cpu B clears nmi_ipi_busy, both cpu A and cpu C will see that and
will race inside nmi_ipi_lock_start(). One of them, say cpu C, will
take the lock and proceed to set nmi_ipi_busy and then call
nmi_ipi_unlock(). Then the other cpu (cpu A) will then take the lock
and return from nmi_ipi_lock_start() and find nmi_ipi_busy == true.
At that point it needs to go through the while loop body once more.
Paul.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'
@ 2020-03-26 21:40 ` Paul Mackerras
0 siblings, 0 replies; 5+ messages in thread
From: Paul Mackerras @ 2020-03-26 21:40 UTC (permalink / raw)
To: Leonardo Bras
Cc: linux-kernel, Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev,
Allison Randal
On Thu, Mar 26, 2020 at 05:37:52PM -0300, Leonardo Bras wrote:
> spin_until_cond() will wait until nmi_ipi_busy == false, and
> nmi_ipi_lock_start() does not seem to change nmi_ipi_busy, so there is
> no way this while will ever repeat.
>
> Replace this 'while' by an 'if', so it does not look like it can repeat.
Nack, it can repeat. The scenario is that cpu A is in this code,
inside spin_until_cond(); cpu B has previously set nmi_ipi_busy, and
cpu C is also waiting for nmi_ipi_busy to be cleared, like cpu A.
When cpu B clears nmi_ipi_busy, both cpu A and cpu C will see that and
will race inside nmi_ipi_lock_start(). One of them, say cpu C, will
take the lock and proceed to set nmi_ipi_busy and then call
nmi_ipi_unlock(). Then the other cpu (cpu A) will then take the lock
and return from nmi_ipi_lock_start() and find nmi_ipi_busy == true.
At that point it needs to go through the while loop body once more.
Paul.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'
2020-03-26 21:40 ` Paul Mackerras
@ 2020-03-26 22:05 ` Leonardo Bras
-1 siblings, 0 replies; 5+ messages in thread
From: Leonardo Bras @ 2020-03-26 22:05 UTC (permalink / raw)
To: Paul Mackerras
Cc: Benjamin Herrenschmidt, Michael Ellerman, Allison Randal,
Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]
On Fri, 2020-03-27 at 08:40 +1100, Paul Mackerras wrote:
> On Thu, Mar 26, 2020 at 05:37:52PM -0300, Leonardo Bras wrote:
> > spin_until_cond() will wait until nmi_ipi_busy == false, and
> > nmi_ipi_lock_start() does not seem to change nmi_ipi_busy, so there is
> > no way this while will ever repeat.
> >
> > Replace this 'while' by an 'if', so it does not look like it can repeat.
>
> Nack, it can repeat. The scenario is that cpu A is in this code,
> inside spin_until_cond(); cpu B has previously set nmi_ipi_busy, and
> cpu C is also waiting for nmi_ipi_busy to be cleared, like cpu A.
> When cpu B clears nmi_ipi_busy, both cpu A and cpu C will see that and
> will race inside nmi_ipi_lock_start(). One of them, say cpu C, will
> take the lock and proceed to set nmi_ipi_busy and then call
> nmi_ipi_unlock(). Then the other cpu (cpu A) will then take the lock
> and return from nmi_ipi_lock_start() and find nmi_ipi_busy == true.
> At that point it needs to go through the while loop body once more.
>
> Paul.
Ok, got it.
Thanks for explaining Paul!
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'
@ 2020-03-26 22:05 ` Leonardo Bras
0 siblings, 0 replies; 5+ messages in thread
From: Leonardo Bras @ 2020-03-26 22:05 UTC (permalink / raw)
To: Paul Mackerras
Cc: linux-kernel, Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev,
Allison Randal
[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]
On Fri, 2020-03-27 at 08:40 +1100, Paul Mackerras wrote:
> On Thu, Mar 26, 2020 at 05:37:52PM -0300, Leonardo Bras wrote:
> > spin_until_cond() will wait until nmi_ipi_busy == false, and
> > nmi_ipi_lock_start() does not seem to change nmi_ipi_busy, so there is
> > no way this while will ever repeat.
> >
> > Replace this 'while' by an 'if', so it does not look like it can repeat.
>
> Nack, it can repeat. The scenario is that cpu A is in this code,
> inside spin_until_cond(); cpu B has previously set nmi_ipi_busy, and
> cpu C is also waiting for nmi_ipi_busy to be cleared, like cpu A.
> When cpu B clears nmi_ipi_busy, both cpu A and cpu C will see that and
> will race inside nmi_ipi_lock_start(). One of them, say cpu C, will
> take the lock and proceed to set nmi_ipi_busy and then call
> nmi_ipi_unlock(). Then the other cpu (cpu A) will then take the lock
> and return from nmi_ipi_lock_start() and find nmi_ipi_busy == true.
> At that point it needs to go through the while loop body once more.
>
> Paul.
Ok, got it.
Thanks for explaining Paul!
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-26 22:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 20:37 [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if' Leonardo Bras
2020-03-26 21:40 ` Paul Mackerras
2020-03-26 21:40 ` Paul Mackerras
2020-03-26 22:05 ` Leonardo Bras
2020-03-26 22:05 ` Leonardo Bras
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.