Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp22831lqh; Wed, 27 Mar 2024 13:32:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEMK+BNtDSk9OsdOlG9QqfD0YuTuShB1x2x/xMsv3BgTZvFAeZeofb0NAUDJiXYZlW6fnEXZscgGR6qRyM/FIOCHkZQhdOek9fdAeqvQ== X-Google-Smtp-Source: AGHT+IHbkSOS+csJZ6cGRMewGYkfQJKvBjSs5KnJQAP1kg1Z6iJ/mopUosQlK69SU5RdoYAHBKyN X-Received: by 2002:a05:6a00:929b:b0:6e6:270a:9303 with SMTP id jw27-20020a056a00929b00b006e6270a9303mr937091pfb.32.1711571529721; Wed, 27 Mar 2024 13:32:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711571529; cv=pass; d=google.com; s=arc-20160816; b=ZOs8m4ebkHMVGMdYHiZ5XhnXSgmRz8B3Z26/Rd/MgMsWZTl13dBcG+Ljh6tp09roz1 hSjmOo1hEeXuM6JlHiMATfGbV43i0N5y1jKUUvNbi4HyNBzOWtWbvRd0ntVKA7i9bDoC IuWQ1a9SeRE7ydfZhiW2l0KAL/ih7oLAqhVf38sJspmOg8ifVFTxuguHUPsWBnS+CjXs O7vKFjZzDoiW8BtuVjSG0gb05LXhfnFikWJ3UztHkcbQP13BpOFVe8NTU+CVdB09dT/a 4S84UtvJ6ibkzUSJRV71q77Alyt/8UFkYMnU0Mmkz/9m0K9UWu9uVDv1+37/iJ2tW58u ye4w== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=NCYK7bXPxC3buWagK44KXlYoaMMqT9xkSSzlJu6d89E=; fh=33iI4LOBbgSKI//mgUWwCflIIHMzrJpK9sb5fq+6ytA=; b=Te1XS5Z3KCt97h2BmZ2YGLR3QEjOsTFTY1m/iBYdqaLyxnmoZvygIqWJKmR43C8OuD Lgdt4qkKwaoy8eikAFF5E+0zCybv6iOfPFu0hx3nYnW7oj1GUL1ba6qn4VsvUY+zFLwA oxMvk5C5UKoKHHOYem5G+tYHW37N7YCNyjDcXfTU8F2wU4g7iDtwxhY117mnt+qDCrX7 FKprlk4eRXdxWd1XO1C+8zwC4uKlj/F/4pVA/If2Sj8ULBCFIqhCJuQz3Rsjzls6XCyy cAsHO99B/meMMKsBo4E1Ij3Ha/pCWRsjE167ywgjgEXHIXApv0fJZfB77Q/wnGJYvn6H 32VQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="EmQs82/6"; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lp16-20020a056a003d5000b006eabaf68ae3si4153902pfb.170.2024.03.27.13.32.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="EmQs82/6"; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 97213B2428C for ; Wed, 27 Mar 2024 20:14:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DBEE152526; Wed, 27 Mar 2024 20:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="EmQs82/6" Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (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 D7C15137764 for ; Wed, 27 Mar 2024 20:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711570486; cv=none; b=lnMS3wsoLJeU79jqm/cd+/PADm8IIZHr1hdvoW2Ew2RZK6YoBGF3zQIMFfUH5xS5kd/Z4HJJ/e6g82vxCeqtdiVILBY51lkq/oFlDYQK0mKFyXuCMaKwod0LtA7pPQQ4r0qbXp0LdP3Uklhio1JIjTOVeS5mubUa9ouvZjQtS1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711570486; c=relaxed/simple; bh=neQf4eKiBF6fjnhAkZORZQaKoNsXJqfl8RdUdwaGnjA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TzOUQkhSELunGONm60wgK0tAnpUUtTvT1a7NrHaGhpfvNJ0UJz/NbzsqAYLeEif/1DzdnaLcgznxnmFrNzQcsB4ycf0BILWKDkDsna89AERcf4HRe/SJf0/FHAu4XCFt0yqwutqPsQyUEVtawOon9CjIRqJojVBQHerukXBixpk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=EmQs82/6; arc=none smtp.client-ip=209.85.166.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-7cc77e74b5cso9668339f.2 for ; Wed, 27 Mar 2024 13:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711570484; x=1712175284; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=NCYK7bXPxC3buWagK44KXlYoaMMqT9xkSSzlJu6d89E=; b=EmQs82/6Armje5j3LNcur5raGfMx5qSvGFQU0P1z9XUUl3bKndGfeaUusVJUBEws4c bBr7ZHBMTafSqmMcFuanSlOgkNF53XqL9ZiVmm/5IheFGYX5ZzF0b/bvGp/TNclXNbRc JFHXmtJVDooKNW6iuBGi10gJfZa25yS2XxzTFZDIsh8KzOOUcrmkyjIMdmEv5Wf/OHOe W7amXAosOxRXSsVhYh+37Z75vgRm6Ew+tU0sXJZ97fFt2Ypo/ptbmT7I5I2vm9vZ4fhU UIYzViC50dVi7tTLFP7YDVKcYY4o9hrvLs8mvKNQGQBMj2AubhD5tSxoYi6gqaCPTFt3 NvUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711570484; x=1712175284; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NCYK7bXPxC3buWagK44KXlYoaMMqT9xkSSzlJu6d89E=; b=YQdcuYmujRLP2SxbcAbY0HPQ/mR7XvpmQvVUxGoW46zvDq0RzVAxRWu1maXAhrRO5h /IglWTY8J8Jwalf3qdeoTsxZMQ/RnlRa8UDva3Ty2v5FX0QyYeSQJzhuaAUl9+V3YRWg XQIYf8GVSVN9LdAD+TBwIXFIYKBwsyycJGc5zl3yc0vRF5iZ/c8WAxEm9iVeo6oFx26J TrCArA5/lv35vH0q54/SvPbQiZAUDkhW3S/YPMn0OPMWgnZweu6CzSYA9p1P0UqgUbDV jbP2lA/uXqKURDXqcsLZY3WHG4q1MGmGxRv+Qf42nAqiddsvjxl4jsQtmv2wS/4Dc/wH 0m5w== X-Forwarded-Encrypted: i=1; AJvYcCV7jw8rQvgjuWL09G/NWKQIGbwO03d1e5n5WOvsFoCmCVEBn0hmvoHN6cLEFageIdVPt968PJdf3s1of+nngDIEiaqg5tc5A/67pIQB X-Gm-Message-State: AOJu0YxdNku6LX4jDnBooCtqlVJKIdDkynP6CNqfWlYUfC4O5P30s2tV SZgI7Lofv+lQwSLpMzqVjIny6TfkA7tgIas4WqxJVXYz96JGYpvv8AfLGcvfNWM= X-Received: by 2002:a6b:7311:0:b0:7c8:4c27:810e with SMTP id e17-20020a6b7311000000b007c84c27810emr520564ioh.18.1711570483944; Wed, 27 Mar 2024 13:14:43 -0700 (PDT) Received: from [100.64.0.1] ([170.85.6.190]) by smtp.gmail.com with ESMTPSA id g8-20020a02b708000000b0047469b04c35sm3465108jam.65.2024.03.27.13.14.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Mar 2024 13:14:43 -0700 (PDT) Message-ID: Date: Wed, 27 Mar 2024 15:14:41 -0500 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: [External] [PATCH v6 05/13] riscv: Only send remote fences when some other CPU is online To: yunhui cui Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang References: <20240327045035.368512-1-samuel.holland@sifive.com> <20240327045035.368512-6-samuel.holland@sifive.com> Content-Language: en-US From: Samuel Holland In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Yunhui, On 2024-03-27 1:16 AM, yunhui cui wrote: > On Wed, Mar 27, 2024 at 12:50 PM 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); >> -- >> 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? The logic in on_each_cpu() doesn't apply when riscv_use_sbi_for_rfence() is true, so we would make unnecessary SBI calls, and cannot be oppimized out when CONFIG_SMP=n. The cover letter includes benchmarks for a representative single-core system (D1). There was no measurable performance impact from this portion of the series on multi-core systems. If there are specific benchmarks you think I should run, please let me know. Regards, Samuel