From: Peter Xu <peterx@redhat.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH v2] mm: Don't fault around userfaultfd-registered regions on reads
Date: Fri, 4 Dec 2020 14:23:29 -0500 [thread overview]
Message-ID: <20201204192329.GP108496@xz-x1> (raw)
In-Reply-To: <X8p8KNJXD3aK9TkF@redhat.com>
Hi, Andrea,
On Fri, Dec 04, 2020 at 01:12:56PM -0500, Andrea Arcangeli wrote:
> On Thu, Dec 03, 2020 at 11:10:18PM -0500, Andrea Arcangeli wrote:
> > from the pte, one that cannot ever be set in any swp entry today. I
> > assume it can't be _PAGE_SWP_UFFD_WP since that already can be set but
> > you may want to verify it...
>
> I thought more about the above, and I think the already existing
> pte_swp_mkuffd_wp will just be enough without having to reserve an
> extra bitflag if we encode it as a non migration entry.
>
> The check:
>
> if (!pte_present && !pte_none && pte_swp_uffd_wp && not_anonymous_vma && !is_migration_entry)
[1]
>
> should be enough to disambiguate it. When setting it, it'd be enough
> to set the pte to the value _PAGE_SWP_UFFD_WP.
>
> Although if you prefer to check for:
>
> if (!pte_present && !pte_none && swp_type == 1 && swp_offset == 0 && not_anonymous_vma && !is_migration_entry)
[2]
>
> that would do as well.
>
> It's up to you, just my preference is to reuse _PAGE_SWP_UFFD_WP since
> it has already to exist, there are already all the pte_swp_*uffd*
> methods available or uffd-wp cannot work.
Yes, I had the same thought that it would be nice if this special pte can be
still related to _PAGE_SWP_UFFD_WP.
To me, above [2] looks exactly the same as Hugh suggested to check against
swp_type==1 && swp_offset==0, since:
- do_swap_page() basically already means "!pte_present && !pte_none"
- "not_anonymous_vma" seems optional if uffd-wp+shmem will be the first user
of such a swp entry
- "!is_migration_entry" seems optional since if swp_type==1, it will never be
a migration entry
While for above [1] that's the thing I asked besides the current type==1 &
offset=0 proposal. Quotting one of the previous emails:
> So I guess I'll start with type==1 && offset==0.
>
> (PS: I still think "swp_entry(0, _UFFD_SWP_UFFD_WP) && !vma_is_anonymous(vma)"
> could also be a good candidate comparing to "swp_entry(1, 0)" considering
> type==1 here is kind of randomly chosen from all the other numbers except 0;
> but maybe that's not extremely important - the major logic should be the same)
If we see [1]:
if (!pte_present && !pte_none && pte_swp_uffd_wp && not_anonymous_vma && !is_migration_entry)
Then it's fundamentally the same as:
swp_entry(0, _UFFD_SWP_UFFD_WP) && !vma_is_anonymous(vma)
Reasons similar to above.
Thanks!
--
Peter Xu
next prev parent reply other threads:[~2020-12-04 19:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 23:06 [PATCH v2] mm: Don't fault around userfaultfd-registered regions on reads Peter Xu
2020-12-01 9:30 ` David Hildenbrand
2020-12-01 12:59 ` Matthew Wilcox
2020-12-01 22:30 ` Peter Xu
2020-12-02 0:02 ` Andrea Arcangeli
2020-12-02 22:37 ` Hugh Dickins
2020-12-02 23:41 ` Peter Xu
2020-12-03 5:36 ` Hugh Dickins
2020-12-03 18:02 ` Peter Xu
2020-12-03 19:44 ` Andrea Arcangeli
2020-12-04 2:30 ` Peter Xu
2020-12-04 4:10 ` Andrea Arcangeli
2020-12-04 5:59 ` Hugh Dickins
2020-12-04 16:50 ` Peter Xu
2020-12-04 18:12 ` Andrea Arcangeli
2020-12-04 19:23 ` Peter Xu [this message]
2020-12-04 19:37 ` Andrea Arcangeli
2020-12-04 20:21 ` Peter Xu
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=20201204192329.GP108496@xz-x1 \
--to=peterx@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).