Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1659297imb; Sun, 3 Mar 2019 02:08:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxzV7CrBiT+7v7o2cBK2nu9X9RzcoGoVmgVSHFBYBox3DNiDdrGaXVdlh5Fr+Z7/xw7vZMn X-Received: by 2002:a17:902:4503:: with SMTP id m3mr14507695pld.35.1551607726120; Sun, 03 Mar 2019 02:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551607726; cv=none; d=google.com; s=arc-20160816; b=OIi8YPswSsMGWcom0EzB94PMxk7n2lw+BZ3QD92YtBajiaOS4iYuj5pXVKbMOIBDwz MzFIkeN7ww5CISFH+KM/Y+m/UzZSAhM6LZ+3lYPlnIdSr0ZXsCDxdOdjmLsbA1gy8V9t HUghBEGJU2F+MoWxSqJTFxMtVERDECfJ9dGKC654bnJ7hf9sqhfhJCfxmJenuGvBBQCT bLY//YjLxMgdm6WtOMS5YRkBbem53cIEfajoBjzqGmyZU6udv+bxcbd0r28ekUXeap9L 9JDl5aoBb35n6W7sKkB5BtMdHiH9rdnarKtjcHM/s5G83P1k8KPuMUhbXuFWR1my+Hfj JXvg== 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:message-id :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date:dkim-signature; bh=8e/W7PnR4rmEtm15we8NhHHmsnEM8GgTneAnV61w9jQ=; b=NnvBArNrc8CASqSAm2gRAmDQSq8xNdTAHACzoHe6Nn8MkNZR56Pwk0AyABX470dLQa o92uysD6oW0AhCNj5j4Fax8PM/0suxgpIiG1q3goozzIyeOHVD+XA5n99W/CyU+pVWVw eDK7G278ZX5ygMes/9BjdnU/6meX7xEwShpzk3li2QC2Ewvsa+fZi2DBspBoPzLgqzn1 gFDpHPzwtAPBor0HDh0G4sAdWxtbSCGWJro+1oziYPl4RisBVsgRFdgiI2JhiaWgBvxB Qgppk8JO/jEnEx4IeMV1m34OX3YUaHc8SwwpmukHzYUY6Q3vZNZiBRp3L/ewJ3VOwEPZ NZOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kxRrUF4I; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16si2696363pgj.27.2019.03.03.02.08.30; Sun, 03 Mar 2019 02:08:46 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=kxRrUF4I; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726090AbfCCKIA (ORCPT + 99 others); Sun, 3 Mar 2019 05:08:00 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46378 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbfCCKH7 (ORCPT ); Sun, 3 Mar 2019 05:07:59 -0500 Received: by mail-pl1-f194.google.com with SMTP id c17so1095995plz.13; Sun, 03 Mar 2019 02:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :user-agent:message-id:content-transfer-encoding; bh=8e/W7PnR4rmEtm15we8NhHHmsnEM8GgTneAnV61w9jQ=; b=kxRrUF4IXFc2cNMmBduGygMy8rmgtRgHhq+imLV+74jWxe+4VYA6HHem8DntRSWhY/ nuDj0gUdUgCvxFowpy9t4erHQ43YCj4Nn20PpYKMbbcRA2SkbUG3DP/6XnmklDYWb6Ng RB7QN1yq3ism7WAq73j5OP598FgmVwQfvPOwPAUhWLl8Wbzq+vrWPej13zf3BvAzuwDM z/7DG/c2Bg7Bewr+wejRdElUGdH8rH7F9zVN9PXklD5jIH33g08Iny7c2ZFxewKzPz9s H+JkKEUjGpk4JccZod1SsCA804me68fuxSs8LaR5xIAi91PUWTucUMQDwjYvX/qZuPrK 5K6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:user-agent:message-id:content-transfer-encoding; bh=8e/W7PnR4rmEtm15we8NhHHmsnEM8GgTneAnV61w9jQ=; b=ha8TRUIK/OpIw9KI0Y0xt7R6SnNrNpIolkb/+Q5Mw1ZN0eCH3RMr4xwqOIZSbNx+2E l5rLNnhUSGmdRdAQxOJ9Aog/uBpvIZCiWyW+PUCQUKFu18iqGOsw1bpU68bLxCwlH1Pp wSpgD+YWXwBWasE17uF0vAS66gmEcO0P4ZS69P27SeJFrTAahssIcSrlasFoyvi1aXM5 mukxJakVQ9PFS9SR12y+6h1172CqvufhMphUosNLLucPO8iVkRe/ZDgLlvq0ea243Ig/ SeCFNMKMPXx/MjmOmRzZjrEGvvxrxERjhDuS7TdKJltHhFEL43QuLdD+L/tr2m4QJBAs qJdw== X-Gm-Message-State: APjAAAWZU6ih7FWSMyEg498Bhu64/XyLAPV8qOeOtM1qqKkazKo1cl6U O4whhTklg0rcu4jUPxQxitegB1wM X-Received: by 2002:a17:902:6b4b:: with SMTP id g11mr14273441plt.92.1551607678901; Sun, 03 Mar 2019 02:07:58 -0800 (PST) Received: from localhost (193-116-74-175.tpgi.com.au. [193.116.74.175]) by smtp.gmail.com with ESMTPSA id 63sm4859744pfy.110.2019.03.03.02.07.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Mar 2019 02:07:58 -0800 (PST) Date: Sun, 03 Mar 2019 20:07:52 +1000 From: Nicholas Piggin Subject: Re: [PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking To: linux-arch@vger.kernel.org, Michael Ellerman , Will Deacon Cc: Andrea Parri , Arnd Bergmann , Benjamin Herrenschmidt , Rich Felker , David Howells , Daniel Lustig , linux-kernel@vger.kernel.org, "Maciej W. Rozycki" , Ingo Molnar , Palmer Dabbelt , Paul Burton , "Paul E. McKenney" , Peter Zijlstra , Alan Stern , Tony Luck , Linus Torvalds , Yoshinori Sato References: <20190301140348.25175-1-will.deacon@arm.com> <20190301140348.25175-2-will.deacon@arm.com> <1551575210.6lwpiqtg5k.astroid@bobo.none> <87tvgkia0k.fsf@concordia.ellerman.id.au> In-Reply-To: <87tvgkia0k.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 User-Agent: astroid/0.14.0 (https://github.com/astroidmail/astroid) Message-Id: <1551607531.yk1v9azmym.astroid@bobo.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael Ellerman's on March 3, 2019 7:26 pm: > Nicholas Piggin writes: >> Will Deacon's on March 2, 2019 12:03 am: >>> In preparation for removing all explicit mmiowb() calls from driver >>> code, implement a tracking system in asm-generic based loosely on the >>> PowerPC implementation. This allows architectures with a non-empty >>> mmiowb() definition to have the barrier automatically inserted in >>> spin_unlock() following a critical section containing an I/O write. >> >> Is there a reason to call this "mmiowb"? We already have wmb that >> orders cacheable stores vs mmio stores don't we? >> >> Yes ia64 "sn2" is broken in that case, but that can be fixed (if >> anyone really cares about the platform any more). Maybe that's >> orthogonal to what you're doing here, I just don't like seeing >> "mmiowb" spread. >> >> This series works for spin locks, but you would want a driver to >> be able to use wmb() to order locks vs mmio when using a bit lock >> or a mutex or whatever else. Calling your wmb-if-io-is-pending >> version io_mb_before_unlock() would kind of match with existing >> patterns. >> >>> +static inline void mmiowb_set_pending(void) >>> +{ >>> + struct mmiowb_state *ms =3D __mmiowb_state(); >>> + ms->mmiowb_pending =3D ms->nesting_count; >>> +} >>> + >>> +static inline void mmiowb_spin_lock(void) >>> +{ >>> + struct mmiowb_state *ms =3D __mmiowb_state(); >>> + ms->nesting_count++; >>> +} >>> + >>> +static inline void mmiowb_spin_unlock(void) >>> +{ >>> + struct mmiowb_state *ms =3D __mmiowb_state(); >>> + >>> + if (unlikely(ms->mmiowb_pending)) { >>> + ms->mmiowb_pending =3D 0; >>> + mmiowb(); >>> + } >>> + >>> + ms->nesting_count--; >>> +} >> >> Humour me for a minute and tell me what this algorithm is doing, or >> what was broken about the powerpc one, which is basically: >> >> static inline void mmiowb_set_pending(void) >> { >> struct mmiowb_state *ms =3D __mmiowb_state(); >> ms->mmiowb_pending =3D 1; >> } >> >> static inline void mmiowb_spin_lock(void) >> { >> } >=20 > The current powerpc code clears io_sync in spin_lock(). >=20 > ie, it would be equivalent to: >=20 > static inline void mmiowb_spin_lock(void) > { > ms->mmiowb_pending =3D 0; > } Ah okay that's what I missed. How about we just not do that? Thanks, Nick =