From patchwork Thu Feb 29 23:21:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13577710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECBF6C54798 for ; Thu, 29 Feb 2024 23:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63E446B009C; Thu, 29 Feb 2024 18:22:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 551686B009D; Thu, 29 Feb 2024 18:22:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A38D6B009E; Thu, 29 Feb 2024 18:22:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2792D6B009C for ; Thu, 29 Feb 2024 18:22:21 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 05A2C16024C for ; Thu, 29 Feb 2024 23:22:21 +0000 (UTC) X-FDA: 81846417282.11.382C8C6 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf26.hostedemail.com (Postfix) with ESMTP id 50F40140007 for ; Thu, 29 Feb 2024 23:22:19 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b="PTZUH/xG"; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf26.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709248939; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9YO6O944kqWb4oNKtEMwGtpxpVk1nDXsHdzKgYw/NyE=; b=TD7HVZ5Vo7a2rkaYoX11GK9ou6QfuFnKcRqJck3VSI67z6Qa6JRUkSFuqUQi1rbDR8ZSXi XU8dHJm6N3vgzy/jNYG2wnmxLDZ6y22QmqXfPwaHsHn+5VuvL1yDySJlcFhzpqGojIf3Jj e/37NiSE6WW07IwTLKYiXviPAigOLXk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b="PTZUH/xG"; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf26.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709248939; a=rsa-sha256; cv=none; b=0T6cyh6Myxtf/66LOiq2saSWT+LU7aYRxgYqkNoUME1CQ+KhV+61w2+G1VStrLRQugBFb2 VQzmGiJnR5UB3Gk9DM4NHC4TNFw16jEgFYLuSPIlewsZjQdWILkNjKANzujQyka9KbXXyP 7W05dp9yZ1bo57qzyrm3jt9oyCMsXDQ= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3bd4e6a7cb0so971696b6e.3 for ; Thu, 29 Feb 2024 15:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1709248938; x=1709853738; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9YO6O944kqWb4oNKtEMwGtpxpVk1nDXsHdzKgYw/NyE=; b=PTZUH/xGJcSbZV8vdA+e7QClZFoXrGD3HJxNC1GUJs/19erE8j4p8oRrzToIQ1cFX2 GG45d/wz1UJOW5w8+aC1enMmfR55pxecANDvn+JbrlZWTzumKF3dfH+c803C8C6V3bvi xOAwQRnn8N2v/LgC/cwAInE36p7T6H2xMOENzUFVGGdPTa1VYNDRXu0LDZlqAWfFFLKQ LOeaBC5n53+CFiZNK/mRtwMyATYhfXemGqKu0jq4CS1TW0RXt8t8jnFeKTjPTl1GeBS0 rFgZTS20l/PjvGg/73rQ4kZkKa2pHOOdjZieGv8i2X9Z9b9lzaCD83fbb3AjxqBVphxj 6Lxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709248938; x=1709853738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9YO6O944kqWb4oNKtEMwGtpxpVk1nDXsHdzKgYw/NyE=; b=F5kTGlqgBfgLxXHSkCySAL4wIGGusPbLJVslPBQa43Sjn7C8orUp6ka1dv2aNKBW0n 1C/nuhND06j+NhgBy7jSwJkpxD4PvXLKy61SyuVFhRgDzlKB/rvsqCfbzBCPo/CUjvA1 VbWUWrUhB4xe5VAy3TLndtN/+H3dGTcFpHScriRmeJGRucx2U0r5EH263atTlML1/saQ 7FoGheS++6mI9QlzZinvaagaCGIo3mwsrTCwFLsRXgZ4VUEie6lGTdwEiHeTPGTIHD9i oq9WToqQ4ruzE+iT0lEN0nkb1XP54E4wS/SbzyR99T2C1/PCor3TXxCt3L7unAfjJD+Z vIdA== X-Forwarded-Encrypted: i=1; AJvYcCUKfknPm7HBIv3g6F+PsmFXoVWHBKi9/RFQ4fL1dsSt/wyKtSYUXOXmkVik2z8QjwcCcJpVHHf42bbxpOBnq64klpY= X-Gm-Message-State: AOJu0YwS53+Rgp8KfUJbXQA+28UObK6tcbSLKtKoKf3IdEjcD1bMTI6I 5bjX1Vfoy9gJHSsfZlBnU2kZX+UchI7kY2EmQQ2M9UuPIom6OS7cEck21/lqoSQ= X-Google-Smtp-Source: AGHT+IF/+PdA1OOJxMn23/EE1kPZ70u92KMkSqj19wYtg5glHTCWIaPOP2OtxcWfToq1z4V1DP9b6Q== X-Received: by 2002:a05:6808:8f2:b0:3c1:c37b:1a71 with SMTP id d18-20020a05680808f200b003c1c37b1a71mr62346oic.57.1709248938472; Thu, 29 Feb 2024 15:22:18 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id c6-20020aa78806000000b006e55aa75d6csm1779719pfo.122.2024.02.29.15.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 15:22:17 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang , Yunhui Cui , Samuel Holland Subject: [PATCH v5 05/13] riscv: Only send remote fences when some other CPU is online Date: Thu, 29 Feb 2024 15:21:46 -0800 Message-ID: <20240229232211.161961-6-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240229232211.161961-1-samuel.holland@sifive.com> References: <20240229232211.161961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 50F40140007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1mj5i56bmajhn6qdcke7f4zujbzxmq8b X-HE-Tag: 1709248939-707819 X-HE-Meta: U2FsdGVkX1/nNSbZz05Rgi3+pDO9AU1+PsmnL8IRsLITRsFgkkr9p7k78oAwyf1AwSTnKAWEyH7BvM1OKf5twE81KidotlovR4IlZLyJ/rLHfF5deyo9aSzJ4Wzz6y45jsCSPY2kJ8Codz75qsVsTkvHJ/+5KPvZVIzM6KyFUiKtmQW2mESFe7UdTzlCtSgVhYP81qENXOirB09GlWMtCFZGB7g5Pzwg6WZbLX2SB807holMfMEtVAzAf1B5uqbSupsiX/TGN9DTwVGJgXN4rIUlEkoX83BhRwj/U767LuZYjtAHIpVi62NlvP9x32YzchWzfcAfuHHgJqukw8yRz0zhOpF7iWT4be8Inxy9gXx7qUSTqVe6bmTpEKytM6a5/JD81IsHgfIGK5pB90r0aOxyGnptz4Xr4J3yIBzJjO19WSIrZBWk4QhfZkWaTK6OcUCvqRL1OPvXq5gFS2H+3iz8wQY/QIb+NhDwALg2lPJIGgsGmxPqBDYJW+2Gji8PDUPE9N91fEixPp/wrd4EEmT6blnLbq4M91KcAiPAS/P/YK+paXz1/8uLjTto/aAiCwaTPiMiRA+jBNrKxVQIQ5pm3E7EmF/m+JoDfEgp2qjHIESmNIOdSg8oYxhlyooYWbx4JEEDMi5XyT2oDvLFeb9Lgu7nnupnQUHAcDkCGepzVxB0Ip4SC6K5UWI88Kq3YzYlHI6DStzVNNLFSMsknDf8sm9B6D5Rv7/4tcYKfz1zoGOHIV8K+HxAiUCLa9mrjI2KdykBvio6TuwRhj5pmRdyJgaztsrZaSw9c84HPUP/t2+vGVSObpjtQ2BJfcgh5Fv2qSgoKjTzZLb6UNOa3HH9b54ubDPJnPBJvLnMXBOl3isy0eD2VJ5BpuJzVVY8hh0URjXy/R8vD0oWTyuczlyXdfHDKk3UBYcT+pmGycujhdzcVkMCQ8BwneXdxfz8Cw2+wM1DiuJThGTG7A0 SCXQrsN2 2HYzE0DdaiXW4xu1ibha6w6JO61QVYKDruhbS8BbW28V07B1jjru9ufGAE/31HBIhES9YlsDITyDb2zOA7le5eMWCh8yCEzbFSa8eLEnGiVo+MMQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.060444, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 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) + 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 8cdb082f00ca..69402c260a89 100644 --- a/arch/riscv/mm/tlbflush.c +++ b/arch/riscv/mm/tlbflush.c @@ -78,7 +78,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);