Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp116781lqe; Thu, 4 Apr 2024 01:04:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFu3uo3zwoN4b97tiA5XwinzIU/3pVk3Cr3NRac/hRRieO+JS4FMenUDexe8Gka5TNMwl8u2Le234WvjZpcr4O+FjUgrSBpClFQWiUaw== X-Google-Smtp-Source: AGHT+IG5f0j9rN7mVrUmalRe0/wxgp4wgrSkCZyeTDrzN6Tz3nPUrs4JEN/si9hkO+8cd/tLv797 X-Received: by 2002:a17:906:3b11:b0:a46:ec44:477c with SMTP id g17-20020a1709063b1100b00a46ec44477cmr888806ejf.41.1712217875173; Thu, 04 Apr 2024 01:04:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712217875; cv=pass; d=google.com; s=arc-20160816; b=KsI1Sqg/QLJ+ZPj8yFc8ZBOK2S1FskRNcFviwPNVidnowWNMQjUbv/0q5D8bia1lKJ M5ngro3I69gp4Aq6iEbiIIjquFxXR/C97iBH846drwGO2js8towDgRwO8WCftu32FMGQ 40XaI6YohoTDlUe8UtfaZx0WohITHj+YsIlxlnW+UbJWlB8J4ep+EaYLrL2CQV0dE4bq cDnQqsDhQKGxiatJMxe8+WfyVjFH4u/Vr7/lmZY6jLAe4b3abN3edjK8PEdlfh7okpAj teUU60wWZq8NFtkg0DnFH0ohloTUO8Y3ySRgz8UXG98ywP/CRz/d1Qpl7vkwbUOrug9G sjBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ZflYejt5YFI5d7U1xZXMaufx7pxYzeyLA32aM805nBs=; fh=kIe2jktUoKPsM711s1HC99xzVIFcov+vFj5zb5YF11g=; b=n6ZGLEYN/jHROm2qY5z9zmAIkj3oi3nwI7GSAhJrtcHffMExNWdyKMIvRGvITCLchI bxgRX0PT6uDJNpdykEC5AkEt5OtaMUb+nBXOdIVn5GkcbywbppWORc8KiplsNVmFmwYE 4kgSypix8d6642wNXfxv5LPmqOQ4zq0RvCWunlb6d2OT0vkbGzGCR7tw2+MAMrVrLFPM ZlUXsLCENxI6QVBlWAMnAT195wI7Ecc7WrmvHrm1LgxHk2gnkPHxknOX2WZCwHz2O1Vt Xv0nWz+llMbMrTpr3iLJn7nMj7gXqdSWRHWx9/x082oUGaeQrQ06iPPVSQaBZ9fRPBYy HITg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-131075-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131075-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x23-20020a170906b09700b00a4694013bfesi7609599ejy.355.2024.04.04.01.04.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 01:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131075-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-131075-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131075-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B464E1F293B3 for ; Thu, 4 Apr 2024 08:04:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D5A760ED0; Thu, 4 Apr 2024 08:04:19 +0000 (UTC) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CA865D73A for ; Thu, 4 Apr 2024 08:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712217858; cv=none; b=p2BIBfryHfoOIr1mqAxRH66edi4wBUxPKI55n+ytpFRT0RT00ZOd165i5dgBnb/WW7MPvEE4ZTn9A4GTaW6sIRYQ2HFf5lvzBGPWux8ROnuyWwlVkrG+44z3hzF9R4+LF2TfgCBX+VL5xaX6M3xy8J7mnX8e4lPxt8Zc9pkZJ/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712217858; c=relaxed/simple; bh=Ek5fSmDXp78lw8Lyzp8NrGztbcnXisYx47LKbLmVKvI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AIgqBCyo14PkS1eWG81GB8imvjkUV4Zt74YkjCXywaQteDfBgA4yt6eYi5zrQ6AeixkJF9+4B08VTg2IO5ixLbgNpme1Lswbhr7gAcZ8swD2oyeGBLGUuIGJ8ywMElXDEmkUFUlKNy0vJoQKORT3nST9npxICm8MKwuonun9qOI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 54BBAE0011; Thu, 4 Apr 2024 08:04:06 +0000 (UTC) Message-ID: Date: Thu, 4 Apr 2024 10:04:05 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 05/13] riscv: Only send remote fences when some other CPU is online Content-Language: en-US To: Samuel Holland , Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang , Yunhui Cui References: <20240327045035.368512-1-samuel.holland@sifive.com> <20240327045035.368512-6-samuel.holland@sifive.com> From: Alexandre Ghiti In-Reply-To: <20240327045035.368512-6-samuel.holland@sifive.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr On 27/03/2024 05:49, Samuel Holland wrote: > If no other CPU is online, a local cache or TLB flush is sufficient. > These checks can be constant-folded when SMP is disabled. > > Signed-off-by: Samuel Holland > --- > > (no changes since v4) > > Changes in v4: > - New patch for v4 > > arch/riscv/mm/cacheflush.c | 4 +++- > arch/riscv/mm/tlbflush.c | 4 +++- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > index d76fc73e594b..f5be1fec8191 100644 > --- a/arch/riscv/mm/cacheflush.c > +++ b/arch/riscv/mm/cacheflush.c > @@ -21,7 +21,9 @@ void flush_icache_all(void) > { > local_flush_icache_all(); > > - if (riscv_use_sbi_for_rfence()) > + if (num_online_cpus() < 2) > + return; > + else if (riscv_use_sbi_for_rfence()) > sbi_remote_fence_i(NULL); > else > on_each_cpu(ipi_remote_fence_i, NULL, 1); > diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c > index da821315d43e..0901aa47b58f 100644 > --- a/arch/riscv/mm/tlbflush.c > +++ b/arch/riscv/mm/tlbflush.c > @@ -79,7 +79,9 @@ static void __ipi_flush_tlb_all(void *info) > > void flush_tlb_all(void) > { > - if (riscv_use_sbi_for_rfence()) > + if (num_online_cpus() < 2) > + local_flush_tlb_all(); > + else if (riscv_use_sbi_for_rfence()) > sbi_remote_sfence_vma_asid(NULL, 0, FLUSH_TLB_MAX_SIZE, FLUSH_TLB_NO_ASID); > else > on_each_cpu(__ipi_flush_tlb_all, NULL, 1); Could this be done directly in __sbi_rfence() instead? Otherwise: Reviewed-by: Alexandre Ghiti