[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87czcqiecd.fsf@nvdebian.thelocal>
Date: Wed, 24 Aug 2022 11:56:25 +1000
From: Alistair Popple <apopple@...dia.com>
To: "Huang, Ying" <ying.huang@...el.com>
Cc: Peter Xu <peterx@...hat.com>, Nadav Amit <nadav.amit@...il.com>,
huang ying <huang.ying.caritas@...il.com>,
Linux MM <linux-mm@...ck.org>,
Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
"Sierra Guiza, Alejandro (Alex)" <alex.sierra@....com>,
Felix Kuehling <Felix.Kuehling@....com>,
Jason Gunthorpe <jgg@...dia.com>,
John Hubbard <jhubbard@...dia.com>,
David Hildenbrand <david@...hat.com>,
Ralph Campbell <rcampbell@...dia.com>,
Matthew Wilcox <willy@...radead.org>,
Karol Herbst <kherbst@...hat.com>,
Lyude Paul <lyude@...hat.com>, Ben Skeggs <bskeggs@...hat.com>,
Logan Gunthorpe <logang@...tatee.com>, paulus@...abs.org,
linuxppc-dev@...ts.ozlabs.org, stable@...r.kernel.org
Subject: Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page
"Huang, Ying" <ying.huang@...el.com> writes:
> Peter Xu <peterx@...hat.com> writes:
>
>> On Thu, Aug 18, 2022 at 02:34:45PM +0800, Huang, Ying wrote:
>>> > In this specific case, the only way to do safe tlb batching in my mind is:
>>> >
>>> > pte_offset_map_lock();
>>> > arch_enter_lazy_mmu_mode();
>>> > // If any pending tlb, do it now
>>> > if (mm_tlb_flush_pending())
>>> > flush_tlb_range(vma, start, end);
>>> > else
>>> > flush_tlb_batched_pending();
>>>
>>> I don't think we need the above 4 lines. Because we will flush TLB
>>> before we access the pages.
I agree. For migration the TLB flush is only important if the PTE is
present, and in that case we do a TLB flush anyway.
>> Could you elaborate?
>
> As you have said below, we don't use non-present PTEs and flush present
> PTEs before we access the pages.
>
>>> Can you find any issue if we don't use the above 4 lines?
>>
>> It seems okay to me to leave stall tlb at least within the scope of this
>> function. It only collects present ptes and flush propoerly for them. I
>> don't quickly see any other implications to other not touched ptes - unlike
>> e.g. mprotect(), there's a strong barrier of not allowing further write
>> after mprotect() returns.
>
> Yes. I think so too.
>
>> Still I don't know whether there'll be any side effect of having stall tlbs
>> in !present ptes because I'm not familiar enough with the private dev swap
>> migration code. But I think having them will be safe, even if redundant.
What side-effect were you thinking of? I don't see any issue with not
TLB flushing stale device-private TLBs prior to the migration because
they're not accessible anyway and shouldn't be in any TLB.
> I don't think it's a good idea to be redundant. That may hide the real
> issue.
>
> Best Regards,
> Huang, Ying
Thanks all for the discussion. Having done some more reading I agree
that it's safe to assume HW dirty bits are write-through, so will remove
the ptep_clear_flush() and use ptep_get_and_clear() instead. Will split
out the TLB flushing fix into a separate patch in this series.
- Alistair
Powered by blists - more mailing lists