linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH 1/2] mm/gup: introduce pin_user_pages_locked()
Date: Sun, 31 May 2020 12:52:21 -0700	[thread overview]
Message-ID: <d11d52f8-d54c-bb45-bde9-198235a03921@nvidia.com> (raw)
In-Reply-To: <CAFqt6zZr9rUZaXEpjwmtmicdNP9KhJ8UrjPPjk4bMHJ20VsVsg@mail.gmail.com>

On 2020-05-31 00:04, Souptick Joarder wrote:
...
>> +/*
>> + * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked().
>> + * Behavior is the same, except that this one sets FOLL_PIN and rejects
>> + * FOLL_GET.
>> + */
>> +long pin_user_pages_locked(unsigned long start, unsigned long nr_pages,
>> +                          unsigned int gup_flags, struct page **pages,
>> +                          int *locked)
>> +{
>> +       /*
>> +        * FIXME: Current FOLL_LONGTERM behavior is incompatible with
>> +        * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on
>> +        * vmas.  As there are no users of this flag in this call we simply
>> +        * disallow this option for now.
>> +        */
>> +       if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM))
>> +               return -EINVAL;
>> +
>> +       /* FOLL_GET and FOLL_PIN are mutually exclusive. */
>> +       if (WARN_ON_ONCE(gup_flags & FOLL_GET))
>> +               return -EINVAL;
>> +
>> +       gup_flags |= FOLL_PIN;
> 
> Right now get_user_pages_locked() doesn't have similar check for FOLL_PIN

Yes, that should be added...

> and also not setting FOLL_GET internally irrespective of gup_flags
> passed by user.
> Do we need to add the same in get_user_pages_locked() ?

...and no, that should not.

Yes, it's prudent to assert that FOLL_PIN is *not* set, at all the
get_user_pages*() API calls, thanks for spotting that. I'll add that to
this patch and send out a v2.

The same check should also be added to get_user_pages_unlocked(). I'll send
out a correction (I think just a v3 of that patchset) to add that.

The setting of FOLL_GET, on the other hand, is something best left as-is
so far. Some call sites set FOLL_GET, some want it *not* set, and some
expect that FOLL_GET is implied, and at the moment, the delicate balance is
correct. :)


thanks,
-- 
John Hubbard
NVIDIA


  parent reply	other threads:[~2020-05-31 19:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 22:32 [PATCH 0/2] mm/gup: introduce pin_user_pages_locked(), use it in frame_vector.c John Hubbard
2020-05-27 22:32 ` [PATCH 1/2] mm/gup: introduce pin_user_pages_locked() John Hubbard
2020-05-28  8:43   ` David Hildenbrand
2020-05-31  7:04   ` Souptick Joarder
2020-05-31  7:13     ` Souptick Joarder
2020-05-31 19:56       ` John Hubbard
2020-05-31 19:52     ` John Hubbard [this message]
2020-05-31 13:03   ` Pankaj Gupta
2020-05-27 22:32 ` [PATCH 2/2] mm/gup: frame_vector: convert get_user_pages() --> pin_user_pages() John Hubbard
2020-05-28  8:46   ` 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=d11d52f8-d54c-bb45-bde9-198235a03921@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=jrdr.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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).