From: John Hubbard <jhubbard@nvidia.com>
To: Shigeru Yoshida <syoshida@redhat.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Alistair Popple <apopple@nvidia.com>,
syzbot+616ff0452fec30f4dcfd@syzkaller.appspotmail.com
Subject: Re: [PATCH] mm/gup.c: Fix return value for __gup_longterm_locked()
Date: Sun, 21 Aug 2022 17:14:01 -0700 [thread overview]
Message-ID: <7398324a-2134-3501-ca81-67a56a4c8629@nvidia.com> (raw)
In-Reply-To: <20220821183547.950370-1-syoshida@redhat.com>
On 8/21/22 11:35, Shigeru Yoshida wrote:
> __get_user_pages_locked() may return the number of pages less than
> nr_pages. So __gup_longterm_locked() have to return the number of
> pages __get_user_pages_locked() returns if it succeeded, not nr_pages
> passed.
s/passed/requested/
>
> Fixes: 61c63c2076d9 (mm/gup.c: simplify and fix check_and_migrate_movable_pages() return codes)
> CC: Alistair Popple <apopple@nvidia.com>
> Reported-by: syzbot+616ff0452fec30f4dcfd@syzkaller.appspotmail.com
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
> ---
> mm/gup.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
(with a couple of nits about line length, below)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 5aa7531a703b..542cf74c59b0 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2068,22 +2068,22 @@ static long __gup_longterm_locked(struct mm_struct *mm,
> unsigned int gup_flags)
> {
> unsigned int flags;
> - long rc;
> + long rc, nr_pinned_pages;
>
> if (!(gup_flags & FOLL_LONGTERM))
> return __get_user_pages_locked(mm, start, nr_pages, pages, vmas,
> NULL, gup_flags);
> flags = memalloc_pin_save();
> do {
> - rc = __get_user_pages_locked(mm, start, nr_pages, pages, vmas,
> - NULL, gup_flags);
> - if (rc <= 0)
> + nr_pinned_pages = __get_user_pages_locked(mm, start, nr_pages, pages, vmas,
> + NULL, gup_flags);
Can you please wrap at 80 cols, though?
> + if (nr_pinned_pages <= 0)
> break;
> - rc = check_and_migrate_movable_pages(rc, pages, gup_flags);
> + rc = check_and_migrate_movable_pages(nr_pinned_pages, pages, gup_flags);
Also here.
> } while (rc == -EAGAIN);
> memalloc_pin_restore(flags);
>
> - return rc ? rc : nr_pages;
> + return rc ? rc : nr_pinned_pages;
> }
>
> static bool is_valid_gup_flags(unsigned int gup_flags)
thanks,
--
John Hubbard
NVIDIA
prev parent reply other threads:[~2022-08-22 0:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-21 18:35 [PATCH] mm/gup.c: Fix return value for __gup_longterm_locked() Shigeru Yoshida
2022-08-22 0:14 ` John Hubbard [this message]
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=7398324a-2134-3501-ca81-67a56a4c8629@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=syoshida@redhat.com \
--cc=syzbot+616ff0452fec30f4dcfd@syzkaller.appspotmail.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).