From: Naman Jain <namjain@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>,
"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
"decui@microsoft.com" <decui@microsoft.com>,
"tglx@kernel.org" <tglx@kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"luto@kernel.org" <luto@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>
Cc: "hpa@zytor.com" <hpa@zytor.com>,
"riel@surriel.com" <riel@surriel.com>,
"bigeasy@linutronix.de" <bigeasy@linutronix.de>,
"zhouchuyi@bytedance.com" <zhouchuyi@bytedance.com>,
"houwenlong.hwl@antgroup.com" <houwenlong.hwl@antgroup.com>,
"qq570070308@gmail.com" <qq570070308@gmail.com>,
"bastien.curutchet@bootlin.com" <bastien.curutchet@bootlin.com>,
"dianders@chromium.org" <dianders@chromium.org>,
"jgross@suse.com" <jgross@suse.com>,
"hawk@kernel.org" <hawk@kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/5] x86/tlb: Make the conditional flush predicate reusable
Date: Wed, 25 Nov 2026 10:36:06 +0530 [thread overview]
Message-ID: <428b0ccd-b59d-410c-bada-609396d879b1@linux.microsoft.com> (raw)
In-Reply-To: <DM6PR02MB68607FE813E55D371E03B4E2D4442@DM6PR02MB6860.namprd02.prod.outlook.com>
On 11/25/2026 2:08 AM, Michael Kelley wrote:
> From: Naman Jain <namjain@linux.microsoft.com> Sent: Monday, November 23, 2026 10:44 PM
>>
>> On 11/24/2026 5:46 AM, Michael Kelley wrote:
>>> From: Naman Jain <namjain@linux.microsoft.com> Sent: Tuesday, November 17,
>> 2026 1:15 AM
>>>>
>>>
>>> In the patch Subject, avoid the "flush predicate" terminology (see my
>>> comment on Patch 4).
>>
>> Acked. I can use this:
>> [PATCH v3 2/5] x86/tlb: Make should_flush_tlb() available to Hyper-V
>>
>>>
>>>> Make should_flush_tlb() available to the Hyper-V backend and give it a
>>>
>>> What is the Hyper-V "backend"? Maybe more specific would be
>>> "PV tlb flush functions"?
>>
>> yes, I should change it to "Hyper-V PV TLB flush functions".
>>
>>>
>>>> const struct flush_tlb_info pointer instead of void *. Keep a
>>>> should_flush_tlb_wrapper() adapter for the SMP callback interface.
>>>
>>> Is there any particular reason for needing a specific type instead
>>> of keeping the void *? I'm just wondering what value that change
>>> adds other than the compiler being able to typecheck the call
>>> as made from the Hyper-V code.
>>>
>>> Michael
>>
>> No functional reason. I changed the type because the Hyper-V caller
>> passes a "const flush_tlb_info *" while should_flush_tlb() expects
>> "void *". The original function does not modify the request, although
>> its local pointer is not declared const.
>>
>> Keeping the void * signature would also work, with an explicit cast
>> at the Hyper-V call site. I can keep the existing signature if you
>> prefer a smaller change.
>
> I was originally thinking that even a cast isn't necessary because
> any pointer type is acceptable for a void * parameter. But the "const"
> on flush_tlb_info makes that not work, and the cast to void *
> is needed. Casting a const pointer as void * to discard the
> const is a bit dubious, though native_flush_tlb_multi() is doing
> it. Your new wrapper function goes the other way -- passing a
> void * value as a const pointer parameter, which is OK.
>
> It's judgment call. I think I prefer skipping the wrapper just
> to have less machinery, but you or others may prefer adding
> the wrapper, and I'm OK with that too.
>
> Michael
>
Got it. I would prefer to retain it. We can reconsider if we
get more comments around it.
Regards,
Naman
>>
>> Regards,
>> Naman
>>
>>>
>>>>
>>>> No functional changes.
>>>>
>>>> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
>>>> ---
>>>> arch/x86/include/asm/tlbflush.h | 1 +
>>>> arch/x86/mm/tlb.c | 18 ++++++++++++++----
>>>> 2 files changed, 15 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..9b1aea2b3a1d5 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)
>>>> +/*
>>>> + * Select ordinary flush targets using state ordered against context switches.
>>>> + * Callers must bypass this filtering for page-table freeing and global ASID
>>>> + * transitions, as native_flush_tlb_multi() does.
>>>> + */
>>>> +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,12 @@ static bool should_flush_tlb(int cpu, void *data)
>>>> return false;
>>>> }
>>>>
>>>> +/* Adapt the typed predicate to the SMP conditional-call interface. */
>>>> +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 +1367,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
>>>>
>>
>
next prev parent reply other threads:[~2026-11-25 5:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:15 [PATCH v2 0/5] x86/hyperv: Account for lazy mm_cpumask maintenance Naman Jain
2026-11-17 9:15 ` [PATCH v2 1/5] x86/hyperv: Reject unrepresentable TLB flush VP sets Naman Jain
2026-11-24 0:14 ` Michael Kelley
2026-11-24 6:43 ` Naman Jain
2026-11-17 9:15 ` [PATCH v2 2/5] x86/tlb: Make the conditional flush predicate reusable Naman Jain
2026-11-23 16:06 ` Dave Hansen
2026-11-24 6:43 ` Naman Jain
2026-11-24 0:16 ` Michael Kelley
2026-11-24 6:44 ` Naman Jain
2026-11-24 20:38 ` Michael Kelley
2026-11-25 5:06 ` Naman Jain [this message]
2026-11-17 9:15 ` [PATCH v2 3/5] x86/hyperv: Use native callbacks for trimming and ASID transitions Naman Jain
2026-11-24 0:16 ` Michael Kelley
2026-11-24 6:44 ` Naman Jain
2026-11-24 20:12 ` Michael Kelley
2026-11-25 5:06 ` Naman Jain
2026-11-17 9:15 ` [PATCH v2 4/5] x86/hyperv: Filter TLB targets before building hypercalls Naman Jain
2026-11-17 9:24 ` sashiko-bot
2026-11-23 9:57 ` Sahil Chandna
2026-11-23 10:16 ` Naman Jain
2026-11-24 0:16 ` Michael Kelley
2026-11-24 6:44 ` Naman Jain
2026-11-24 20:20 ` Michael Kelley
2026-11-25 5:06 ` Naman Jain
2026-11-17 9:15 ` [PATCH v2 5/5] x86/hyperv: Request mask cleanup when no remote target remains Naman Jain
2026-11-24 0:17 ` Michael Kelley
2026-11-24 6:45 ` Naman Jain
2026-11-24 0:14 ` [PATCH v2 0/5] x86/hyperv: Account for lazy mm_cpumask maintenance Michael Kelley
2026-11-24 6:43 ` Naman Jain
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=428b0ccd-b59d-410c-bada-609396d879b1@linux.microsoft.com \
--to=namjain@linux.microsoft.com \
--cc=bastien.curutchet@bootlin.com \
--cc=bigeasy@linutronix.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=dianders@chromium.org \
--cc=haiyangz@microsoft.com \
--cc=hawk@kernel.org \
--cc=houwenlong.hwl@antgroup.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=qq570070308@gmail.com \
--cc=riel@surriel.com \
--cc=tglx@kernel.org \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
--cc=zhouchuyi@bytedance.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.