Linux-HyperV List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Naman Jain" <namjain@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v3 5/5] x86/hyperv: Request mask cleanup when no remote target remains
Date: Tue, 01 Dec 2026 04:53:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-242546@kernel.org> (raw)
In-Reply-To: <20261201043642.1054258-6-namjain@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] x86/hyperv: unthrottled mm_cpumask trimming in
  hyperv_flush_tlb_multi()
--

commit 23e911529adea55b9d5f4467fb5c265f2dce940f
Author: Naman Jain <namjain@linux.microsoft.com>

x86/hyperv: Request mask cleanup when no remote target remains

This commit falls back to native_flush_tlb_multi() with trim_cpumask
enabled when target filtering leaves no remote CPUs in flush_cpus, and
removes the redundant empty processor_mask check.

> 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;
> +	}

[Severity: Medium]
Does forcing trim_info.trim_cpumask = 1 and passing the unfiltered cpus
mask here bypass should_trim_cpumask()'s 1 Hz rate limit?

hyperv_flush_tlb_multi() already branches to do_native when
info->trim_cpumask is set by flush_tlb_mm_range(), so this block only
runs when should_trim_cpumask() throttled trimming.  In workloads where
sibling threads frequently run on remote CPUs and switch away between
TLB flushes, forcing trim_cpumask = 1 on the unfiltered cpus mask causes
should_flush_tlb() to match every stale non-lazy CPU in mm_cpumask(mm),
sending synchronous trim IPIs and contending on mm_cpumask(mm) on every
local-only flush instead of at most once per second.

When the stale remote CPUs in mm_cpumask(mm) are in lazy TLB mode,
should_flush_tlb() returns false even with trim_cpumask = 1, so passing
cpus rather than flush_cpus does not clear them from mm_cpumask(mm) and
instead makes smp_call_function_many_cond() rescan all remote CPUs in
cpus and re-run should_flush_tlb() on every flush.

Passing flush_cpus and info without overriding trim_cpumask
(native_flush_tlb_multi(flush_cpus, info)) would flush only the local
CPU without IPIs, hypercalls or remote CPU rescans while leaving
mm_cpumask trimming to the 1 Hz should_trim_cpumask() path.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201043642.1054258-1-namjain@linux.microsoft.com?part=5

      reply	other threads:[~2026-12-01  4:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  4:36 [PATCH v3 0/5] x86/hyperv: Account for lazy mm_cpumask maintenance Naman Jain
2026-12-01  4:36 ` [PATCH v3 1/5] x86/hyperv: Reject unrepresentable TLB flush VP sets Naman Jain
2026-12-01  4:36 ` [PATCH v3 2/5] x86/tlb: Make should_flush_tlb() available to Hyper-V Naman Jain
2026-12-01  4:36 ` [PATCH v3 3/5] x86/hyperv: Use native flushes for mask trimming and ASID transitions Naman Jain
2026-12-01  4:36 ` [PATCH v3 4/5] x86/hyperv: Filter TLB targets before building hypercalls Naman Jain
2026-12-01  4:44   ` sashiko-bot
2026-12-01  4:36 ` [PATCH v3 5/5] x86/hyperv: Request mask cleanup when no remote target remains Naman Jain
2026-12-01  4:53   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-242546@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=namjain@linux.microsoft.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox