Re: [RFC 01/20] mm/tlb: fix fullmm semantics

Nadav Amit
2021-02-04T03:21:28Z

> On Feb 3, 2021, at 1:44 AM, Will Deacon <will@kernel.org> wrote:
>
> On Tue, Feb 02, 2021 at 01:35:38PM -0800, Nadav Amit wrote:
>>> On Feb 2, 2021, at 3:00 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>>>
>>> On Tue, Feb 02, 2021 at 01:32:36AM -0800, Nadav Amit wrote:
>>>>> On Feb 1, 2021, at 3:36 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>>>>>
>>>>>
>>>>> https://lkml.kernel.org/r/20210127235347.1402-1-will@kernel.org
>>>>
>>>> I have seen this series, and applied my patches on it.
>>>>
>>>> Despite Will’s patches, there were still inconsistencies between fullmm
>>>> and need_flush_all.
>>>>
>>>> Am I missing something?
>>>
>>> I wasn't aware you were on top. I'll look again.
>>
>> Looking on arm64’s tlb_flush() makes me think that there is currently a bug
>> that this patch fixes. Arm64’s tlb_flush() does:
>>
>> /*
>> * If we're tearing down the address space then we only care about
>> * invalidating the walk-cache, since the ASID allocator won't
>> * reallocate our ASID without invalidating the entire TLB.
>> */
>> if (tlb->fullmm) {
>> if (!last_level)
>> flush_tlb_mm(tlb->mm);
>> return;
>> }
>>
>> But currently tlb_mmu_finish() can mistakenly set fullmm incorrectly (if
>> mm_tlb_flush_nested() is true), which might skip the TLB flush.
>
> But in that case isn't 'freed_tables' set to 1, so 'last_level' will be
> false and we'll do the flush in the code above?

Indeed. You are right. So no rush.