From patchwork Sun Jan 12 15:53:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 13936445 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 0BD8BE7719E for ; Sun, 12 Jan 2025 15:55:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD3F76B009D; Sun, 12 Jan 2025 10:55:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B11FA6B009C; Sun, 12 Jan 2025 10:55:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42E5D6B009D; Sun, 12 Jan 2025 10:55:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 17C946B009C for ; Sun, 12 Jan 2025 10:55:43 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BB653140948 for ; Sun, 12 Jan 2025 15:55:42 +0000 (UTC) X-FDA: 82999250124.11.A90DEEA Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf20.hostedemail.com (Postfix) with ESMTP id 3846E1C000D for ; Sun, 12 Jan 2025 15:55:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of riel@shelob.surriel.com designates 96.67.55.147 as permitted sender) smtp.mailfrom=riel@shelob.surriel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736697341; h=from:from:sender: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; bh=BHBAIJk3kp5/hgDdQnghZ6LaG1R2na2fX2tkn+6lmL4=; b=PGFSIVDbiM2uHiCWtnIbLiQYXaSaxLwnvvW6WEv80JhtbUG0YC3iJsKh4WIufbXmp+jxmE wfhnmoG+B6kJFXc5Xc/rBZC2e4biSqVsZRnN6Hac3f/Bh91IYrctqwuWmSzzgEpIf7GYkf jwzLHYJO1pkmr/BgOE5ur78RcGY/vpY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of riel@shelob.surriel.com designates 96.67.55.147 as permitted sender) smtp.mailfrom=riel@shelob.surriel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736697341; a=rsa-sha256; cv=none; b=D86BQeEvER7g28wwqpYheitoIUprosx3f4Lk8+v2HnpQkZb44b40CAcR/lWRzmzoGD3zqR SUDmIkpqikbRiJC5ggmk5jhNP2A6ZeWIi/DS+k7ZkSWVM/ZN7Hp2/UK3j7f3eQMwuuC2kb AlSurd4js1N1tGBQWvas+kq+noNhBX8= Received: from fangorn.home.surriel.com ([10.0.13.7]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1tX0Ii-0000000010W-3An5; Sun, 12 Jan 2025 10:54:56 -0500 From: Rik van Riel To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, bp@alien8.de, peterz@infradead.org, dave.hansen@linux.intel.com, zhengqi.arch@bytedance.com, nadav.amit@gmail.com, thomas.lendacky@amd.com, kernel-team@meta.com, linux-mm@kvack.org, akpm@linux-foundation.org, jannh@google.com, Rik van Riel Subject: [PATCH v4 07/12] x86/tlb: use INVLPGB in flush_tlb_all Date: Sun, 12 Jan 2025 10:53:51 -0500 Message-ID: <20250112155453.1104139-8-riel@surriel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250112155453.1104139-1-riel@surriel.com> References: <20250112155453.1104139-1-riel@surriel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3846E1C000D X-Stat-Signature: s419hunatq61kdhboqt4ktcd47zncpuk X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736697341-677786 X-HE-Meta: U2FsdGVkX19rx9Q8EMZoOG63M2qBx01EwAuE19PHMVtQbtlNzwtOsgjRj+yJqq6mdnjPtOqYWzic+GK3XtDmw46P3qRRuL027cKWua5EaZQi2MOYbMrJ4V+b1pkEkC9W/ph6i91QUuB/3ZrCL/PBo8jCVtF8OR2m7KHGrEgFF1QYb0Nz4Kyhw4szfmi950IHUXmusZkkGva7PYgpDqjoHA4hE1e274H6H9f2VoPiUEbMKOXyy23EXWr0r+CDZ/JiqP+dc/bX2TVDrSiHg6PZ574JxVY5y+a1Un8zXGZ6liUwT/y+A7io6cAJGPy/+++UAMsrfG0ZMba4u/vy/fEeEDNKLij30NXd6tvyxWPmytZL7xkAmdOuFbFgvgSbXuukz4txXQ84yt+YXlmld4vL0TSW7mhKgTozJ75PNdhCaZ5uP1rqIvzHbsIofmMNo53/DchZamKx+ac2feOjsYMNldsp/RUTeUjPvhbQUNpKheDoM1/47IILh2Nj7bIR3X9cn0OK0WIbkE0gXBw1/dp81b0DeOTc0Q39dp8C5TbHJyZSmnTk9AwOURg4f3AM+96ikCT0yjOEvQ8qjqZn5H0fcq0faRORt39+P4LyHD77tyOJs6yZBSTaRWFWj4HxW2Zd11OX/ebOxEFNiYNIFD8IR41WRoTJvq5ibKRoUcUIOkct8ejEDjsqKHwyjoIhfZvoqYnOR6HgGYe3L4kHpGBZkF0QzGrOi9MKiwjHjjuwU/4iq+RTrsyRe7C9wlJsrJvJ5ln1x96bM14PH13D4OeU4gr8NUTLYZ4y4YKQBCmYP7RplcD+AKdUxXai8uDcTHjgaWtFE0xvNvlWx5sal5IZV+iJuzSFm6cala3XZdafwpnpxo4zEezAJWstDfnUhlHkmBdsRXugWfEDb32IzR8a5R5ErQVr3+mVPIzPcFr2aV4Y9Ynu89k1g3F4TfdTmk34Re0+SFMw4ArypODu/DO RWJItmVs BAgbIpw948TDZQOBoLrIk88tPM46EJAeq8cPjbMMrc7MegcSZwhhmF8ciA31Y56Fj4G2juDitWiDTwYMP+X2Df8ze9oE63Dqhn/2Jh5veqpewSkEVOn8sVGQ+9xtdPlV5A/VsFh5Gwb87XZKV4tk8RF7FQ/1JUgcK0qt8nrFwnghSSdaA9Z7E8jwR/C61VNs5R/FIg6InMv7S0S3Wm+Cw2p1UER+NPaMSacDOqTevln7t5Z0QXAY+It/r8iQz3aXYAqw6Zqa6TIBCe5R65vPlQ6q1T8ZThWFTJ4kyAqX9YuylB8ElkRbEbJTkHhjnRAAjimwDlOiGQ31DsdmzosthIw9UrdOOFbQuebexSLrKnXVLan48ZbahPx2DmaD3RMQ2amgFTv6MHyyYF+nH9e54ByZkOt1LIBYtRJUSwHO+Tt0+fRSIhOD69USRig== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The flush_tlb_all() function is not used a whole lot, but we might as well use broadcast TLB flushing there, too. Signed-off-by: Rik van Riel --- arch/x86/mm/tlb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 45c7b84f6f80..56634c735351 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1065,6 +1065,18 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, } +static bool broadcast_flush_tlb_all(void) { + if (!IS_ENABLED(CONFIG_X86_BROADCAST_TLB_FLUSH)) + return false; + + if (!cpu_feature_enabled(X86_FEATURE_INVLPGB)) + return false; + + guard(preempt)(); + invlpgb_flush_all(); + return true; +} + static void do_flush_tlb_all(void *info) { count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); @@ -1073,6 +1085,8 @@ static void do_flush_tlb_all(void *info) void flush_tlb_all(void) { + if (broadcast_flush_tlb_all()) + return; count_vm_tlb_event(NR_TLB_REMOTE_FLUSH); on_each_cpu(do_flush_tlb_all, NULL, 1); }