Re: [PATCH v9 10/12] x86/mm: do targeted broadcast flushing from tlbbatch code

Rik van Riel
2025-02-11T20:21:40Z

On Tue, 2025-02-11 at 11:02 +0100, Brendan Jackman wrote:
>
> So I think here we're encoding the assumption that context_switch()
> always calls either enter_lazy_tlb() or switch_mm_irqs_off(), which
> is
> a little awkward, plus the job of these functions is already kinda
> hazy and this makes it even hazier. What about doing it in
> arch_start_context_switch() instead?
>
> That would mean a bit of plumbing since we'd still wanna have the
> tlbsync() in tlb.c, but that seems worth it to me. Plus, having it in
> one place would give us a spot to add a comment. Now that you point
> it
> out it does indeed seem obvious but it didn't seem so yesterday.
>
While that would be a little bit cleaner to maintain,
in theory, I'm not convinced that adding an extra
function call to the context switch path is worthwhile
for that small maintenance benefit.

I'd rather add more comments than an extra function call :)

> Now I think about it... if we always tlbsync() before a context
> switch, is the cant_migrate() above actually required?

Probably not, but I guess it won't hurt?

I'm running tests right now on a kernel with a bunch
of debug options enabled, and I'm getting all sorts
of warnings, but not this one :)

--
All Rights Reversed.