mm/gup.c: Fix return value for __gup_longterm_locked()
Subsystems (2)
PATCH 1/1 mm/gup.c: Fix return value for __gup_longterm_locked()
__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.
--- mm/gup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/gup.c +6 -6
@@ -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); +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); }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)
Signature · 1 line
2.37.2
Quoted 4 lines · Shigeru Yoshida
__get_user_pages_locked()may return the number of pages less thannr_pages. So__gup_longterm_locked()have to return the number of pages__get_user_pages_locked()returns if it succeeded, notnr_pagespassed.
s/passed/requested/
Quoted 8 lines
Fixes 61c63c2076d9 (mm/gup.c: simplify and fix check_and_migrate_movable_pages() return codes)CC Alistair Popple <[email protected]>Reported-by [email protected]Signed-off-by Shigeru Yoshida <[email protected]>--- mm/gup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
(with a couple of nits about line length, below)
Quoted 12 lines
mm/gup.c +1
-1@@ -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;
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm, · line 2079
Quoted 10 lines
mm/gup.c +2
-3if (!(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?
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm, · line 2082
Quoted 4 lines
mm/gup.c +2
-1+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.
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm, · line 2089
Quoted 8 lines
mm/gup.c +1
-1}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,
Signature · 2 lines
John Hubbard NVIDIA
Quoted 11 lines · John Hubbard
Quoted 4 lines · Shigeru Yoshida
__get_user_pages_locked()may return the number of pages less thannr_pages. So__gup_longterm_locked()have to return the number of pages__get_user_pages_locked()returns if it succeeded, notnr_pagespassed.s/passed/requested/
Quoted 2 lines
Fixes 61c63c2076d9 (mm/gup.c: simplify and fix
check_and_migrate_movable_pages()return codes)
Quoted 9 lines
Quoted 6 lines
CC Alistair Popple <[email protected]>Reported-by [email protected]Signed-off-by Shigeru Yoshida <[email protected]>--- mm/gup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)Reviewed-by John Hubbard <[email protected]>
Hi John,
Thank you so much for your review.
I'll send v2 patch.
Shigeru
Quoted 55 lines
(with a couple of nits about line length, below)
mm/gup.c static long __gup_longterm_locked(struct
Quoted 6 lines
mm/gup.c +0
-0@@ -2068,22 +2068,22 @@ static long __gup_longterm_locked(struct
mm_struct*mm,mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm,
Quoted 8 lines
mm/gup.c +1
-1unsigned 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,
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm,
Quoted 4 lines
mm/gup.c +0
-1NULL, gup_flags); flags =memalloc_pin_save (); do { - rc = __get_user_pages_locked(mm, start, nr_pages, pages,vmas,
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm,
Quoted 3 lines
mm/gup.c +1
-2- NULL, gup_flags); -if (rc <=0 ) + nr_pinned_pages = __get_user_pages_locked(mm, start,
nr_pages, pages, vmas,mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm, · line 2079
Quoted 1 line
mm/gup.c +1
-0+ NULL, gup_flags);Can you please wrap at 80 cols, though?
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm,
Quoted 4 lines
mm/gup.c +2
-1+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.
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm, · line 2089
Quoted 8 lines
mm/gup.c +1
-1}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