Re: [PATCh 0/3] x86,tlb: context switch optimizations

From: Peter Zijlstra
Date: Thu Nov 14 2024 - 09:40:39 EST


On Thu, Nov 14, 2024 at 09:27:25AM -0500, Rik van Riel wrote:

> 1) Move the interrupt re-enabling up (probably not this one?)

Correct, that one is wrong for it results in IPIs that we don't want or
need.

> 2) Explicitly clear the mm_cpumask bit in unuse_temporary_mm()
>
> 3) Have unuse_temporary_mm increment the mm's tlb_gen, since that
> is the only thing flush_tlb_mm_range really does for an MM
> without any bits set in the mm_cpumask.

So flush_tlb_mm_range() has an 'mm == loaded_mm' case, which does a
local flush. I *think* we're not hitting that because switch_mm() does a
write to loaded_mm() just before this.

But I don't think we want to proliferate the logic contained in
flush_tlb_mm_range() further than we have to.

So my preference goes to 2, as that seems to be the safest option.
Notably text_poke() it not concerned with performance much.