From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796099824; b=Lh1zYcIgovYIg57z5iTUEGxX+Yn1uvtnqIv+9ItEGQ3i8iED69jqPITmOEXYB8mALlTt 0oPUWkHRhWnS9MXYkkLx+Al7zNxC8Ot+4PL7CP75IriP/vKw80ZBlEWMz0IWtN3qmtRkA pTmWzzLHMTKdKLE01oTnphmr6NpThF38q0n56tKs71GEcxpdMqZoL+ioibBbLQOVD81b0 LDD79laXE6umL1aXDt3hCDNR4FW2YVNL30oCC2mFTiGADs0amOuNT6Ol+Mh/qJLX/l52h t6WR/A0+Uhp7BUKzDki1B5TLYqxPU1GjmT1D/r6My/vgHaZD5/CJ1ZPkFpCgWVOsXJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796099824; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version; bh=/W274tc6Rk2YAeDYlkVcqCSnuBs1xI+S0r8hTag+qD8=; b=oHzhX7vHz0+N/aLgDGuFqnRClcVwB3mf84lFAY8SyZdSf05qx4bMP7XIIbcqwE4VRTI9 cWtxVvKtiXLcjGMdHMPXUqZx4c+1jqeiDwEu8Q6KuiFEzynkV4T2dO5SS+8pclSFqw1Li BqtA1Ee60tayNAcqSuxOdBKmimU7JNA7wqkIVEZkr4o68qyzvEvFf4fE9NlYtoowWQ58d FEpQH7RXAC0L91xJfmfgg6z0LnDlrZ/753AHTmhiV51RSypx1dFz98i4XqVpbJw0pR1M2 I0r5V0ekvvyPYQZ/naYbEpVNwUm4OBfxw7ktt/Wxgl115SiroBw2EMzu5tAmp5VBG+Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Bqfsrj20; arc=none smtp.remote-ip=13.77.154.182 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18C48606A320; Tue, 1 Dec 2026 04:37:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 18C48606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Bqfsrj20 Received: from CPC-namja-026ON.localdomain (unknown [4.213.232.23]) by linux.microsoft.com (Postfix) with ESMTPSA id CBD1420B7168; Mon, 30 Nov 2026 20:36:50 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CBD1420B7168 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1796099815; bh=/W274tc6Rk2YAeDYlkVcqCSnuBs1xI+S0r8hTag+qD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bqfsrj20AGfh1aPiCw9YnPRFKsNSZtWJ3DOdy3kHa8jflbVBvH7kL42cxuqsx8aYJ Sh9bSNJpmeuRZyyyQMs3cDOwMNDTj4aVvEZr4zucKQmeN3cvN5LasAJMJN2mckkqnW MV/RifvDD0UTlRyf07Wp4oVlhvl6jx8EZE0HGTQU= From: Naman Jain To: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, luto@kernel.org, peterz@infradead.org Cc: dave.hansen@intel.com, hpa@zytor.com, riel@surriel.com, mhklinux@outlook.com, schandna@linux.microsoft.com, namjain@linux.microsoft.com, qq570070308@gmail.com, houwenlong.hwl@antgroup.com, zhouchuyi@bytedance.com, jgross@suse.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/5] x86/tlb: Make should_flush_tlb() available to Hyper-V Date: Tue, 1 Dec 2026 04:36:39 +0000 Message-ID: <20261201043642.1054258-3-namjain@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201043642.1054258-1-namjain@linux.microsoft.com> References: <20261201043642.1054258-1-namjain@linux.microsoft.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Make should_flush_tlb() available to the Hyper-V PV TLB flush functions so they can use the same checks as native_flush_tlb_multi(). Use a const struct flush_tlb_info pointer for direct callers. This preserves the read-only request passed by hyperv_flush_tlb_multi() without a cast and lets the compiler check the argument type. Keep a small wrapper for on_each_cpu_cond_mask(), which takes void *. No functional changes. Signed-off-by: Naman Jain --- arch/x86/include/asm/tlbflush.h | 1 + arch/x86/mm/tlb.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 70098d448e999..1d1852ecaf084 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -263,6 +263,7 @@ void flush_tlb_one_user(unsigned long addr); void flush_tlb_one_kernel(unsigned long addr); void flush_tlb_multi(const struct cpumask *cpumask, const struct flush_tlb_info *info); +bool should_flush_tlb(int cpu, const struct flush_tlb_info *info); static inline bool is_dyn_asid(u16 asid) { diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 53dcab39566f2..2990aab1f8ca3 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1279,10 +1279,14 @@ static void flush_tlb_func(void *info) nr_invalidate); } -static bool should_flush_tlb(int cpu, void *data) +/* + * Callers must bypass should_flush_tlb() when freeing page tables or + * during a global ASID transition, so CPUs in lazy TLB mode also + * receive callbacks. + */ +bool should_flush_tlb(int cpu, const struct flush_tlb_info *info) { struct mm_struct *loaded_mm = per_cpu(cpu_tlbstate.loaded_mm, cpu); - struct flush_tlb_info *info = data; /* * Order the 'loaded_mm' and 'is_lazy' against their @@ -1317,6 +1321,11 @@ static bool should_flush_tlb(int cpu, void *data) return false; } +static bool should_flush_tlb_wrapper(int cpu, void *data) +{ + return should_flush_tlb(cpu, data); +} + static bool should_trim_cpumask(struct mm_struct *mm) { if (time_after(jiffies, READ_ONCE(mm->context.next_trim_cpumask))) { @@ -1357,8 +1366,8 @@ STATIC_NOPV void native_flush_tlb_multi(const struct cpumask *cpumask, if (info->freed_tables || mm_in_asid_transition(info->mm)) on_each_cpu_mask(cpumask, flush_tlb_func, (void *)info, true); else - on_each_cpu_cond_mask(should_flush_tlb, flush_tlb_func, - (void *)info, 1, cpumask); + on_each_cpu_cond_mask(should_flush_tlb_wrapper, flush_tlb_func, + (void *)info, 1, cpumask); } void flush_tlb_multi(const struct cpumask *cpumask, -- 2.43.0