From patchwork Mon Jan 20 02:40:15 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: 13944701 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 41419C02188 for ; Mon, 20 Jan 2025 02:42:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 737C66B008A; Sun, 19 Jan 2025 21:42:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 531AD280002; Sun, 19 Jan 2025 21:42:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 222516B0093; Sun, 19 Jan 2025 21:42:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D9BDE6B0089 for ; Sun, 19 Jan 2025 21:42:29 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 699CC1A26F7 for ; Mon, 20 Jan 2025 02:42:29 +0000 (UTC) X-FDA: 83026281618.01.55C71A4 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf23.hostedemail.com (Postfix) with ESMTP id E363014000A for ; Mon, 20 Jan 2025 02:42:26 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf23.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=1737340947; a=rsa-sha256; cv=none; b=xbVfoDxzcCD2wrm5btW6FXXlZhhHrli5Gjis/Bgwvclib3o8W+tcQaDTFnauB5ICc64YzL V5XNz8RTqEwoWRJu96jNEIde5ScGdtI16krs3wSXOZH0snIIsJ0tEFvS7c9y4HB8fCe/Sw ie0ocQG6FlPag3QaPVOZwcgc2cBp5cI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf23.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=1737340947; 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=FUVHLo8ZQw9HuI2d8HGefUGZmMCOMsVfRQUVMierrfw=; b=GIzdzQgB8DzaYY+YaQZkWyPqLupCAC5A0M0CdbMzlp5grE/zZxChm3VqZVC17QibFMeYtL wZ0jQHgeFEHgj1h5uiji5MF6N18w+O1ykMlLl+SuAkS9GJkf8hEo1/gEnHYq7BWfo2WP++ 2/6lBE6vCtL7IAz8W2Po+DDsxTnQrJg= 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 1tZhis-000000002w5-1D2R; Sun, 19 Jan 2025 21:41:06 -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, mhklinux@outlook.com, andrew.cooper3@citrix.com, Rik van Riel Subject: [PATCH v6 07/12] x86/tlb: use INVLPGB in flush_tlb_all Date: Sun, 19 Jan 2025 21:40:15 -0500 Message-ID: <20250120024104.1924753-8-riel@surriel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250120024104.1924753-1-riel@surriel.com> References: <20250120024104.1924753-1-riel@surriel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: E363014000A X-Rspamd-Server: rspam10 X-Stat-Signature: 5myq85secwt8rbmzh6513bowum1yaf5h X-HE-Tag: 1737340946-626300 X-HE-Meta: U2FsdGVkX1+QK2+qMJIow8yMBTO0zcnU6g0ZQrt0BfB4LmWB0LF926PItpTZkwgjgzVxXjaKUMlJkls6pZFbeCE8YiEcOwB8ADKMejt4sa7mfI9SCdYMFwO59roVYT9te6T5xhOb+I7GLIORM13FAsxIb/wEV2NhlVuWJ/h8gaxzOq7BbHQSKr2A9iNMaH1va/XShZwzO/yvNjdYziWSNafWUuOqelP9ZLOggv1Us97OQYtRyJslQgiVlIK4UN3qwCvai2l3EtOYjMdwzAy+IkE1nRJO+yYJjyKI/F9c9KRDPBJ+T98GzrGHSsW25QW3sDxPiIsx0GqjA+aVFrT4RqMC6KHOYvNwlCk9MC/zZDFnXdGdIr2eYakWNQOy5N1uHQb6QiH6ssqkrhLsNcJLYxzNzChvHJBHFLABd3oZce30OWBE71MlGkvyFqyt9CyplPVEEu4ZQ+kLTzybxfHbTszwW4mQ5FsU5XvhumSBZf5m5VyXSrxJXP4aogn3iyYN76pOtVFNlow3VRIrhwRghGSxMb/z2At9C4WKbfwgqPHsxy9MlWXPAUOt/r5Vq5hjBhW7NWSB7uuA48bpS0m5Njw/5xHJuUujr9HTQwepJBq6hqYzScRPxfgsFHSAFbJCv5j7cVwYWeU49wzplREu2HqyIbLbq9uiTfTkFH+KC6zildQyrMi9eHW9p5V0OFzM53IMHhuF1eXMNT02BtTpKPvqrdg2AQ1ikwq/Njr8r3Ez3SWKBelLzIAdCGXi7z+FC4ODioQ2h9fZFlzVX/0j+eAZ9snPzpUHBlmdbDr2SJzLl7TdxMk/nEm9ho/Lv2GW06YH9zO+1HWeKCX7FuHn4IqH/YLtCUNEF6eufoPiGUUIr6U/mapcO8ZSvrHH8nD5innYIvy0GngWhHIzjiNdiI4KvSRaHwK8RhPcusCVMT2UKXBWm1Cl2vm/Ho4kD0Bp36PSf4Hum+KPjFFPS2Y wad5byo+ COBtUhVaegFOyr6Mmy0CjHrAQtf3yBauwQhkezrM8R6j9BR0CpiozRzSVZkozVqYlcrE/QvPQOLqOzOnYXPwD0lPySRhx8xrksDWjWUuQMvfq0tUr1Vsd8z01YdsVg+FhnkcLn2KhlAgsCl2Yy1CVDSQIiAR2rKMcJsPIfqPCImu40Turwef9pAS6zHt/tijEXNRNUE+ru9HpXclGIUK0LHSZE1nde6QMd54fWjfVwkR2xeZDqgpzKfU5d5fSM7/Zw/VUUsqzYEt8XCUOS3lWKIozyLvVTUFJB7QHBsJGMvCz4P2Bj3/2a1m5rZHsPtrcyiG5vhtRJ7ViHlM8rvEhbQqtEb3QPQfltrpm8NQ5PMXOpj/BegrZFicdKGqfmlvaAlCJGUgazMMFAvY6nje7Z0YgCbwroDXIztcGvXl38oSL6Ui9GKO9+iazig== 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 2c9e9b7482dd..e2a0b7fc5fed 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1065,6 +1065,19 @@ 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 +1086,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); }