Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7179779rdb; Wed, 3 Jan 2024 07:10:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYpsHn7q0ry0YDRtsQZKYFt1TrS7GWXLYu07ivPzMwdDi6dMBVIaMtfCAHDVeF4NBV0MGl X-Received: by 2002:a05:6870:5591:b0:204:b43:38e9 with SMTP id qj17-20020a056870559100b002040b4338e9mr15001327oac.2.1704294649653; Wed, 03 Jan 2024 07:10:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704294649; cv=none; d=google.com; s=arc-20160816; b=mzv7M6ceE48c8lqWDKfh1SQxadKdzNMSUMAxWaHp7A4RVnkcy2hdlGKzt72FL1pJTJ RYLQxHvEiCslvr9upqeUqTQaNVde4RE82nOUoheY5vLTTt9/Jub4n2/6zQIz2rcKQkqu j5suDAfYqAONdUObkJQboFRvEECYC19OU4v35j29azzicx7b3IK4nsC4p93IsEg6lknF zMsGlbO9ZyuwZk5ttlHiBNRqt48/YcTtd1Lz3OMemJKiFvXjk7zaLP+qeXFBAYail5wC MyDJiJXZzJWEEPwEVYg5ZROyrkczB/InBo6GUnsaE4qnzcrr4j2Paef7fJX3KYpDFzUX Dyaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nr8PVtrtaTMjckH8H7MeI3j5XR2ut8jHz2n9vGAK2Go=; fh=lXRNZPPD/vB2l4adEnq1JQWLoznnU3nAIf33OLw1uzM=; b=INAXFZI1bfTc+saDPeS1MCE+LusXhhhLbu+KAG0lTu66nssPgeKlBZn/1V+Kp0YcTg WCCjyVR64Y61YE+Sf9Gnicd7Al2xfxeI4I9GRsgYSwH5vnhkETsEskiTKgL/y8BDilJS 8E/8Yb/B9sedeHkKx9DUQ90Z+gjqMLF7dr6REFutZOXirgu8x0HKp0mFFZu5TPqSab5w TQTp8Y93QaIwEXjz9x5uc5CkFjHKZZmr9To4dOVHp+bQLLgrR6C8/KwTzvFe05/V/016 p5LC44P2//JeD8JUff8kNShzA4IBN6BasVNq5TaJ5z2lWL9JNA9+RkD5LYOpjzP99zvX OlEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tp7oRgzy; spf=pass (google.com: domain of linux-kernel+bounces-15681-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15681-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y12-20020a67bd0c000000b0046700ac964bsi2025271vsq.616.2024.01.03.07.10.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:10:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15681-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tp7oRgzy; spf=pass (google.com: domain of linux-kernel+bounces-15681-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15681-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 156A91C23635 for ; Wed, 3 Jan 2024 15:10:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFCC01A704; Wed, 3 Jan 2024 15:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tp7oRgzy" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2114D1A718 for ; Wed, 3 Jan 2024 15:10:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E6BEC433C8; Wed, 3 Jan 2024 15:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704294640; bh=NkRRzJNtkIaqD3FKoHNbeRWvalOUr4JWu2/1EIqaoKg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tp7oRgzysGa93W3YGZKULOpHNoDKsXBqBy7chiOvQRihBgJAypspwLbYkCRdMiPS1 CG2X/bi28oBBjMJHWtgVvI62dmPslcmBad0n8Pbi/SSbAjHtVk6TRZv935ARL7q6oM vax735NBXLFbcWKHhd4LlzguyudA7vws5JovhRyOFYNwdRSI+aEoqs73RZApf6Em2s jHX0dEp9SRH8GF/4vXA/HVrRoXsmyrEPU9v0IsyLLWD3CxgcflqJ8imWZunQyfM8KZ LOLlWOcdGlDfjBpcKFsym0/Nzet30kg3hM8pkILeE01GnkyOGInXsc8j3HYsmqfKPs EDq1ZBCvZqcKw== Date: Wed, 3 Jan 2024 22:57:58 +0800 From: Jisheng Zhang To: Samuel Holland Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti Subject: Re: [PATCH v4 04/12] riscv: Only send remote fences when some other CPU is online Message-ID: References: <20240102220134.3229156-1-samuel.holland@sifive.com> <20240102220134.3229156-5-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240102220134.3229156-5-samuel.holland@sifive.com> On Tue, Jan 02, 2024 at 02:00:41PM -0800, 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 > --- > > 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 47c485bc7df0..f7933ae88a55 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) with patch5, I think it's better to short cut for !SMP, I.E if (!IS_ENABLED(CONFIG_SMP) || num_online_cpus()) < 2) so that the UP case can avoid a atomic read and check > + 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 2f18fe6fc4f3..37b3c93e3c30 100644 > --- a/arch/riscv/mm/tlbflush.c > +++ b/arch/riscv/mm/tlbflush.c > @@ -73,7 +73,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) ditto > + 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); > -- > 2.42.0 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv