From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 B0269319858 for ; Mon, 29 Dec 2025 16:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025058; cv=none; b=BroR2OqJtEP1Ns5vd/Pom2YlniG7MnuInrT6KHetSENKw7RK5WbAxcgbqOs/BQ+rDgD4AsCA+8N+KOY4mzZB91yGY+w7S21FplHxyrgn6XWMW34ugKzrKtH3CNFgxaEav/9tCyw9SQk44nD7C8f6dGWluFCnwBFk9dUG7Ts5iYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025058; c=relaxed/simple; bh=n7zOUW6Ej9XQxpCqpcebXYRtyBmuik8QvZ4x35PJmsc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BtVaTIwlFjOfOiODK2KD6q0uJ25MBcSmErdsyxyLE+nb16mSXgI0CRRT0/HrB9a2RGZTp8F3+KfghmTFnJP0xVFXRs34FoICmKH3Io/UFgE/Ug08xc8UOFpVn1DsRjyDiPNB5HwvgynpHOg0YU/pneaMGKLAo3A2ypLWRjmInXw= 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.160.45 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-oa1-f45.google.com with SMTP id 586e51a60fabf-3e898ba2a03so7727483fac.0 for ; Mon, 29 Dec 2025 08:17:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767025055; x=1767629855; 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=DI/SttekhGDiQM1tlGP5eL+usMVrVsg1suNc61YphTc=; b=UgyLV5gpaWpFMoE0UV1Ec/4ZyHuBSIwVjUH6P1OjHk6MSIfyXm6DfNW4L5S3WRvpPf cZLspJYV4u7EvHO0Ds4M3SN1E6+mZTzC9INBWaq42JNlmQw5xQfliEtUCxx60oKXepC+ Jgk3J42YKNoVbdlIGc9vwOVmRdFv4+Nf2xZ5KIroUtRBjiQXRhOfYcY42q8EjwDEWTY2 W5KDsRgTrapu8wZnN4Hqq2bahz6iW0iBZbWtLwi0rI31+5QJc0okgmQow0M7OMBWgC02 JDZIGOu82XYAt/2RlciedxkvzFKDGSwXUkfIqSq8JN0QeXrWsFMZjZlEGtsSBGhOTL2e y/9w== X-Forwarded-Encrypted: i=1; AJvYcCXvXqRUKNMfyOdZEFsJQHf+aDxvjl91aW/DjaYKwIx8UU8xEgx45UJOoP/6EmZACi5awOGcdcwv2lXf+00=@vger.kernel.org X-Gm-Message-State: AOJu0YxDJ0utvb/eAjeP0Pk7/QWRiv8qCfScAL7qBTitlfsGYEh5ILfr zVl4x8eCPBWh0eNIeuFg8/KrjvkdvMe1qHkniOTritMI/L8IondX0rZ2lE6hnGsVb+A= X-Gm-Gg: AY/fxX5ZGoJSxqMQsDkyxaTqnCqD+Y25N1vcwHXb2s3xG33QdmjdNhyul49sIa2y2jB PHWyBgAURstPhHDDUTgOXkM+xFV+Zza/8Ldvo6/LjYObb8fuzfNt5Tgqa+MbIf+kx1+Yzvx8jxR YrsRNLsXDK1nZIhQ3siDktNBmE4E6kp5zu1/9if4x61jEpxoSV6XVravC6hOBq1a126u9G6QROX 2x1jVyWQNKl+e6XBgwPrtpW6/fttt496NfjE1ZtC1iemKqM+qYXSxcp6BLIVDdJ2HPL9b7UPGyt XyfowaTTI6Z0NBnhpirfPl7tyKNUZe480cEHNOVYijFT2BVdJTfA0zVDW+mjHUPafo0ysTPMVNt 0s4HUDR+04D6wcprTfL0zOgWf/70XjwK9A4XfJ5k2dX7doSj273kQolvaGOaHuk2Fsdv7pBqEwu UMUd4Ez2xhU1oRDdlEQdb9 X-Google-Smtp-Source: AGHT+IF8h2vXgJODZ7JZMxunWbJsYMMr6g5hSF24Ns6SSSKowIEhxB0xTevh9xlGxdP/5/5wrf4fPA== X-Received: by 2002:a05:6a00:f99:b0:7e8:43f5:bd55 with SMTP id d2e1a72fcca58-7ff67759f24mr24454290b3a.65.1767018650539; Mon, 29 Dec 2025 06:30:50 -0800 (PST) Received: from EBJ9932692.tcent.cn ([103.88.46.167]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7dfac28fsm29705159b3a.32.2025.12.29.06.30.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Dec 2025 06:30:49 -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:30:30 +0800 Message-ID: <20251229143038.73315-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 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