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=1796099841; b=PcrYbRlMLVpCrnGdTU9/Y6iGbZngCDEY+d/HUdKOzwhlthWRG2nJ5Ns3+g5pKB6/bp6L L1tWHN8v4UNoR/y+bbQd5ejxFwQmVqaUGFCO4SciKG+Y91Jxe8ILmp9tzuEa1dHV3+4UO W2CmPxM7e0rba1qKgKHMLPyHcNTMsgt4OPHKv01/ZH0NNqNTRUB1pPahwaG23omtGlxM4 3Q1jDFCDfKGTX4qNN1tc2a3zvzN0NS0Lt/i/7Nv+zLRSB0khZ1PkWGYl07Q9XFScxOAu+ heSaYZhGFdSBvO7xL5WnQesdOja7v045D2n2Z96TSYQND9JRE5W57NcMVovKAwAaNJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796099841; 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=tMJ7HDYPf0ehqjzRQmQ6b+BIa9p27WWlv2pn3kAza54=; b=xwUfLICf7s4qtYRdvv5GmXMq667BOidQ6/v8BGt+uUKpQhpHC0V8LWilfRnmHnUg3Ncc H9m8RQZo11479RrQPxEvqV8UuVZqbCtKhEK+inP7ErqOXq3iBHx5wchy8qN3TnVqzbIoh H0y79Ado9P4XdPfFNeRrCUo3qjI0iWjuTsfZdlNzyDv8OBDNJIWdmTWH3j/meF2OkQmto 2tx2iKbmr/VXdNtJubynWnVFu6PVJe6cHV/lpcZ+46ULojcqu6PPThe0nQewU+XBYVl9V CyJ+a6/Gt0BDSSvgT9RAQAR5hUyWVJOrI+3901WyLW54MJ2PDsZezA9fy87+jl/du1w== 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=d5yvvZNy; 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 2E3F6606A31A; Tue, 1 Dec 2026 04:37:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E3F6606A31A 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=d5yvvZNy Received: from CPC-namja-026ON.localdomain (unknown [4.213.232.23]) by linux.microsoft.com (Postfix) with ESMTPSA id 2005320B7166; Mon, 30 Nov 2026 20:37:07 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2005320B7166 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1796099833; bh=tMJ7HDYPf0ehqjzRQmQ6b+BIa9p27WWlv2pn3kAza54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d5yvvZNy5DvkFmJblMs6RRFriKv/tFTRV6id8sY0HtEh3cpvGlm8xfdhfQugn2zTO 8FcPk1Lx1kmcexnRDkVkiJhMDfxc7cnfpEsoCHdF+ElzNdYBIrx0Bxb1cFFHqDR2rb a9tP5NtsfxDOt+EfPeY0PGEXcNW6oEUVjTT6CjUI= 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 5/5] x86/hyperv: Request mask cleanup when no remote target remains Date: Tue, 1 Dec 2026 04:36:42 +0000 Message-ID: <20261201043642.1054258-6-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-hyperv@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 Filtering avoids flushing CPUs that do not need it, but does not remove stale entries from mm_cpumask(). These entries can keep later flushes on the multi-CPU path even when only the local CPU needs to be flushed. If no remote CPU needs a flush after filtering, call native_flush_tlb_multi() with the original CPU mask and request trimming of mm_cpumask() instead of waiting for the periodic trim. Copy the const request so only this call requests cleanup. should_flush_tlb() still skips lazy CPUs, so cleanup may not leave a local-only mask. The new early return also makes the empty basic processor-mask check unnecessary. Signed-off-by: Naman Jain --- arch/x86/hyperv/mmu.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index 15809bb4a5ebb..c74d3f109aa13 100644 --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -102,6 +102,21 @@ static void hyperv_flush_tlb_multi(const struct cpumask *cpus, } } + /* + * If no remote target remains after filtering, request native cleanup + * of stale, non-lazy memberships so later flushes can take the local + * fast path when possible. Lazy memberships may remain. + */ + if (cpumask_any_but(flush_cpus, smp_processor_id()) >= nr_cpu_ids) { + /* Keep the caller's const request unchanged. */ + struct flush_tlb_info trim_info = *info; + + trim_info.trim_cpumask = 1; + local_irq_restore(flags); + native_flush_tlb_multi(cpus, &trim_info); + return; + } + if (info->mm) { /* * AddressSpace argument must match the CR3 with PCID bits @@ -148,12 +163,6 @@ static void hyperv_flush_tlb_multi(const struct cpumask *cpus, __set_bit(vcpu, (unsigned long *) &flush->processor_mask); } - - /* nothing to flush if 'processor_mask' ends up being empty */ - if (!flush->processor_mask) { - local_irq_restore(flags); - return; - } } /* -- 2.43.0