From nobody Mon Feb 9 04:30:12 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 690242D5C91 for ; Mon, 29 Dec 2025 14:54:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767020089; cv=none; b=lfVcMHT/LtUpw1boTLZlb36RFNWNp5OBDpQ3fFEc8a5XG+N57c9Um43eRQ91CttVwLEL9EZRVSmX08phdMlcSKTnpVIur4+y4aCmFjWhT+2Jz3nLKfyTKnbP3oo4QzSM+6PJQ3usWKplxWFUwirsEOEmVvzcqipsL9/bQpR/8uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767020089; c=relaxed/simple; bh=lC6GEfxIGK/35lvrPF2qw5D86rHWEQ6C/lNcw05H+jI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dXG6GXQjK6ZAz9nDZjNUHfqpwuBGMyUz4IxHSh/dD/ew0JW3zIZE9dLZBVTkKLY95E4gGR0Vn3iHgel1UeaKSUEcI5DheREAAvUngsKaJ85RGGGbiMYLqzxPrhLzzmJHZLowSOFvv+GPMUDoqIrCHTQ+6i3JQDs3/iakL9YjZto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7b9c17dd591so7847011b3a.3 for ; Mon, 29 Dec 2025 06:54:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767020087; x=1767624887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=foHDr6tTVVg2N+oq2ubI3TwM6NJy7Osy+6nFP/DCYQ8=; b=ajf8UQ5hX9i96tajGa1CZkFL48h5CQSlBjtS/KXfDuU+9SZOjnZvXKFf43pVDdx+28 vgazkY7g5r0/4eKS/msVWtH0nWgViALFbsSCYEH+R1YNbLHWAwtebGzntKKeo6fwof3h 6P4rCm6Yf+9JnTl518H/HYtjuib0bPaPUbF+DyXgT4Z+tybTB6onmJOZWyan0AJO4bMg 3krMqfv+wk8HRq+D42bw4vT+UGnL0DhZDqHTFcyg8twu8SUShW1+DZ4a5WSseOQpjIeb Girlli3/uRXJr5RLvrCrm+FCYqvugNMTNrwNRCAr41pH2YL3LugypqFvcu40lpRwzmDb Crqg== X-Forwarded-Encrypted: i=1; AJvYcCVFYpGxOxPBR6vl9icFGKm2XPj9aBH0lCpJq1t5lRsXYukECTX+S/qsjQ0Xc/z+/b/DFpfh/wj8tsYXRbE=@vger.kernel.org X-Gm-Message-State: AOJu0YyGcGq25gw+yrzJlT0Uw+r+zTzkpNyjZcPIJeLbw97wngw2LiNI 00osxA1HsT7O8ZjLFjyngE6om/N9boOalp1aM3eCCEVKYMz3wnSZ2o4c X-Gm-Gg: AY/fxX5+jZx8XFYaP43uPzZc8gkY9h22XdolbJcC1a5Kqgdyhj3xItX8nXD8OJd10Op 5n1EPtAE7VMKdtooFDFu/2jLI4XOkB2vI9+ZDCGPIjVKnrOF//tcjSwMUNL1CwSaov5Y8Ge0Pt0 F0nKm6RrA0Jl7ULIHBbm6eb3JZcjyVX2HWyxk+c3yoo2OfjQZOwI+plzkwX4xawzRl9/VW/MKWj uKZNMPQfyHz4cDJofsuEHYOefNauPxyOJJjcQbkvpynQ4/PUomzJ47p90lWokJaM5RMhHAPYn9f qd9Nzu11ZHPEuWYvCk++RqezN/or21k5JMkL+ZXuuaZVsimvrEcBQZuPryB7V0WnyJQskR7C91j QZJjB4ZAM9Qg9VIp9kFMlx5lg1fP8O2WoBo25ZLiwKxsWGY6irKT5e8Y0o1JC6oxCxu7BF+0yPM EqOogTVe5laAKwSRnV6ofgOthGWH0RJyE= X-Google-Smtp-Source: AGHT+IGKVZznmIqdsFJZx8tzz7DJSoz4ei3n/x9I/qNdC+q4k/iJfPtD5Rz6uSZJWfuK81E5v5oz3Q== X-Received: by 2002:a05:6a21:6da6:b0:35b:9ba2:8cd5 with SMTP id adf61e73a8af0-376a9ccbb8emr26989418637.56.1767020086734; Mon, 29 Dec 2025 06:54:46 -0800 (PST) Received: from EBJ9932692.tcent.cn ([103.88.46.167]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34e70dbcb6esm31557603a91.9.2025.12.29.06.54.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Dec 2025 06:54:46 -0800 (PST) From: Lance Yang To: akpm@linux-foundation.org Cc: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, david@kernel.org, lorenzo.stoakes@oracle.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, ioworker0@gmail.com, shy828301@gmail.com, riel@surriel.com, jannh@google.com, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Lance Yang Subject: [PATCH v2 1/3] mm/tlb: allow architectures to skip redundant TLB sync IPIs Date: Mon, 29 Dec 2025 22:52:43 +0800 Message-ID: <20251229145245.85452-2-lance.yang@linux.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20251229145245.85452-1-lance.yang@linux.dev> References: <20251229145245.85452-1-lance.yang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lance Yang When unsharing hugetlb PMD page tables, we currently send two IPIs: one for TLB invalidation, and another to synchronize with concurrent GUP-fast walkers. However, if the TLB flush already reaches all CPUs, the second IPI is redundant. GUP-fast runs with IRQs disabled, so when the TLB flush IPI completes, any concurrent GUP-fast must have finished. Add tlb_table_flush_implies_ipi_broadcast() to let architectures indicate their TLB flush provides full synchronization, enabling the redundant IPI to be skipped. Suggested-by: David Hildenbrand (Red Hat) Signed-off-by: Lance Yang --- include/asm-generic/tlb.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 4d679d2a206b..e8d99b5e831f 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -261,6 +261,20 @@ static inline void tlb_remove_table_sync_one(void) { } =20 #endif /* CONFIG_MMU_GATHER_RCU_TABLE_FREE */ =20 +/* + * Architectures can override if their TLB flush already broadcasts IPIs t= o all + * CPUs when freeing or unsharing page tables. + * + * Return true only when the flush guarantees: + * - IPIs reach all CPUs with potentially stale paging-structure cache ent= ries + * - Synchronization with IRQ-disabled code like GUP-fast + */ +#ifndef tlb_table_flush_implies_ipi_broadcast +static inline bool tlb_table_flush_implies_ipi_broadcast(void) +{ + return false; +} +#endif =20 #ifndef CONFIG_MMU_GATHER_NO_GATHER /* --=20 2.49.0