Received: by 10.213.65.68 with SMTP id h4csp132822imn; Mon, 26 Mar 2018 17:09:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELugpXbWghl2w3awez7AP3Fn5OFwGObvnHXYbILU5D1ffcvKp27z+q0yY6dIT9WClxJQncb4 X-Received: by 2002:a17:902:207:: with SMTP id 7-v6mr43584939plc.261.1522109370649; Mon, 26 Mar 2018 17:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522109370; cv=none; d=google.com; s=arc-20160816; b=H+2Z8NYDLsWODILUhsdcvQEV5WwNX9AIHU51BRlJ5NKKq4IypDbi0eWZYsdqND+7tx FErQSvXRWqizO5qFQDynvogbUvEVs8brAmylArVkUb9qHHeDdHDaZUxTSDcAuaCOSpCi 9/2DZdtaA9YSiPrIsfQXrOIuqKU8XofWiR+hMU6wORy8z3ldYQX3SA6qhxrStIm0/noj QSxd+iDfhNqZBhLhec/MLFvrVGwosh2Gu2qwuanlUi5Uw8lAVtGqKlgeoFhNz48v6wxp oLilFh6aEdAQei4qLMpjs0ua4RHsGeMk1HfwBDS2y+w2g3dTOHhsosA5TGYJEbDWp5Nn VgJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=HHHauvKjEe9/5Q3TgtPjGLRHijtZfiixGIseQLLreY4=; b=0fyct+s3uo+R1u4NydqvsR4f407knaPpHqIb8Sk5B2gK3SoWm78KVwqOvlWx3+wGX1 ENQ0rHAAGgjXYwL78UoefXPlcpgS5NyfpDxvuDtwCF9CewC/fx09bf7Sk+pzKnXDHuh6 XO1zUV7tWAvN3QnHGnlseqVg6b4/vodBUSpy+DZoiXE5AwhqAh+SQFbpuUZ2wLdpBdyo BSwkDcgOjl7wLpftmevn7Zca7TD5scQcYogJPn7eYYtdrK6g/9uPlix8Zn+bamN2qJGz k1Y67tjMVbW/KnsEmYFjCGmgFbpRgwNPA6Cgn7UfABXyoXcPlDXVN7Ax2OsPJvRkcCqt EW3w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si8754152pfi.355.2018.03.26.17.09.16; Mon, 26 Mar 2018 17:09:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751713AbeC0AH6 (ORCPT + 99 others); Mon, 26 Mar 2018 20:07:58 -0400 Received: from gate.crashing.org ([63.228.1.57]:34537 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751160AbeC0AH5 (ORCPT ); Mon, 26 Mar 2018 20:07:57 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w2R06vQU023979; Mon, 26 Mar 2018 19:06:58 -0500 Message-ID: <1522109216.7364.30.camel@kernel.crashing.org> Subject: Re: [PATCH for-4.17 2/2] powerpc: Remove smp_mb() from arch_spin_is_locked() From: Benjamin Herrenschmidt To: Andrea Parri , Paul Mackerras , Michael Ellerman , Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Linus Torvalds Date: Tue, 27 Mar 2018 11:06:56 +1100 In-Reply-To: <1522060667-7034-1-git-send-email-andrea.parri@amarulasolutions.com> References: <1522060667-7034-1-git-send-email-andrea.parri@amarulasolutions.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-03-26 at 12:37 +0200, Andrea Parri wrote: > Commit 51d7d5205d338 ("powerpc: Add smp_mb() to arch_spin_is_locked()") > added an smp_mb() to arch_spin_is_locked(), in order to ensure that > > Thread 0 Thread 1 > > spin_lock(A); spin_lock(B); > r0 = spin_is_locked(B) r1 = spin_is_locked(A); > > never ends up with r0 = r1 = 0, and reported one example (in ipc/sem.c) > relying on such guarantee. > > It's however understood (and undocumented) that spin_is_locked() is not > required to ensure such ordering guarantee, Shouldn't we start by documenting it ? > guarantee that is currently > _not_ provided by all implementations/arch, and that callers relying on > such ordering should instead use suitable memory barriers before acting > on the result of spin_is_locked(). > > Following a recent auditing[1] of the callers of {,raw_}spin_is_locked() > revealing that none of them are relying on this guarantee anymore, this > commit removes the leading smp_mb() from the primitive thus effectively > reverting 51d7d5205d338. I would rather wait until it is properly documented. Debugging that IPC problem took a *LOT* of time and energy, I wouldn't want these issues to come and bite us again. > [1] https://marc.info/?l=linux-kernel&m=151981440005264&w=2 > > Signed-off-by: Andrea Parri > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Linus Torvalds > --- > arch/powerpc/include/asm/spinlock.h | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h > index b9ebc3085fb79..ecc141e3f1a73 100644 > --- a/arch/powerpc/include/asm/spinlock.h > +++ b/arch/powerpc/include/asm/spinlock.h > @@ -67,7 +67,6 @@ static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock) > > static inline int arch_spin_is_locked(arch_spinlock_t *lock) > { > - smp_mb(); > return !arch_spin_value_unlocked(*lock); > } >