From: David Hildenbrand <david@redhat.com>
To: Suren Baghdasaryan <surenb@google.com>,
Matthew Wilcox <willy@infradead.org>
Cc: Lokesh Gidra <lokeshgidra@google.com>,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@android.com,
aarcange@redhat.com, peterx@redhat.com,
zhengqi.arch@bytedance.com, kaleshsingh@google.com,
ngeoffray@google.com
Subject: Re: [PATCH] userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE
Date: Thu, 4 Apr 2024 22:15:57 +0200 [thread overview]
Message-ID: <adce9a6f-fccf-4c9b-8ca3-3140a6a3d326@redhat.com> (raw)
In-Reply-To: <CAJuCfpHvb5Jt6J1P9aHVdRWYUHmBL1edfp7QHn=jF88gJRD7RA@mail.gmail.com>
On 04.04.24 22:07, Suren Baghdasaryan wrote:
> On Thu, Apr 4, 2024 at 10:21 AM Matthew Wilcox <willy@infradead.org> wrote:
>>
>> On Thu, Apr 04, 2024 at 10:17:26AM -0700, Lokesh Gidra wrote:
>>> - folio_move_anon_rmap(src_folio, dst_vma);
>>> - WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
>>> -
>>> src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
>>> /* Folio got pinned from under us. Put it back and fail the move. */
>>> if (folio_maybe_dma_pinned(src_folio)) {
>>> @@ -2270,6 +2267,9 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
>>> goto unlock_ptls;
>>> }
>>>
>>> + folio_move_anon_rmap(src_folio, dst_vma);
>>> + WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
>>> +
>>
>> This use of WRITE_ONCE scares me. We hold the folio locked. Why do
>> we need to use WRITE_ONCE? Who's looking at folio->index without
>> holding the folio lock?
>
> Indeed that seems to be unnecessary here. Both here and in
> move_present_pte() we are holding folio lock while moving the page. I
> must have just blindly copied that from Andrea's original patch [1].
Agreed, I don't think it is required for ->index. (I also don't spot any
corresponding READ_ONCE)
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-04 20:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 17:17 Lokesh Gidra
2024-04-04 17:21 ` Matthew Wilcox
2024-04-04 20:07 ` Suren Baghdasaryan
2024-04-04 20:15 ` David Hildenbrand [this message]
2024-04-04 20:23 ` Suren Baghdasaryan
2024-04-04 20:37 ` Andrew Morton
2024-04-04 20:32 ` Peter Xu
2024-04-04 20:55 ` Suren Baghdasaryan
2024-04-04 21:04 ` Peter Xu
2024-04-04 21:07 ` Suren Baghdasaryan
2024-04-10 17:09 ` Peter Xu
2024-04-04 20:17 ` David Hildenbrand
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=adce9a6f-fccf-4c9b-8ca3-3140a6a3d326@redhat.com \
--to=david@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=kaleshsingh@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=ngeoffray@google.com \
--cc=peterx@redhat.com \
--cc=surenb@google.com \
--cc=willy@infradead.org \
--cc=zhengqi.arch@bytedance.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®