Re: [PATCH v11 06/12] x86/mm: use INVLPGB for kernel TLB flushes
From: Yosry Ahmed
Date: Fri Feb 14 2025 - 21:09:15 EST
On Fri, Feb 14, 2025 at 08:25:51PM -0500, Rik van Riel wrote:
> On Fri, 2025-02-14 at 11:55 -0800, Dave Hansen wrote:
> >
> > Fair enough. If we don't have a better name, we can at least do:
> >
> > if (new_bad_name()) {
> > new_thing();
> > } else {
> > old_thing();
> > }
> >
> > My real heartburn is with:
> >
> > if (new_bad_name()) {
> > new_thing();
> > } else if (need_thing_1()) {
> > old_thing1();
> > } else {
> > old_thing2();
> > }
> >
> > Where new and old are logically squished together.
> >
> Do we want to group this code by history, or
> by function?
>
> I would argue that new_thing() and old_thing1()
> are closer to each other functionally (they both
> do remote TLB invalidation) than they are to
> old_thing2(), which does local-only invalidation.
>
> I can organize the code however people want,
> but I would like a second opinion on this idea :)
IIUC the discussion is about:
if (broadcast_kernel_range_flush(info))
; /* Fall through. */
else if (info->end == TLB_FLUSH_ALL)
on_each_cpu(do_flush_tlb_all, NULL, 1);
else
on_each_cpu(do_kernel_range_flush, info, 1);
In this case I agree with Dave. old_thing1() and old_thing2() are both
sending IPIs, the difference is that old_thing1() is doing a full flush
while old_thing2() is doing a range flush. Not sure why you mentioned
that old_thing2() does local invalidation.
broadcast_kernel_range_flush() also decides between full and range
flushes internally. So the main difference between 'new' and 'old' here
is using the broadcast flush vs the IPI flush.
So I think what Dave wants (and I agree) is:
if (!broadcast_kernel_range_flush(info))
ipi_kernel_range_flush(info)
Where ipi_kernel_range_flush() contains old_thing1() and oldthing2().
> --
> All Rights Reversed.
>