From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 8482E261B9F for ; Mon, 29 Dec 2025 15:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767023792; cv=none; b=G/uAi/2tQJBKLmO7EnwioApCudBLyuI7j1NEXeRpg7Lm1VOnv2802b2Q9z9xv9hziv3K0cJfNXl1OGMCiFmyzgRC9TAka7+h5JQvc6xgEwMuNuSdjDz93wMBt9mwWO9LVBXKunZwwkG/ei9iWfWhzUsVolkTFSZvt6MBXy0TGTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767023792; c=relaxed/simple; bh=N8padF7buaqa1eXg1+Igz+XpRALmc90ogMazOG4CwFc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=LbNAbEiKxx+MmNJF3a/zuajSk+gX8RMcgWUzjyd4BVBaFXcnRA1wkz4pwP6ljDRzu1n5653Ggu2tQA0/nK+oHBO9X77ViDEKU262lYidP0IGP/+GDe8kmqGOKCZo9sczYitJrBWyVQe5V8jvg8gZ2j33D+9L8w39bXaA4xkxtWw= 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.48 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-ot1-f48.google.com with SMTP id 46e09a7af769-7c701097a75so5092613a34.3 for ; Mon, 29 Dec 2025 07:56:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767023789; x=1767628589; 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=6lnYMzB+dCUz+mkORGwbpkYC+kll7m3t+mAqWOhKrD8=; b=eeyW6Qk5gp4hdl0TEkS3lq/B5SyAQj2ryReyuN/Enz0sXF7YZUxm/do7PVvMk28WjQ GKcMby0UEeqFdClpA3mvd3N1pLudh3cmcDF/OW410G0X3OJbISKgiXBgmz8yePbrR6C7 ILQ2RZNppPg3ss6AaSsYzdV1BeUMLSvVZk9ytWq6sIY4angAmWmJszb8ox2wK6N9gCdX EFmnGrn8OHA+fGkYEcMkAawlNwAEJ3P6JyVOzGIs5aPlMuvGAqoZguVOPbEq5GtCFv2b pc4m/g9sOv9YAFKNSA1gTfJBRWf22QbpV/ZYiGRCeaEk+1v1RdKrqTjiFpCK9Iu5nl+x lPAA== X-Forwarded-Encrypted: i=1; AJvYcCW0k2XGFWwzN8uN21YAkuBcHCcfYauEqeVcRWyDqTQn5lBx/rG0u+9RuVThBXnFnZJdsFQeYP11nBDI02E=@vger.kernel.org X-Gm-Message-State: AOJu0YyL1bVj/OiZh6WMB1c7sAXRdWuplaxSR4vwMzUhsrlkZ6YsmfuM RvSpUKqI17F/AhAYeIRe/7BjxdvFM5fCOKvBrne0DOgiJsNrwK2jfQN6olGykKRClF4= X-Gm-Gg: AY/fxX7DbXxQcRph0HgG9sVA5iTFHkYwNZrc+EL5S6Vy5aiXjPqM4i4VH3pz46YHJpA 9hRDDHRhgBYJobEzCKpigee5nWiCEGRQme5HrWSDbNPPbFCMy3xrY05obWnY98HUGclvx/vrUdF R8NlkebWWdRT1gcTPSUHtEAGGJz8Qkh+7X/cy7DCr1HUJdu0NCiihztSkwdw0/ay8AAX8sXIxyS EHXjz2MpxxYlGxd/xJa4oFVdckezZvL3sgwrC3KOoE8++rQMi2WKOwtGHhocWxgmICxK/eRsKXj eOcSv+sxA1SRT8XsCp2oA2jvTJKOPB2aALabQmq42OFIgM3G3bq3AZYTVKr969QYbY1azTAVWg5 taBe39Ev5j/EvPUT751wWHt5hm8jbMueul+jBqJ7KMAQGNYghAWDWBBtpZ5/opXhAo3TPHpNSqC H/Ttqz/te4Eu3yNIstkcQI X-Google-Smtp-Source: AGHT+IHg6byxM/xkxubE4jTDVkQ4ULmMFOY4QfJYQWgFM4sIg4d8O/EzQKPsy5ALE1+u/Z3o6zsA5w== X-Received: by 2002:a05:6a00:9089:b0:781:be:277e with SMTP id d2e1a72fcca58-7ff64401115mr28062284b3a.4.1767017579562; Mon, 29 Dec 2025 06:12:59 -0800 (PST) Received: from EBJ9932692.tcent.cn ([103.88.46.167]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7a93ab3csm29472636b3a.7.2025.12.29.06.12.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Dec 2025 06:12:59 -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 v1 0/3] skip redundant TLB sync IPIs Date: Mon, 29 Dec 2025 22:12:42 +0800 Message-ID: <20251229141246.63435-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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