Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp104158lqe; Tue, 26 Mar 2024 23:16:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV04bgqlemLRnNMxlMiFLygywjVh5NAwyp6zkB1dxBnbikjlyQnCFs35Z+E+roIVwEqyTYqGoNJVP3UXqjDH2+TD8s4UK6GrxyvNpKTfg== X-Google-Smtp-Source: AGHT+IETdLM/5OwuTZO1Zzx9oF13iqeJi9VplMw91UlNOxFigCZT+QhsVfUVuilPOtQkbO9HsDid X-Received: by 2002:a05:6358:569a:b0:17f:5b3d:1611 with SMTP id o26-20020a056358569a00b0017f5b3d1611mr2016218rwf.11.1711520181144; Tue, 26 Mar 2024 23:16:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711520181; cv=pass; d=google.com; s=arc-20160816; b=Er1INvl+qyeCVLzjPclCSTeVVFEjhuWhOt/jiZvRQrQDhjzv+5s9mrfaMjaDoqn+9r il+GbJ52oiJ6jllKPQyglw1ze3m4ySLjTHqyfhFqxFiC6dl2dvF98uqOEfJV+fTGEDrY hdWJazo1E+F0XzsUHWfOZ9a1yj0Z1rAdKnJOV7bLiWv4tBXYlow6p2xHsJJdCDIRW5Ns iQUnbl0n9b7peyKoNCzkbOcMsRihY1tp3K6vH0CZGku4pbih2dlayBfHnVsyv6mzvA35 Ig0HuefzeBqnzzWnIbW89ankjEfBqv+0Tjkb+iwpkeOwmieK8u3HPZHrNq99hasfRuqS E/bQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=3kGrOBgnau6vlPoQysPMrILfu8WUrfgT3mQotZjW+mc=; fh=CxKHcY0wxDbwy8UpaH4anWgrHW5FL+805Ic2vsuYWjI=; b=xXI8xVi0R3OMJBKlSjD3UdOIDwgOp0jjUu9GCosThKdYwpeqTpge3/PR7GywUnuHcE c+bTkLDXQ8STIwksVCuWGSuXvzYn3agKJm+TFB4LSnPzATmWiRFDaANKAtnjnnA3nK+d HeH01XfdQ2Wj1RwMBFs3MiBLUQkfeSSoTZU1Wo7kBxIhJ+GDFx4YwEkJ+wkjk/+Jfwyv udHYYxQbl2OGDHSJ+TZ7gufVbS3rEEGz0xeAtlcdAI8xDzs5hLfxQ/VPX58xBgxL7N38 W0UVns5lrDbcmZ0+lGEhOxvgnTggspDKWCYo67IlVMJAYLBYF4c1cSDnQQrHUTtRASxH xc+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Xo7vTBJi; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-120362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120362-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k21-20020a63d855000000b005dbec216167si10753493pgj.614.2024.03.26.23.16.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 23:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Xo7vTBJi; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-120362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120362-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C8C812A280B for ; Wed, 27 Mar 2024 06:16:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C8CF1C6B4; Wed, 27 Mar 2024 06:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="Xo7vTBJi" Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E06FE171CC for ; Wed, 27 Mar 2024 06:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711520174; cv=none; b=jYROhqtVorZwJnzYJ26Ubuini4vIw5oOpk3b6SEcGeqFD/gaioGJkNtDueYTHw5zLyTf/qH3zxqKub7OQZm6wfImgUtiZY0T+UbnnSkRv0x0vK7fsL14qk+Q1bSLNcix2eqEKejViy+91p7cV8zYeD96Ln/LhSDK1XRrrfNibVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711520174; c=relaxed/simple; bh=YyCynSucS6U+XPV2fYpF5SbSkiOgoxVK7j+SNkVIXVY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=vBe2iqxK+3vHkM6nTZj162zbhyJbfkCQYauIGIRa8CnFE76jrKlOLsm/n9XcRNBCQux5CfDhxnrBJ+J+55RcmuUxFlgF7WGT1HjHrYlCKhOAMCdmHUhAS3HuLHoji3SS2YVqxAGezdX3ed6Ph2gZPNos4sDAp28YJpf6k/PwcA4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=Xo7vTBJi; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-21e45ece781so4061310fac.0 for ; Tue, 26 Mar 2024 23:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1711520171; x=1712124971; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3kGrOBgnau6vlPoQysPMrILfu8WUrfgT3mQotZjW+mc=; b=Xo7vTBJiMIrDouqFE+FKsMNW6/GGYMWnBCJIkYBkCVZGf3ChDpEoLWVKVZydY40yYM I8ZN4t/UXJoRW45dH2HeQksFe6XLhJa5f/adLc8Vo53dkiXb7Cg/i1Ixz8IklkFc1gfz jDngskszo85sjPdTp2izVlwC6DdU4YSi2p7UYJy1hO1wqaV5lr6brSSGYs+lWLnFNslx 0gxRZHUIVVCPB7nduFX6aHNFj2FsF6yPPVmoc9JcV+lQMJkOOnX1Cbxiz8mv2SbIOi7L C9bKK6w40Bd53mLpSjn1XfkvrwLncokb2zp1WEGda7pHCRuc/zDhd3uIq4al2TRK+krk 5PKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711520171; x=1712124971; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3kGrOBgnau6vlPoQysPMrILfu8WUrfgT3mQotZjW+mc=; b=fmu67u+mKq7wSpihvHAWSqQy9ofQI1sPBEecY+2qbjn+I1eGnZruyd5JnBVNRTMN0J /51aBe9+wQ8STk9GNjDRN8itqH48aXbXtezIce8lAICrbp2rjrhofmyayD9cN5UZqZxT QMK7ALZSzubHBF5mozU+gdXFa7+G+FLDn1hJJQBnRe2BDahd4lTemZrnaUwBxI6AfXk+ ErWv4s5AktdSuebpJZWL2S9HxwCoWfHFpoAuE5uxr3GprhLrZUetrhObr8aIjjlKy5PT ZluS6/8gv3L0hXrr6gYJF2X1caDQSPV43NnvTHyIrIFV7F4FLRimo4db9MV9pdAFYRy1 wASA== X-Forwarded-Encrypted: i=1; AJvYcCWyWwu6CLNN46ScfGCDay+h/AJKnZGbVC52WN0udLHzReW6OQy2y47Lv/TDC4zBavKwMw7jzmxnS9gIBh+BYId1zlo/bbHp4VjeWXjc X-Gm-Message-State: AOJu0YzzOtDdrfw4k5ub1LkvFhylLN40PsR8tKL8LgZdZu6BXltLhtBN DVbQR25qsg7TIB0Dg+DFipvS/y4yhIcQ1MMF9a6mVZ4swVzuvqI6J2gSAAVpiyYAPbpDQFfwG7C asZdIduKzeyqXhga5wCLRdkmqdqjXPL751jBZ7w== X-Received: by 2002:a05:6870:c0c4:b0:229:ec0e:7361 with SMTP id e4-20020a056870c0c400b00229ec0e7361mr1762070oad.29.1711520171010; Tue, 26 Mar 2024 23:16:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327045035.368512-1-samuel.holland@sifive.com> <20240327045035.368512-6-samuel.holland@sifive.com> In-Reply-To: <20240327045035.368512-6-samuel.holland@sifive.com> From: yunhui cui Date: Wed, 27 Mar 2024 14:16:00 +0800 Message-ID: Subject: Re: [External] [PATCH v6 05/13] riscv: Only send remote fences when some other CPU is online To: Samuel Holland Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Samuel, On Wed, Mar 27, 2024 at 12:50=E2=80=AFPM 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, F= LUSH_TLB_NO_ASID); > else > on_each_cpu(__ipi_flush_tlb_all, NULL, 1); > -- > 2.43.1 > From a perceptual point of view, the modification here is not necessary. There is such logic in on_each_cpu(). Can you share your test data? Thanks, Yunhui