Received: by 10.213.65.68 with SMTP id h4csp563581imn; Wed, 4 Apr 2018 03:29:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx48jIo5jCBOr08/FpQIVKlxtGAaALLKpbdXN6huiLPDFJ123ozBrBoKTEY3D1Jxi/z09uFMS X-Received: by 2002:a17:902:968a:: with SMTP id n10-v6mr17683422plp.362.1522837792306; Wed, 04 Apr 2018 03:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522837792; cv=none; d=google.com; s=arc-20160816; b=Dl/T0SMUV6jb283lBBDOUvv7mp2kNxRPNTsUixBk64lewYfh3px4ePLPQXrWpElNkt 3xufKi6zMU2TIAELewFsHKu//PJDZCmfmtK9uivaEBrT4ToU6hwPwVsrGRWvzarGn1g2 IRie/ZJNSbhHA3pnvtIii59YaMKo5tCogWEWM+pI65YGh9J074IXsgIALaXMZIyQB/3+ TZrfa7yp9enprmea51t8v0ysAG4/WV2z48ShnEo3+Plnm/h2u8QTFc+xGlMk2luZ+Bkd GQ32kKHvX/ZdZpnX4ipbRB1OK34TVqzpnXaapQU73+Nth0UkqANw0KLtnoXWv6mkF0P/ s82w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=/dNu1SRn2OOYGWUkPZKV2NW61zYldkX2XStZadpV6wI=; b=hRDH/dKvXUo0wPEGdRr3wuxdPGpOy7PFkze4brtlrneObzSEYoR2SYeaR9UVGJ3v/d gCgK1+OrLfAHnD9HIzXuX/yO5aauPG24asyjKJV24RckyQyENb7jyKO14KPgj+njXuhh B+EF1BMxVEYNhxghMPRwSf6aLu43P8IH+P57R7NqzVBWo8ERYkjd8aN8sXyou68qGXoj 5iUM4hPcp+qENvxq9Innf8bw9XhLhHQ14fg+S7D1bLt6RWLwoVii8edR/rEs52kB6j+M rkthg9EK3+Orh0KLjo3zYh1xkrawB1+p3tkBbs8j/rI63F1KsP81GC0ywrkdXoxe0amA N1ew== 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 w11-v6si3200365plq.544.2018.04.04.03.29.38; Wed, 04 Apr 2018 03:29:52 -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 S1751487AbeDDK2P (ORCPT + 99 others); Wed, 4 Apr 2018 06:28:15 -0400 Received: from ozlabs.org ([103.22.144.67]:39549 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeDDK2O (ORCPT ); Wed, 4 Apr 2018 06:28:14 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 40GMcD1Vkhz9s0n; Wed, 4 Apr 2018 20:28:12 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Peter Zijlstra Cc: Andrea Parri , Benjamin Herrenschmidt , Paul Mackerras , Ingo Molnar , linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [PATCH for-4.17 2/2] powerpc: Remove smp_mb() from arch_spin_is_locked() In-Reply-To: <20180328110436.GR4043@hirez.programming.kicks-ass.net> References: <1522060667-7034-1-git-send-email-andrea.parri@amarulasolutions.com> <1522109216.7364.30.camel@kernel.crashing.org> <20180327102521.GA7347@andrea> <87a7us3h66.fsf@concordia.ellerman.id.au> <20180328110436.GR4043@hirez.programming.kicks-ass.net> Date: Wed, 04 Apr 2018 20:28:11 +1000 Message-ID: <87woxnmfk4.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > On Wed, Mar 28, 2018 at 04:25:37PM +1100, Michael Ellerman wrote: >> That was tempting, but it leaves unfixed all the other potential >> callers, both in in-tree and out-of-tree and in code that's yet to be >> written. > > So I myself don't care one teeny tiny bit about out of tree code, they > get to keep their pieces :-) I agree, but somehow I still end up seeing the pieces from time to time :) >> Looking today nearly all the callers are debug code, where we probably >> don't need the barrier but we also don't care about the overhead of the >> barrier. > > Still, code like: > > WARN_ON_ONCE(!spin_is_locked(foo)); > > will unconditionally emit that SYNC. So you might want to be a little > careful. > >> Documenting it would definitely be good, but even then I'd be inclined >> to leave the barrier in our implementation. Matching the documented >> behaviour is one thing, but the actual real-world behaviour on well >> tested platforms (ie. x86) is more important. > > By that argument you should switch your spinlock implementation to RCpc > and include that SYNC in either lock or unlock already ;-) Yes! Unfortunately performance is also a thing :/ I ran the numbers again, switching to sync on unlock is a 30% hit for an uncontended lock/unlock loop. Which is not going to make me any friends. > Ideally we'd completely eradicate the *_is_locked() crud from the > kernel, not sure how feasable that really is, but it's a good goal. At > that point the whole issue of the barrier becomes moot of course. Yeah that would be good. The majority of them could/should be using lockdep_is_held(), though there are still a handful that are actually using it in non-debug logic. cheers