From patchwork Wed Mar 27 04:49: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: 13605549 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 A917EC54E67 for ; Wed, 27 Mar 2024 04:50:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 422406B0099; Wed, 27 Mar 2024 00:50:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D3E26B009B; Wed, 27 Mar 2024 00:50:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24C176B009C; Wed, 27 Mar 2024 00:50:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0FD0A6B0099 for ; Wed, 27 Mar 2024 00:50:51 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E1F3CA05F4 for ; Wed, 27 Mar 2024 04:50:50 +0000 (UTC) X-FDA: 81941593860.20.DD32CC7 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by imf17.hostedemail.com (Postfix) with ESMTP id 20C874000B for ; Wed, 27 Mar 2024 04:50:48 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=Q+LmYxwD; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf17.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.45 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=1711515049; 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=8r90DmKfTzo12+b9oHF/xBbsXVRSBOTytxxA308aMe8=; b=3iva4nVJZbw9w0SjEiLYlp4Xg+wxqbK/pDLoaPsUqFdJcWs9Vm6WX+YVHT1FdOyZU6mi7t JaEHME/elxeoqjMghQeTzVuPQ9T+gywRjetqmqz7gtcy2PF8vyxOCyUPdOvaEer2J8O+WF 58oAg8UY1dqaYuTPnA7UUAdGmio5/r4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=Q+LmYxwD; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf17.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.45 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711515049; a=rsa-sha256; cv=none; b=edaffm77R7ob0xlqT6UZUpO6qoZ3bl+J5tCXPQfxEv5/FEgWRiwbQGTCLw/InAsFgHvL09 I5A/j4VEK2U/XPsVejB4J/BSIW4kvxAu6c+8SW1KEpC9cGJq+kdtduJqjNiUCV/1lsvgPC AZP6WCtbilj0nrquacfDsfpLvIHVkEY= Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6e6ce0702c3so1683045a34.0 for ; Tue, 26 Mar 2024 21:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711515048; x=1712119848; 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=8r90DmKfTzo12+b9oHF/xBbsXVRSBOTytxxA308aMe8=; b=Q+LmYxwD+v4odx40f3QLjMK50TBatVjdUDOk21Bvm98rojkUw2ECpDDslsJ+ARYjIW 5d/yFE0Y347FvEm0RXW6maQpydSPauSQkNQcrZs/jHQ8qREDgQ/ybDaMEH5tD/6fDB3G 2Vdn/v6rN8b9+6h6yc4wE4c0u8/6eqI/Wh+hVa1Cnj/I/m3PaBY03osqk16KSsJ2pmNJ S5yX1KiSfvojwd33hZZNpjF5c5W7VIysR5NxgOA5cfHmAfILktAAbq6BkgKtZVP8I/yv XxNe5soKSmYW3uWP4t/TkE78cFp6m+pmtsX1YRQjxaSHrQEcf1ZibSzpzSBC32mAg1wB mPhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711515048; x=1712119848; 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=8r90DmKfTzo12+b9oHF/xBbsXVRSBOTytxxA308aMe8=; b=PWPhPMiDiRJs6A6iienjZ1VYASEZSFfboliZo7nBUUTchDwIXLPbYO6Yow3DUC1Tpr Dn1FCkhY7fHlYSl6R/YfBavmS49sj4eGfujMRpIH+O5d/SqEy16YngkX300+N/Lpx6zj Qx6jK1eej1UDEK3aYRc6vOIQWkFd4wJvPGygBrzlF3nyaokwLCGVYFKsf93Q/qlG9qVy nAAFUJ4hcb/ljSxUlNF3PB2cww6TEZ7jZS+O50sRVVGip9mrMnjb3Qt7N6o2W+qqI94L Rps3V2G1CA1JuVir3cm+N1LJnj6xGyEOahk5818o3tu61r1OhkQ0DQwXjEGV1oozYT3O bLVg== X-Forwarded-Encrypted: i=1; AJvYcCWlIKQhC5CewYEPIOUDwNdosu3L92MnLe+k0taJ8ESqJXHtjsANScVBoRHCkl4XwX0MX/1EI7kggF+hST/AaXyu1fw= X-Gm-Message-State: AOJu0YwMji1Qx8RIxiWnlyxGQ2iHdWzuAWoRZmbKk4P3RjrnzBY0gduU Mi54qgaOMlI1naKzHDL5AN7JW9Y91n+YLStF+ADvv/8sJt6OJaiYu+EoClhxTmdWoXqWUt1CxZp U X-Google-Smtp-Source: AGHT+IE/gtW/a2EQvN+qhLpDTcQ1EZrF+9VNRUlZn60iPj1iarim6P+gGyjDapgmLmO07m/XYQ3rgg== X-Received: by 2002:a05:6830:1e72:b0:6e6:7db1:b444 with SMTP id m18-20020a0568301e7200b006e67db1b444mr154078otr.36.1711515048291; Tue, 26 Mar 2024 21:50:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id e31-20020a63501f000000b005e4666261besm8351500pgb.50.2024.03.26.21.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 21:50:47 -0700 (PDT) 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 v6 05/13] riscv: Only send remote fences when some other CPU is online Date: Tue, 26 Mar 2024 21:49:46 -0700 Message-ID: <20240327045035.368512-6-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240327045035.368512-1-samuel.holland@sifive.com> References: <20240327045035.368512-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 20C874000B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: mhaq58zeicfkz687wdic4io5pxgpncfk X-HE-Tag: 1711515048-537783 X-HE-Meta: U2FsdGVkX18nwSRaTzMpAUS7XQFE7NeSnlnRg62zHnFpF0xec6TrALx2pl94yd2Slhd/wy2+oPPy7TOQ/2iP4+4ngLedyAOaoQKlDxdxEwKbt1t0EIdgECgojUAu8uWQJ9Nm0mTYGEu5iieSWowcl+DGiJbzVfWuA8QuCNbXDDR7A2yM9zNf7AEg5W7iGsccgnvr9yKQMl8UGd556bA5wzzRWfT08/rK25jeRLPdgtIIh9cHLewY8fm5JxlCvfXeEC9QadOGytKU3d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/BpCaJx2f/eQZUFu/mNedAwhFxD5Pa0dg6NbKdmOeDck= 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 Reviewed-by: Alexandre Ghiti --- (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);