Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp214370lqc; Thu, 29 Feb 2024 15:23:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUjgxHfIYHreY5iLm1WbZfe/bVV72i/XKGQhtlU4b/PJeGC/7ZAHrH2KMBjqazuOINJ3Sm5KhhlvpJrLm+TpTQ+J91LMmd+kzcEvWDHTA== X-Google-Smtp-Source: AGHT+IGJlt6UGhpvwjkI4OqxdNcvJ6Ns0NRvpR2k1yYgVyGS0JFhZ+j2dgh6EoPWsMR1PvGVpV9W X-Received: by 2002:a17:906:3811:b0:a40:bff7:6e73 with SMTP id v17-20020a170906381100b00a40bff76e73mr68852ejc.36.1709249008789; Thu, 29 Feb 2024 15:23:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709249008; cv=pass; d=google.com; s=arc-20160816; b=Z8qktqqyPJv4DH5mMjKjEsgzhHhDaoOGaB/u4iYcghKJ/GqQNLkN8KMJzH/9WD0Qz+ U1LIqHId2QUjfFHck9q7rqI6sO3SP87e8JlA230txaw0oC6eQSkUFCFJFx2aHXOjsVis HvzbIkt3mYDFf68xrYRIbi6g9cPZUyaFuIxFlGpNR0B/tgE+YNMHzbBROtRaTyZ2dbVB V7jfYXhviwP1wyXOn+ArjIvKl5KZ0Kq5efZaoKQqTLpFEoz1UNTgrRDReL4skPZG0gUj ulejPOogJ22y3FSCmzazSN9I2oOPD0RGvMvYrp4yqgJ5O33dnHxo2eEMCqD6Db0AtKEf 3n8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9YO6O944kqWb4oNKtEMwGtpxpVk1nDXsHdzKgYw/NyE=; fh=kVMl8kfpA36Ro/3P2bM4CdBKxR/FbbKq3UwoDY1wFDQ=; b=FrliIChSxgV6DKT7Y5sTNVNJxbY5dSzDYrM3vEnshAWdP40A9g37/XhRN0Kj/NUTJr C3rleKP7FdUEaE9KRkSVlw0FBW39digP6Fl0iquQ7VBhLCIHZyzymZBWmf0xOn2/WObT tnrZZhEXnYC7A38pVyRUr4QdIypqBhkRGALRdgUYf8gnLD66aPV1UGZ8RRo6vHALbnvo IbBqRCjPsIE7R0wEy86iqKdNYTxA/V9nBLwyO8ahaRxIQBziIm+A+cpr27kBeOe8SN1c XMeRfs3ziI/ISz/byP1IKQ+OGAQgGZrncqFDZKCStOFZG+vQ7/ZWLnNc29+S5j28z6vB /Bfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=R4zqQOQx; 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-87677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id js6-20020a17090797c600b00a434e94b43bsi961261ejc.825.2024.02.29.15.23.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 15:23:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=R4zqQOQx; 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-87677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87677-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7F84B1F22799 for ; Thu, 29 Feb 2024 23:23:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD75A143728; Thu, 29 Feb 2024 23:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="R4zqQOQx" Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 616D713E7DC for ; Thu, 29 Feb 2024 23:22:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709248940; cv=none; b=M78XxQ+325ihQdQ90g+8gBZo5wiA+wANf8GCPsNliuLAZifhhBX+XiTO+sidDd+ucbcBCkyOMfrnkS4lHcY/g9a6gkoo57XHsoNbUfISB3GijbAEOJ6nMU6/4+YZzht09APRjnsHqbCzaD+kcOvT8xT++8RLwB/CZTjmURXOgJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709248940; c=relaxed/simple; bh=a0/O/6KXaeNjvwFlcxHlcnSxOyEoC+55OmJ2xLa9M+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MiywI4aHJUicxdwDw9xi5QxPzx/mEHdM7PyHWQNBPArlbTkjHWBGXg5nKbHHpCPzjKbodsCaTZwMXppL0G9Y6kzR3CQ1s3NiIkQ8MUukcnvMKafAvEzJ/9s/dkYUx0nihPHa5NMgoKWlbpu61gbJn/aNyp8sXBg5hABWau2EXak= 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=R4zqQOQx; arc=none smtp.client-ip=209.85.167.180 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-oi1-f180.google.com with SMTP id 5614622812f47-3bbbc6bcc78so1082695b6e.1 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=vger.kernel.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=R4zqQOQxA6YWW/2eNFx52MOxRUF7TQJLI3sZyM+IQyqZRzS7REEFcHh9dk6lFH6MA4 ijyUzDrxTfTfJswzq5E39MyjcK2Op4YmBvp0he30ds6rJgkHNMfE9qjFzmf5mJoYdFkA vD594eHOfPd+SYN4rNvn9eEIjOrSqOHjMq2A1uAMQ3r+ZjxNCYyrWD8nrnDBdX7kzBfX riS8VwaZRZ71UibaobFzpHksyB7OX+FbFygcuTx1nX7z70FBIQRwKpBlXkPFTrSZiz4o K4UVsRf6elLXWnwqf2cVY3K8RJun/kXoqKnsheqV7uSCQDV3bBjmNlNr2gL92hoqJgC6 MaZw== 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=szyYA0EenaxhV2SxejIepnW9SAHLfmgUAIdQNTvnBF9Resj7zhEnNvHJQPAnJ3rEC1 Drd+8HVj3l8x7z20Ai/It+3b2OnGQaYNIUR5wkKLDarkdPotA2gjWkmWjPf9wDZmgtUv Y8eVXJflbdiBlDaHg3lIwGfPYXpmQPWaSh0UrPTHS6AoG8gtz2eCEIsw/cHd/5Xkf2F2 vuRKQOMW/ZpVR00Oeu7eQs+gjQCwXPl2Owaa1v0YqV3uH576xFPNnnMMqMqQ6OVnvIqa +AGQZ3vWOCnPMnz0JZI5MQdbAVXq/wFOo6Dwvc8ZyrDh1mdAi/Zj5Mv8xty32Q3pwtgA hpxw== X-Gm-Message-State: AOJu0YyHhq8oUtuCStsuajzFuTxE7f4nnYwGJ87eLdxMfF+Sfh3oYCrt b8HtGNPWnHIzU3/CfsFnZKTNUX4KFfCBhsQsYmmTqK9cXb+jqpyZSgled41hEKQ3MODl2wb1hvY v 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.43.1