Received: by 10.213.65.68 with SMTP id h4csp644551imn; Tue, 27 Mar 2018 06:15:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELvPmYBTYdpAXsx4RdPMPERSv0NoJk9mx+bAfy3RthkMN/Lcf+yZvMHtVqJUNq9YoYg7MpZn X-Received: by 2002:a17:902:51ad:: with SMTP id y42-v6mr42106871plh.314.1522156542200; Tue, 27 Mar 2018 06:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522156542; cv=none; d=google.com; s=arc-20160816; b=krADXlgMqcWSxIgGw3cT6GOb0WYccun73ugP6+9BUBfnDbFUxTAZJJTUPzPH5GwJ7X 0x88Dw6HeNOZU3jU+SBBSyXyEmx0/IlG0SIYUDK5sYTV/7OzeFUIq/CGJ6lWQdGOT9WH YcviQCI/LeBDUrbSlS2OpkXqJ/jifnIiAAYlwrjBwLGtLzp5CAq3uVaAogY5bsVfYGez LD66NZ6q/Ou3baCxcsYApgRwISw6a58dFESTtFQhL49Nwf6KKsReyIFvZfT/J7IYluNd ifdRCGN/dvKsYa5wWhhnczqHCJlsgkLA7Kb8If0EHx/attEQdwt6Izvh/DAwOdiLQRiN j9dw== 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:arc-authentication-results; bh=nWZnvguZt9712l77Vu8Nz2p1ldEVbu4nl+Go2MR8SQw=; b=KK3o5z6zV9MH6xDSkHuYcVCJkBVgPcmqXY6Py+fxzibK3Yy/qFusFD/3528sPesDms cIu8BZeAWlan6EBK+W+DaoRbOtLuclyPSxv0IvA00iC10yCSfa/Av0wqfz0eRmUVf+l7 D0T/ZB2o97HKMeLamZZeSO81+pbJiVcSC184Mnz25ETJfUjNwXO306o6/D5Ge2Vz/J1s uYIyeQ5EdWS/a7hGlkvIMBAQK9h8y/5oLaiGqdCGSRxxYjx7lZA/b28PzIlRLirNqcik c6VT9RRy7d6hc/5ctHsq01D/FfmBtCW640o0TTCGXgr8VgxmRQ2q6TJ2plfxhDdMXMcE sm9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=l7uUjr12; 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 b8-v6si1223728ple.556.2018.03.27.06.15.12; Tue, 27 Mar 2018 06:15:42 -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=@amarulasolutions.com header.s=google header.b=l7uUjr12; 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 S1752538AbeC0NNt (ORCPT + 99 others); Tue, 27 Mar 2018 09:13:49 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35873 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbeC0NNs (ORCPT ); Tue, 27 Mar 2018 09:13:48 -0400 Received: by mail-wr0-f194.google.com with SMTP id y55so1791231wry.3 for ; Tue, 27 Mar 2018 06:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=nWZnvguZt9712l77Vu8Nz2p1ldEVbu4nl+Go2MR8SQw=; b=l7uUjr12rMZN2gyEOXvtoimKIs2nEyuCCGttjYKzX9ukGpCI5BVF3Gn95+ZAVlyiFY AP5zOMrImrjmAQQlkylmTCP5zWLydaqxDF29aoiwAHha2ezqoI4g0CNb/qtWywq6v+1u u5hfT/a97oqPEXtNZqg7EB+HMZaHkILgYtsNk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=nWZnvguZt9712l77Vu8Nz2p1ldEVbu4nl+Go2MR8SQw=; b=aZaHYUKc5VEcQ2U0r1jkEv0ywCpv8BSxBcwFOseyMmP90uZIqX6jo80fqAKgWYLVgM uQuJf+X+5ZJcZ7MIHJkLWtN/nlKJFL/SZ3VdYxgjsdO9SLcbwp9UBOxK+xgcUjiQE9v/ bmulfhPjgoTSr9TwfxCoP54AdHc0wLNqjCdndE/8R+32JHEw9wq8JpO6BYy0b5jxT7nW pzDrbgofwEgNYvnynSn7th/mHFYtdbCBhGMRw1KwsgkoB2YuFss0zHaTXvCg/E2bma99 OjbfLv2GyShkRH/CjRs6OE/+F8wX1KxQ9GES7KvWVkeRBdZr39Htc63/Dzzv5tSMrvM6 6IRA== X-Gm-Message-State: AElRT7EzLlg2tPSSwbzBbEtKdT1pcNoxrmzrrCXPJ2OLJjvdt1/UYc0Z N2OxaDlwteUU3hHJGWTHwR677Q== X-Received: by 10.223.160.78 with SMTP id l14mr31656432wrl.153.1522156427247; Tue, 27 Mar 2018 06:13:47 -0700 (PDT) Received: from andrea ([213.209.242.222]) by smtp.gmail.com with ESMTPSA id l1sm1257203wmh.25.2018.03.27.06.13.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 06:13:46 -0700 (PDT) Date: Tue, 27 Mar 2018 15:13:39 +0200 From: Andrea Parri To: Benjamin Herrenschmidt Cc: Paul Mackerras , Michael Ellerman , Peter Zijlstra , 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() Message-ID: <20180327131339.GA4278@andrea> References: <1522060667-7034-1-git-send-email-andrea.parri@amarulasolutions.com> <1522109216.7364.30.camel@kernel.crashing.org> <20180327102521.GA7347@andrea> <1522150386.7364.53.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522150386.7364.53.camel@kernel.crashing.org> 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 Tue, Mar 27, 2018 at 10:33:06PM +1100, Benjamin Herrenschmidt wrote: > On Tue, 2018-03-27 at 12:25 +0200, Andrea Parri wrote: > > > 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. > > > > I understand. And I'm grateful for this debugging as well as for the (IMO) > > excellent account of it you provided in 51d7d5205d338. > > > > Said this ;) I cannot except myself from saying that I would probably have > > resisted that solution (adding an smp_mb() in my arch_spin_is_locked), and > > instead "blamed"/suggested that caller to fix his memory ordering... > > This is debatable. I tend go for the conservative approach assuming > most people using fairly high level APIs such as spin_is_locked() are > not fully cognisant of the subtleties of our memory model. > > After all, it works on x86 ... > > The fact that the load can leak into the internals of spin_lock() > implementation and re-order with the lock word load itself is quite > hard to fathom for somebody who doesn't have years of experience > dealing with that sort of issue. > > So people will get it wrong. > > So unless it's very performance sensitive, I'd rather have things like > spin_is_locked be conservative by default and provide simpler ordering > semantics. Well, it might not be "very performance sensitive" but allow me to say that "40+ SYNCs in stuff like BUG_ON or such" is sadness to my eyes ;), especially when considered that our "high level API" provides means to avoid this situation (e.g., smp_mb__after_spinlock(); BTW, if you look at architectures for which this macro is "non-trivial", you can get an idea of the architectures which "wouldn't work"; of course, x86 is not among these). Yes, we do appear to have different views on what is to be considered the "simpler ordering semantics". I'm willing to change mine _as soon as_ this gets documented: would you be willing to send a patch (on the lines of my [1]) to describe/document such semantics? Andrea > > Cheers, > Ben. >