From: Alistair Popple <apopple@nvidia.com>
To: huang ying <huang.ying.caritas@gmail.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, "Sierra Guiza,
Alejandro (Alex)" <alex.sierra@amd.com>,
Felix Kuehling <Felix.Kuehling@amd.com>,
Jason Gunthorpe <jgg@nvidia.com>,
John Hubbard <jhubbard@nvidia.com>,
David Hildenbrand <david@redhat.com>,
Ralph Campbell <rcampbell@nvidia.com>,
Matthew Wilcox <willy@infradead.org>,
Karol Herbst <kherbst@redhat.com>, Lyude Paul <lyude@redhat.com>,
Ben Skeggs <bskeggs@redhat.com>,
Logan Gunthorpe <logang@deltatee.com>,
linuxram@us.ibm.com, paulus@ozlabs.org,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH 1/2] mm/migrate_device.c: Copy pte dirty bit to page
Date: Wed, 17 Aug 2022 11:27:17 +1000 [thread overview]
Message-ID: <87a683veip.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <CAC=cRTO6nWGus4v=MhZZeE9hdjM2A5bChHHU_tSbtFD95fFi9w@mail.gmail.com>
huang ying <huang.ying.caritas@gmail.com> writes:
> On Tue, Aug 16, 2022 at 10:33 AM Alistair Popple <apopple@nvidia.com> wrote:
>>
>>
>> huang ying <huang.ying.caritas@gmail.com> writes:
>>
>> > Hi, Alistair,
>> >
>> > On Fri, Aug 12, 2022 at 1:23 PM Alistair Popple <apopple@nvidia.com> wrote:
>
> [snip]
>
>>
>> > And I don't know why we use ptep_get_and_clear() to clear PTE if
>> > (!anon_exclusive). Why don't we need to flush the TLB?
>>
>> We do the TLB flush at the end if anything was modified:
>>
>> /* Only flush the TLB if we actually modified any entries */
>> if (unmapped)
>> flush_tlb_range(walk->vma, start, end);
>>
>> Obviously I don't think that will work correctly now given we have to
>> read the dirty bits and clear the PTE atomically. I assume it was
>> originally written this way for some sort of performance reason.
>
> Thanks for pointing this out. If there were parallel page table
> operations such as mprotect() or munmap(), the delayed TLB flushing
> mechanism here may have some problem. Please take a look at the
> comments of flush_tlb_batched_pending() and TLB flush batching
> implementation in try_to_unmap_one(). We may need to flush TLB with
> page table lock held or use a mechanism similar to that in
> try_to_unmap_one().
Thanks for the pointers. I agree there is likely also a problem here
with the delayed TLB flushing. v2 of this patch deals with this by
always flushing the TLB using ptep_flush_clear(), similar to how
try_to_migrate_one() works. It looks like it could be worth
investigating using batched TLB flushing for both this and
try_to_migrate(), but I will leave that for a future optimisation.
> Best Regards,
> Huang, Ying
prev parent reply other threads:[~2022-08-17 1:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 5:22 [PATCH 1/2] mm/migrate_device.c: Copy pte dirty bit to page Alistair Popple
2022-08-12 5:22 ` [PATCH 2/2] selftests/hmm-tests: Add test for dirty bits Alistair Popple
2022-08-12 7:58 ` Mika Penttilä
2022-08-15 2:35 ` Alistair Popple
2022-08-15 3:11 ` Mika Penttilä
2022-08-15 3:21 ` Alistair Popple
2022-08-15 4:05 ` Mika Penttilä
2022-08-15 4:06 ` Mika Penttilä
2022-08-15 20:29 ` [PATCH 1/2] mm/migrate_device.c: Copy pte dirty bit to page Peter Xu
2022-08-16 0:51 ` Alistair Popple
2022-08-16 1:39 ` huang ying
2022-08-16 2:28 ` Alistair Popple
2022-08-16 6:37 ` huang ying
2022-08-17 1:27 ` Alistair Popple [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a683veip.fsf@nvdebian.thelocal \
--to=apopple@nvidia.com \
--cc=Felix.Kuehling@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alex.sierra@amd.com \
--cc=bskeggs@redhat.com \
--cc=david@redhat.com \
--cc=huang.ying.caritas@gmail.com \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=kherbst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxram@us.ibm.com \
--cc=logang@deltatee.com \
--cc=lyude@redhat.com \
--cc=paulus@ozlabs.org \
--cc=peterx@redhat.com \
--cc=rcampbell@nvidia.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.