Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp511788ybg; Sun, 26 Jul 2020 11:40:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNrXc9Yg4ipbG+QXrvJ3zBJMXF3uXsjpQKx8lEM06uwXO+IFElIq0chDtERiw3mnT7co33 X-Received: by 2002:a17:906:970a:: with SMTP id k10mr2513384ejx.189.1595788831842; Sun, 26 Jul 2020 11:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595788831; cv=none; d=google.com; s=arc-20160816; b=a4FkfOvIBHmYh2L1fLPBRJ/rYOBJY+ITIQNoXe1iAwAa//ilNfzDOJxhxrOXGdo603 vB48p4iILJzs8D4jmJKgZysWuAwbGmW6KpDkZ+/cEfwrCzOe/o474kHawkUeLA3crAEx 5ixMEP9rRrFZBGnN25seBfROhe2RFAg3csjkszClIAqTUu3cOAljbyEdKHhZOfspz4O9 9d//D+jFS2VKSpJ/TC4aVqZBFbNlvU9+ghUuTL9Y0ip2P8Hds/nb+Hf+TjmoBHcgheEl vJ7whvhK72NPX/5ymtacdAaQbpQFo3Dj9OVsvpLRvBfTe8l15WrOoxPgWuC7ILgJ0Sai 1wtw== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=JnUU93WKUKWrXbn9kgNlLm9JHar+29seJwT67nss/Ow=; b=BLVH8nXKb9k9T71MkH7QmXiVIYPdBhrU61bPT9BrK0ogy95bKUZkNZbdc67rl6zEue qkebBTbdk3+hM9nkfXaQsjSB4bdaS6oxIzxICXriMEg7aYIQrt+lKnp6jSR2ozlnMytT QlBRxvzOt1eh2+kvaKwV42gCzrPT7P+oEC6LXuSpQmB8d9Vv5CBmHw7p9rHZaxjK3lmw U3DGwuc+c1Twj6PFtZNAhNgtZ5l7vSGv1Kek1Kc/0fKGvcXzH0FU0iWSVfkUb471TH53 wlkGbU4cp2EPsX3RK+71rF1uNlIwjyQD17wnML5aQBb3OI6aSHbX8jPVt4Z7EZB+78mL N9cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nG3iBDXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si4275194edy.39.2020.07.26.11.40.10; Sun, 26 Jul 2020 11:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nG3iBDXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727840AbgGZShF (ORCPT + 99 others); Sun, 26 Jul 2020 14:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbgGZShC (ORCPT ); Sun, 26 Jul 2020 14:37:02 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1AD2C0619D2 for ; Sun, 26 Jul 2020 11:37:01 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id i92so660146pje.0 for ; Sun, 26 Jul 2020 11:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=JnUU93WKUKWrXbn9kgNlLm9JHar+29seJwT67nss/Ow=; b=nG3iBDXv6+813nvKzqFi/7D1yujtCUMoArCy+DcXTmZ4I+ju4cUuNU7FW7uA5qY49Z ahZqNfeUh/0ve0ztq5LULa1EdAVrpXYDBPr6fNriCImZTYtzcyey4UvcFxtlbUZhf6K+ dBMM/A/8iLFwllKgkA9vjtMBbEawjuQICs3wmlYinNGG/5h0dW1M5DxVk99vKXZn0XVy ANwa+nPHlWm3+6Hw/FXfkx2MdNSxPUaAHqWd8lwl6ZvyE3dpmGdtRQ3AODmaQRqLyPtY 6lPlKthvNWbkEmlUgXvS6Y34a9+GTfX+QnlxmES6i6gOxi4ETMgasw0oEqkeVJZv4+jy 7hgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=JnUU93WKUKWrXbn9kgNlLm9JHar+29seJwT67nss/Ow=; b=uf3Smh9z+JS+2M63icAHhbMAQx0GtJFlU6sbKE970v9PNujJ5wu79KzptsEkvAwcYl ocYdePNh3bkrJc5yB2xlaFEk60+BrqOGRSH/DDBA5bmSBfXBYY784z18zrCiRJxuFLGT iaQTNdW1AR3hXPYe2U+KRoLn9YlYoJhhH3FEiYbx6QHK2hRSWyDVRpX5Mmdfxx68sRD8 wX4o68TEKbLgJ6GDB2yPpBoc1rf4MfSZbbKzMaOhOLFzjeWQm9ZpUzw2QNAZN6w/mczO KBqAXdxaWIlgMUEjG2wOONiF/N3MbUJOYvx6H5gMqWaNJmQg6tqNCjiq9XjA/j7cQINC 42Qg== X-Gm-Message-State: AOAM5304GUdwVmN7w/uZX5v8X63NZLnZjQK1NgaRiOJNCBeRhv/hNgIG DUjLOO/ZZncuxEa/1Z3/Y43XfvJYkeA= X-Received: by 2002:a17:90a:bf04:: with SMTP id c4mr2738242pjs.149.1595788619210; Sun, 26 Jul 2020 11:36:59 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id c125sm11977747pfa.119.2020.07.26.11.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 11:36:58 -0700 (PDT) Date: Sun, 26 Jul 2020 11:36:58 -0700 (PDT) X-Google-Original-Date: Sun, 26 Jul 2020 10:59:11 PDT (-0700) Subject: Re: [PATCH AUTOSEL 4.19 18/19] RISC-V: Upgrade smp_mb__after_spinlock() to iorw,iorw In-Reply-To: <20200720213851.407715-18-sashal@kernel.org> CC: linux-kernel@vger.kernel.org, stable@vger.kernel.org, sashal@kernel.org, linux-riscv@lists.infradead.org From: Palmer Dabbelt To: sashal@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Jul 2020 14:38:49 PDT (-0700), sashal@kernel.org wrote: > From: Palmer Dabbelt > > [ Upstream commit 38b7c2a3ffb1fce8358ddc6006cfe5c038ff9963 ] > > While digging through the recent mmiowb preemption issue it came up that > we aren't actually preventing IO from crossing a scheduling boundary. > While it's a bit ugly to overload smp_mb__after_spinlock() with this > behavior, it's what PowerPC is doing so there's some precedent. > > Signed-off-by: Palmer Dabbelt > Signed-off-by: Sasha Levin > --- > arch/riscv/include/asm/barrier.h | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/barrier.h b/arch/riscv/include/asm/barrier.h > index d4628e4b3a5ea..f4c92c91aa047 100644 > --- a/arch/riscv/include/asm/barrier.h > +++ b/arch/riscv/include/asm/barrier.h > @@ -69,8 +69,16 @@ do { \ > * The AQ/RL pair provides a RCpc critical section, but there's not really any > * way we can take advantage of that here because the ordering is only enforced > * on that one lock. Thus, we're just doing a full fence. > + * > + * Since we allow writeX to be called from preemptive regions we need at least > + * an "o" in the predecessor set to ensure device writes are visible before the > + * task is marked as available for scheduling on a new hart. While I don't see > + * any concrete reason we need a full IO fence, it seems safer to just upgrade > + * this in order to avoid any IO crossing a scheduling boundary. In both > + * instances the scheduler pairs this with an mb(), so nothing is necessary on > + * the new hart. > */ > -#define smp_mb__after_spinlock() RISCV_FENCE(rw,rw) > +#define smp_mb__after_spinlock() RISCV_FENCE(iorw,iorw) > > #include While I don't think it hurts to have this, IIRC we didn't have the generic mmiowb spinlock stuff back then so it doesn't really fix the problem. That said, I'm pretty sure 4.19 doesn't make it to userspace so backports are really an academic discussion at this point. Whatever's less work for everyone is fine on my end for 4.19.