From: Souptick Joarder <jrdr.linux@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: "John Hubbard" <jhubbard@nvidia.com>,
"Tony Luck" <tony.luck@intel.com>,
fenghua.yu@intel.com, "Rob Springer" <rspringer@google.com>,
"Todd Poynor" <toddpoynor@google.com>,
benchan@chromium.org, "Greg KH" <gregkh@linuxfoundation.org>,
"Jens Wiklander" <jens.wiklander@linaro.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
santosh.shilimkar@oracle.com,
"David S. Miller" <davem@davemloft.net>,
kuba@kernel.org, "Ira Weiny" <ira.weiny@intel.com>,
"Jérôme Glisse" <jglisse@redhat.com>,
inux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org,
"open list:ANDROID DRIVERS" <devel@driverdev.osuosl.org>,
tee-dev@lists.linaro.org, Linux-MM <linux-mm@kvack.org>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
rds-devel@oss.oracle.com
Subject: Re: [RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast()
Date: Wed, 6 May 2020 17:51:39 +0530 [thread overview]
Message-ID: <CAFqt6zYaNkJ4AfVzutXS=JsN4fE41ZAvnw03vHWpdyiRHY1m_w@mail.gmail.com> (raw)
In-Reply-To: <20200506100649.GI17863@quack2.suse.cz>
On Wed, May 6, 2020 at 3:36 PM Jan Kara <jack@suse.cz> wrote:
>
> On Wed 06-05-20 02:06:56, Souptick Joarder wrote:
> > On Wed, May 6, 2020 at 1:08 AM John Hubbard <jhubbard@nvidia.com> wrote:
> > >
> > > On 2020-05-05 12:14, Souptick Joarder wrote:
> > > > Currently {get|pin}_user_pages_fast() have 3 return value 0, -errno
> > > > and no of pinned pages. The only case where these two functions will
> > > > return 0, is for nr_pages <= 0, which doesn't find a valid use case.
> > > > But if at all any, then a -ERRNO will be returned instead of 0, which
> > > > means {get|pin}_user_pages_fast() will have 2 return values -errno &
> > > > no of pinned pages.
> > > >
> > > > Update all the callers which deals with return value 0 accordingly.
> > >
> > > Hmmm, seems a little shaky. In order to do this safely, I'd recommend
> > > first changing gup_fast/pup_fast so so that they return -EINVAL if
> > > the caller specified nr_pages==0, and of course auditing all callers,
> > > to ensure that this won't cause problems.
> >
> > While auditing it was figured out, there are 5 callers which cares for
> > return value
> > 0 of gup_fast/pup_fast. What problem it might cause if we change
> > gup_fast/pup_fast
> > to return -EINVAL and update all the callers in a single commit ?
>
> Well, first I'd ask a different question: Why do you want to change the
> current behavior? It's not like the current behavior is confusing. Callers
> that pass >0 pages can happily rely on the simple behavior of < 0 return on
> error or > 0 return if we mapped some pages. Callers that can possibly ask
> to map 0 pages can get 0 pages back - kind of expected - and I don't see
> any benefit in trying to rewrite these callers to handle -EINVAL instead...
Callers with a request to map 0 pages doesn't have a valid use case. But if any
caller end up doing it mistakenly, -errno should be returned to caller
rather than 0
which will indicate more precisely that map 0 pages is not a valid
request from caller.
With these, 3rd return value 0, is no more needed.
That was the thought behind this proposal.
next prev parent reply other threads:[~2020-05-06 12:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 19:14 [RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast() Souptick Joarder
2020-05-05 19:38 ` John Hubbard
2020-05-05 20:36 ` Souptick Joarder
2020-05-05 20:52 ` John Hubbard
2020-05-06 10:06 ` Jan Kara
2020-05-06 12:21 ` Souptick Joarder [this message]
2020-05-06 12:59 ` Jan Kara
2020-05-06 16:08 ` Souptick Joarder
2020-05-07 10:13 ` Jan Kara
2020-05-07 10:32 ` Souptick Joarder
2020-05-07 18:44 ` John Hubbard
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='CAFqt6zYaNkJ4AfVzutXS=JsN4fE41ZAvnw03vHWpdyiRHY1m_w@mail.gmail.com' \
--to=jrdr.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benchan@chromium.org \
--cc=davem@davemloft.net \
--cc=devel@driverdev.osuosl.org \
--cc=fenghua.yu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=inux-ia64@vger.kernel.org \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=jens.wiklander@linaro.org \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rds-devel@oss.oracle.com \
--cc=rspringer@google.com \
--cc=santosh.shilimkar@oracle.com \
--cc=tee-dev@lists.linaro.org \
--cc=toddpoynor@google.com \
--cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).