Re: [PATCH 6/6] mm: proc: Avoid fullmm flush for young/dirty bit toggling

From: Linus Torvalds
Date: Fri Nov 20 2020 - 12:42:37 EST


On Fri, Nov 20, 2020 at 6:36 AM Will Deacon <will@xxxxxxxxxx> wrote:
>
> Ensure that TLB invalidation is performed after updating soft-dirty
> entries via clear_refs_write() by using the non-fullmm API to MMU gather.

This code sequence looks bogus to begin with.

It does that

tlb_gather_mmu(&tlb, mm, 0, -1);
..
tlb_finish_mmu(&tlb, 0, -1);

around the loop (all, your patch series changes those arguments), but
it doesn't actually use "tlb" anywhere inside the loop itself that I
can see.

Yeah., yeah, it sets the flush_pending thing etc, but that still
sounds fundamentally wrong. It should do the proper range adjustments
if/when it actually wals the range. No?

If I read this all right, it will do a full TLB flush even when it
doesn't do anything (eg CLEAR_REFS_SOFT_DIRTY with no softdirty
pages).

So this looks all kinds of bogus. Not your patch, but the code it patches.

Linus