Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2415045pja; Thu, 26 Mar 2020 14:59:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsANqQzzloX0wM8wnwX42ykm5c5h26TJ8EBa8TVETBFVXDSBLuNrBoqaNL2WenU8P18hKHU X-Received: by 2002:a9d:65c4:: with SMTP id z4mr8120870oth.51.1585259967431; Thu, 26 Mar 2020 14:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585259967; cv=none; d=google.com; s=arc-20160816; b=ibBSzlUpPXIBb3sqBdP7KZeVesEL7csaAS/Qkg/ZfVqCbeLUC9HYXD1uWRRKUJ1GIc snxqFsNqPwgHH/VGPWdgvxudg57xyvFcuclwXL0LfSYMhkhQj61MyZf96yCSwljOzGWj j7xkx/NTMxL2EG7JnoXZ7krb0Af3zgEPkPeLrcp3YdpwuEpjf1XxZHcGsSQLOFiiHE3E 3ui6p4cCSTqhMXfsvgIPGJZJxYdkGo7N/rtALf1ioWr6u7KoVy12Ma4x7QN2o56gAazo pGi2XUo/vp5rDCR8vaMGVbB9Wy89d4oeEunLedPo7kGOlJr4k7A7hmMniVe80rvJOOXg MEaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FaLgIgACA4tmmo2anlXGMbcVvuBGVgsdRuCUcQI3t+o=; b=InRL6BQWAcIe+QJ7d9sHd0EQ5VA8pXoTwnDcmFrI+UXrDYorUvpSg54AaeOI+EgDxK 4UXtMtD12GiIWaH4W/+Ft23a1fKCX42qJwsc4VJPyqwo96pYHe7i3iIRAqzOACirlTrx op7rCs7Q9EX+ofwlRz/3AXlYVFC+okYjdBJbWdrT8rDkQsaC4Zop/uaUV8Vgv46Fcnz0 Cqxz1g+xdI5UFyHhzTHdCsJH1TN/2a4AhQwwCt18Fq5uv3Wd+kqvSAZugoEIGh9WUMYn AAK7XgJWmGa79R+tNyUjsvS4enZw6AZW9toICOEkytLrzSNovrab3znIbGL3O4vVdf6w QzWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ozlabs.org header.s=201707 header.b=JMnlHokU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ozlabs.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si1758469oto.169.2020.03.26.14.59.14; Thu, 26 Mar 2020 14:59:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ozlabs.org header.s=201707 header.b=JMnlHokU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ozlabs.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbgCZV6w (ORCPT + 99 others); Thu, 26 Mar 2020 17:58:52 -0400 Received: from ozlabs.org ([203.11.71.1]:52927 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbgCZV6w (ORCPT ); Thu, 26 Mar 2020 17:58:52 -0400 Received: by ozlabs.org (Postfix, from userid 1003) id 48pJls712Wz9sRR; Fri, 27 Mar 2020 08:58:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1585259929; bh=Sf69iWUNrMQgDwyFTyrEPmKhiAksHzMcJ+e9NXva9XM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JMnlHokUFLvdNAUyd3LZd3Bu/BGitZr+URsSji24FWeLJKpN20AGvD98ZM/pZh2wn pM23ZJ+sEfSZwPjY1jGmYzm/KRK+Ejotg3ffuSZlU1XICemP4Mb5DjWePlirfNXZkj SUcrwRH5JsENXTwMmZ+CDyLdRwUufCNMjIwkpxdbKzhnva9bSS4TtC4y4NTIvpaD1n z2+Zzp7g2WQk5Zxxpj9Mq2NCGM7e6ExKfZimRvVOnQ/1L1OsALeqfbNrh7r+KYdyMI yIZjZila19w9omhqFebV2SFHjF+LiLMHNWj6fA/7y8t5T4yGWIE6qhjw+9ZN/Ji5cG HMteGzZrU/vjQ== Date: Fri, 27 Mar 2020 08:40:05 +1100 From: Paul Mackerras To: Leonardo Bras Cc: Benjamin Herrenschmidt , Michael Ellerman , Allison Randal , Greg Kroah-Hartman , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if' Message-ID: <20200326214005.GB9894@blackberry> References: <20200326203752.497029-1-leonardo@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200326203752.497029-1-leonardo@linux.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.