Re: [PATCH v2] mm: Don't fault around userfaultfd-registered regions on reads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux