mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chuyi Zhou" <zhouchuyi@bytedance.com>
To: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Cc: <tglx@kernel.org>, <mingo@redhat.com>, <luto@kernel.org>,
	 <peterz@infradead.org>, <paulmck@kernel.org>,
	<muchun.song@linux.dev>,  <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <pbonzini@redhat.com>,
	 <clrkwllms@kernel.org>, <rostedt@goodmis.org>,
	<nadav.amit@gmail.com>,  <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/5] x86/mm: Decouple kernel TLB flushes from flush_tlb_info
Date: Wed, 23 Sep 2026 18:43:55 +0800	[thread overview]
Message-ID: <956efada-ac6a-413c-ac90-324eae428025@bytedance.com> (raw)
In-Reply-To: <20260923092819.OVgjJ9Gb@linutronix.de>

On 2026-09-23 5:28 p.m., Sebastian Andrzej Siewior wrote:
> On 2026-09-21 17:53:58 [+0800], Chuyi Zhou wrote:
>> --- a/arch/x86/mm/tlb.c
>> +++ b/arch/x86/mm/tlb.c
>> @@ -1487,38 +1487,47 @@ static void invlpgb_kernel_range_flush(struct flush_tlb_info *info)
> …
>>   void flush_tlb_kernel_range(unsigned long start, unsigned long end)
>>   {
>> -	struct flush_tlb_info info;
>> -
>>   	guard(preempt)();
>> -	init_flush_tlb_info(&info, NULL, start, end, PAGE_SHIFT, false,
>> -			    TLB_GENERATION_INVALID);
>>   
>> -	if (info.end == TLB_FLUSH_ALL)
>> +	if (end == TLB_FLUSH_ALL ||
> 
> info.end might be TLB_FLUSH_ALL because init_flush_tlb_info() might set
> it so. But 'end', which is passed as an argument, should not be
> TLB_FLUSH_ALL or can it?
> And if so, wouldn't the check below cover it anyway?

I couldn't find any callers passing TLB_FLUSH_ALL as end.
flush_tlb_kernel_range(start, end) is used to flush actual address
ranges, and flush_tlb_all() is available for unconditional full flushes.
So I agree that we can drop the explicit check.

The ceiling check does not cover all possible inputs, though. For
example, with start = ULONG_MAX - PAGE_SIZE + 1 and end = TLB_FLUSH_ALL,
the expression (end - start) >> PAGE_SHIFT evaluates to zero. The
ceiling check would therefore select a range flush, whereas the explicit
check would select a full flush.

I added the explicit check to preserve that behavior of the old code,
but the current callers do not need it. I'll remove it.



> 
>> +	    tlb_range_exceeds_ceiling(start, end, PAGE_SHIFT))
>>   		kernel_tlb_flush_all();
>>   	else
>> -		kernel_tlb_flush_range(&info);
>> +		kernel_tlb_flush_range(start, end);
>>   }
> 
> Sebastian

  reply	other threads:[~2026-09-23 10:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  9:53 [PATCH 0/5] x86/mm: Allow preemption while waiting for kernel TLB flushes Chuyi Zhou
2026-09-21  9:53 ` [PATCH 1/5] x86/mm: Account for remote kernel TLB flush requests Chuyi Zhou
2026-09-21  9:53 ` [PATCH 2/5] x86/mm: Share the full TLB flush dispatch Chuyi Zhou
2026-09-23  9:17   ` Sebastian Andrzej Siewior
2026-09-23  9:25     ` Chuyi Zhou
2026-09-21  9:53 ` [PATCH 3/5] x86/mm: Extract the TLB range flush threshold check Chuyi Zhou
2026-09-21  9:53 ` [PATCH 4/5] x86/mm: Decouple kernel TLB flushes from flush_tlb_info Chuyi Zhou
2026-09-23  9:28   ` Sebastian Andrzej Siewior
2026-09-23 10:43     ` Chuyi Zhou [this message]
2026-09-23 10:50       ` Sebastian Andrzej Siewior
2026-09-23 10:54         ` Chuyi Zhou
2026-09-21  9:59 ` [PATCH 5/5] x86/mm: Re-enable preemption before waiting for kernel TLB flushes Chuyi Zhou

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=956efada-ac6a-413c-ac90-324eae428025@bytedance.com \
    --to=zhouchuyi@bytedance.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=clrkwllms@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=muchun.song@linux.dev \
    --cc=nadav.amit@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    /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

all inboxes | Powered by JetHome®