From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 CB4DB13B58A for ; Mon, 29 Dec 2025 16:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767026663; cv=none; b=hdHv24htAa+NrmioxBG7Mu2yliXd0APhyQOH8+BsVzbQxsYrgFd4frF8OWZgo6DHrnqQR42ZXmD7pPRWJ/4prRYmYLrJJiRx/0E71hSSPHw4EO8thAQVa0kjatbJkmVTjFR4DNZqnxiaZEAF5u9yauE7VX+0yMFZPeoD1YcPZIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767026663; c=relaxed/simple; bh=zlr/111TrHo5MpMuGBuF231eLYaYQPaX7JKTu3tzgjQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VyfOFatnnOIysvG/CJvL4YBuy6ncm7pI1oux/s0wkhrKLw7FyKk1vwp+jZJHjTWVBHp5WrsZpyHvP0VReVUhmj5SVHu83CM1q/3z8iXwfpCOQYaU1wK34G1ApRtTxZh+Lp/hYM8F0H5BMJPvWNbQ9onOitA3kLcLl28uydxOqdE= 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.167.182 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-oi1-f182.google.com with SMTP id 5614622812f47-450b5338459so5280461b6e.2 for ; Mon, 29 Dec 2025 08:44:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767026661; x=1767631461; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rSXDsPw9SWpPdwz0G6LJLeCgBG0923yYOTzxWibmOZo=; b=Cey28Vda0WLCbAUJhID96GLpLfRYfm0y4L5AFQsLnPwP/3dM7A6Tp8BgYq9/b/6pqZ FMxTt4EuR9tmUJkag5pgSr/C0XWAyu0eRWJJYprKMuERG98OxIV6FdDyIYQoqtEVtMCu vN75BD7et6vcGAczq6GhytgwBK6akXVXj7DgVWacwl4CdcELprwz5lEyPCa6LhX3wn1c 4QF2ShxmLuHdBQ/mMuKGHWurlLGPe77hdX3Kh0N3mYETYGlYbOvoqIE6+PcpWPQimxIG uQWJkFEYHtr+i9x6w+7EQYOFQOb+acMByY0W2iw5uGf72OrR9erAVPN4jmmrxGvioPlR jnqw== X-Forwarded-Encrypted: i=1; AJvYcCW27anc1D9U8kufk4oh4fsQp4XjAtWCOc20JpzVBcZo6rgm427KTrI+qHB4Bk0ovbi/ZMkPEDjxtgVnL8g=@vger.kernel.org X-Gm-Message-State: AOJu0YyALMVcW3/ZC/6NVXy2MRtshqOt9gadQrh3t+92Ec0Dn51Z2Or2 QE6D5LbwU9D+tQDZ4dv/aMZG32wAuKhUy2ZvQ9pG8wI0Iy7xue6Duso/ X-Gm-Gg: AY/fxX4+dL7ksv6xw78++hn5Al5ByhZjGLiN/4eo9tBUiycbBvC8OlBw6EVLb1miwyb 0K8mwaudB+jCrtjydpXxIRscRsgFVJanffFytDH99tvqziKHxPwsgoqRE9D0LialB544jms4B2j onT8hsVKyQ1LnJ0N+vfKZwlzTinrQftXoAbmAlzsRRzdJdl8NDWE/vcZa9Hb4BQ8sD7Ue9D7DKm J3cq5sNlAV0ESpOhu2HnzxGE+qb2Ly2pBATrPjKGD8VeO1evvW4rO1DZDkGSMI7o0hjD16t2xqj 6itaVluuMQB6b7UPfv6II0F2UzKbKRmMtgAh9w6Q1NFu/8sH+DRJv6AfuY//Y3y04V5ipBBmbny iaRdlNyjhxVECzl0LwrjKPuacpOM39RzMS2gbNZ1KefCGRS/bPfHB+nuoR2b/dE+T6KXcGdB0vu 5Ty6CUX/LWC7dHI1LX3lOl X-Google-Smtp-Source: AGHT+IELTW1f0I8nau1FRdD8kDyAYgeeHou3baqoPeRrgIvEnjXylw0MJkmOP3DRvYb3odQ78YmLmw== X-Received: by 2002:a17:90b:1e51:b0:341:8ac7:24d3 with SMTP id 98e67ed59e1d1-34e921f6c8cmr23662117a91.34.1767019978519; Mon, 29 Dec 2025 06:52:58 -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.52.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Dec 2025 06:52:58 -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 Subject: [PATCH v2 0/3] skip redundant TLB sync IPIs Date: Mon, 29 Dec 2025 22:52:42 +0800 Message-ID: <20251229145245.85452-1-lance.yang@linux.dev> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Lance Yang Hi all, When unsharing hugetlb PMD page tables or collapsing pages in khugepaged, we 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. This series introduces a way for architectures to indicate their TLB flush already provides full synchronization, allowing the redundant IPI to be skipped. For now, the optimization is implemented for x86 first and applied to all page table operations that free or unshare tables. David Hildenbrand did the initial implementation. I built on his work and relied on off-list discussions to push it further - thanks a lot David! v1 -> v2: - Fix cover letter encoding to resolve send-email issues. Apologies for any email flood caused by the failed send attempts :( RFC -> v1: - Use a callback function in pv_mmu_ops instead of comparing function pointers (per David) - Embed the check directly in tlb_remove_table_sync_one() instead of requiring every caller to check explicitly (per David) - Move tlb_table_flush_implies_ipi_broadcast() outside of CONFIG_MMU_GATHER_RCU_TABLE_FREE to fix build error on architectures that don't enable this config. https://lore.kernel.org/oe-kbuild-all/202512142156.cShiu6PU-lkp@intel.com/ - https://lore.kernel.org/linux-mm/20251213080038.10917-1-lance.yang@linux.dev/ Lance Yang (3): mm/tlb: allow architectures to skip redundant TLB sync IPIs x86/mm: implement redundant IPI elimination for page table operations mm: embed TLB flush IPI check in tlb_remove_table_sync_one() arch/x86/include/asm/paravirt_types.h | 6 ++++++ arch/x86/include/asm/tlb.h | 19 ++++++++++++++++++- arch/x86/kernel/paravirt.c | 10 ++++++++++ include/asm-generic/tlb.h | 14 ++++++++++++++ mm/mmu_gather.c | 4 ++++ 5 files changed, 52 insertions(+), 1 deletion(-) -- 2.49.0