[RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'

Leonardo Bras leonardo at linux.ibm.com
Fri Mar 27 09:05:03 AEDT 2020


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!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20200326/d81e55f2/attachment.sig>


More information about the Linuxppc-dev mailing list