From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (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 14BCF330670 for ; Mon, 29 Dec 2025 16:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025731; cv=none; b=fE+7IV0dxAmkPnEWMO0ciZv5cdgqn+pQfVS2Bg6fCNkPx3I0kiW+ggqPaxaav7B9mb4tSNuS2g85D37FW/DFyIiciv7QN1iuCbzeL26ROlNRFZsHDLQUG9gchuAsxEq4/abwWUQSKiITC3J/fvuB5txUCdu25GJifO1AfDDWcWg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025731; c=relaxed/simple; bh=zlr/111TrHo5MpMuGBuF231eLYaYQPaX7JKTu3tzgjQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8QO2iujvoHiSr/u5TNnSi59ML95/ViiJ32UYgHrGwoBFziGH3Xy7UPyFbI6oSvfzcdl7OTk9mgFmiETohWBnkYdTP53yGQxtLv6Cb50JPCvIGIsnMyp04+lIbfsVh/oOPqqUV2+nStjb8kr+mPP61Erty4YspBt9LVVzFhwhtk= 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.42 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-f42.google.com with SMTP id 586e51a60fabf-3e37ad3d95aso6289096fac.3 for ; Mon, 29 Dec 2025 08:28:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767025729; x=1767630529; 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=rSXDsPw9SWpPdwz0G6LJLeCgBG0923yYOTzxWibmOZo=; b=rOepHPVcmeoA164RRJnGexgw6FabEfenk95ZmhcQxuRzuRi4U7CpQJWrrv5h3oqeJn 1ZYSjAZv3gjeYQ7MPoe7AJJ08lNxwLMWsn3GHNHWEmsYVtV9TtzKPz54mrhfGTUiS30k VuhWGYYmvZapmDexEVkgrymZnStuDDI/G8Ng04DEHFmKMCOIs+DOqS+jpl/g3uVBmPp7 LJZ+2505ThFKj1T+FekKqF4rZ0kd3H9lrbvcoikOgBQbXodFC6j68up+8iCNVDwsyQm4 bAQIeO9zrmH8td6H5sR+/kpAyazNQgWe3SIo6Gs2GEZ0Sp9WZ2Np2n3ZRIZWB7kA4kcT wppQ== X-Forwarded-Encrypted: i=1; AJvYcCXoxNSIWeUlJXmSPovJGarL8UR1fSQBqM7zSi9ocZeAQWPCOx/GwNd1cTwVQibduPnEt15ACgZViTwO8Ks=@vger.kernel.org X-Gm-Message-State: AOJu0YxxRqB0ZB8nwnM86F7+cf6O9d/hPtYDr2GouQbQx8YvHdkE/oZ9 YbQvulZguAkgS7fK+BsxHgPKZ1DJ0DSTQ8qE/zuZOV+zL57jPWQCxMKpZuNOsysCraI= X-Gm-Gg: AY/fxX7MI+Z5GxGIrkI3p5pYYcr6PX1BrShfCrH2EECe1Ejs3DLLq03vtSljeuqDVWV YFIAy57fSv7d3JWIav4C5nVqhkQymZJM87JunWxQFHpsBLCaO2Or4PqD3wW+agxjFDs3NEMGFFz gAvmlFqUPYpUv0BnsKMNsa1pkryGy/YWhdzgBSpB4kbwBIwIkkL5WD1SM94zfwX5qt7fzUkKeA4 6DIAaQLuzV4M2QSnVwO3MzaTjkj4qyO7H50x795WtBRVEtuvw/yWxZrBkM1OzhmV6Ao8CG8SjGK ftqn9jvR3HWZJ3chpZ5lW18QXAQbgPDL81dmePiBtUr/WmxHo3RPHOCfrkmBytsX0cBqGJ67E8y vOxgezsRyp0hRM3JWwa3YdONIasUGTV019cJm6BYHNUca8EXeidLLg9j+cgORNmJeMxQYJ6mOHA ll+B9ck1Mb8MWvex5VOjoT X-Google-Smtp-Source: AGHT+IEP/l8Fja7SBvXa0ush+/T4hTB3LaeICnV93wQNMRXO4irWoD5nheCHiMMFR22YVQ8DnynhEA== X-Received: by 2002:a05:7022:208:b0:119:e56b:c74d with SMTP id a92af1059eb24-121722b2bc9mr31073304c88.18.1767020515978; Mon, 29 Dec 2025 07:01:55 -0800 (PST) Received: from EBJ9932692.tcent.cn ([154.17.20.208]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217253c058sm118358235c88.11.2025.12.29.07.01.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Dec 2025 07:01:55 -0800 (PST) From: Lance Yang To: lance.yang@linux.dev Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, arnd@arndb.de, baohua@kernel.org, baolin.wang@linux.alibaba.com, bp@alien8.de, dave.hansen@linux.intel.com, david@kernel.org, dev.jain@arm.com, hpa@zytor.com, ioworker0@gmail.com, jannh@google.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, mingo@redhat.com, npache@redhat.com, npiggin@gmail.com, peterz@infradead.org, riel@surriel.com, ryan.roberts@arm.com, shy828301@gmail.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, ziy@nvidia.com Subject: [PATCH v2 0/3] skip redundant TLB sync IPIs Date: Mon, 29 Dec 2025 23:01:47 +0800 Message-ID: <20251229150147.89896-1-lance.yang@linux.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <17a56acb-4e2c-4b14-bdb7-f64b105a3b4f@linux.dev> References: <17a56acb-4e2c-4b14-bdb7-f64b105a3b4f@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: 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