From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 B22DE333445 for ; Mon, 29 Dec 2025 16:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025887; cv=none; b=gy41QaaWzCZOJ9aCD76FY5HkdTf4OiHvGDK5PxHOAOyEfqIFKW8JnjVa9p0wi0QOba0ooJf6G+Cx1eOax2IVa2zY07vKUM2EdBoj5BBhm0ET3Qc68REMXx/lLj9noRUNi3TYNpYCqckxyVW1xJERwH2Cd7sZAZGc9+Vj64XmhpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025887; c=relaxed/simple; bh=iglCtSg7yLjM4+ieaBuaOj/sKVkNeZTBv2wFT1JQJiY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PmEMB1bxbtDXz2xrWaq7nrPhcEmHAnKGNA9dmniR/yUQOuLnTfpFhIvDHf6fRFzNiwkb2zVU1eXMbZkxOWoY+4kDx9dP1BZd/8/fUzNJPE+o4uv2jlzxKeCuafJ9ewc8GilB5vipT39H6DX2wtnetioVWbJ1Z9THjwGQPxxuE9s= 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.222.181 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-qk1-f181.google.com with SMTP id af79cd13be357-8ba3ffd54dbso1309822985a.1 for ; Mon, 29 Dec 2025 08:31:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767025885; x=1767630685; 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=tYC2KycL3rfVSFqLvotaH1KEwy8YCG3oD0jwMS4kfPg=; b=VDriT1hsCy3c3Wb/thjXCjd0i2T7FnZV96X0G1cG6412FIK+GXeaoyAzOfU/mIG+ww BqWQwpmUaRKwgmJULcFj9cLdq8ZpvrAU7hr6eADQ1TmFOfLrRESQfqu/U1M66/axqzj6 f5hx9jWuY+bbLDnFhJtnaCEKEKJdqDHs5C1TuTY6ZWf3Twmm3A/5qR0CPkbgf99V2j14 yVhk/SusYfDHLoBUBZ/R9V7JgzTZn43sa9NJPewQENELz8dR0oXPzA+8JMzlTeUv5l5t nSCxLvl6ygK4I6EnY4YvkkY7Z4LB4mZUUCP+w0BBo6vANhXYVOifcJllOdZcSx+lcHlY l56Q== X-Forwarded-Encrypted: i=1; AJvYcCW5x7OR6CYIpDjf42Ho8Dj1nG89ewIjsQm+XMI+Yn5H05NRhHESgsI7YovWNwgX3IG2KqiKBV1LXiuu1NE=@vger.kernel.org X-Gm-Message-State: AOJu0YyiSiB1AabPSI9sRZlN7FAs+VGrLUu9cXJ/Na5zsYHh+hX+I6xN GKr4ATn7FgRq3atAT/Qdw8fifNRx2MqlP4r2+c2bSPaxVR90S/J1NZb0 X-Gm-Gg: AY/fxX5mlQC9MqDb8XqZWhQhb80+zviSRheB5kNgjrN1cqDeXpn7ti+hyovy9gXf3Ln U/916CcsHCjbaNprcVtRaKe2tqjT/tEqHLTH487+1LVXqnCvpxGNy0LiT8xiHOgFqWFxsYHMLiP iZENSmIEcbc/fsNR35i9hZgnGteXfobNModQbToJQHfHpMXno2P386b7NCheQlP26y8WUVasLcr bwCLxH5ykzca/Us631kjv29FGQoEh7DxI74HlgsSRv3vWw6nTjJF20e4HX3KOKG5V6tvfokyc6R //WQnZXwaCZ1g606mfhnQSEPCZgMj6dRs990HEFtouh3979TxcXo6Ljo7tEQkG6DvrY7wOqmIsI iAG3SYF2rqE9zohpjV7ZhqPndKQ9za5ItS8abdyOHfVkFUaxqAnWXFqrpPMS3r1LgkNLpDrSW4p 7gncZjNFSCLPfDAL+sy/DA X-Google-Smtp-Source: AGHT+IFhUxr5n8VZRZbKH7W82fTkxc2RP8kajse/6MgRobffbByIorFltc6WUeCvU41oKdSH/PT+mQ== X-Received: by 2002:a17:902:cf08:b0:2a2:ecb6:55ac with SMTP id d9443c01a7336-2a2f220cbf6mr353927325ad.7.1767019032156; Mon, 29 Dec 2025 06:37:12 -0800 (PST) Received: from EBJ9932692.tcent.cn ([45.8.220.167]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3d7736fsm279669625ad.92.2025.12.29.06.37.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Dec 2025 06:37:11 -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 RESEND v1 0/3] skip redundant TLB sync IPIs Date: Mon, 29 Dec 2025 22:36:54 +0800 Message-ID: <20251229143657.76968-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! 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