Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero

From: Andrew Morton
Date: Wed Oct 16 2019 - 20:50:22 EST


On Wed, 16 Oct 2019 17:07:44 +0800 zhong jiang <zhongjiang@xxxxxxxxxx> wrote:

> >> --- a/mm/gup.c~a
> >> +++ a/mm/gup.c
> >> @@ -1450,6 +1450,7 @@ static long check_and_migrate_cma_pages(
> >> bool drain_allow = true;
> >> bool migrate_allow = true;
> >> LIST_HEAD(cma_page_list);
> >> + long ret;
> >> check_again:
> >> for (i = 0; i < nr_pages;) {
> >> @@ -1511,17 +1512,18 @@ check_again:
> >> * again migrating any new CMA pages which we failed to isolate
> >> * earlier.
> >> */
> >> - nr_pages = __get_user_pages_locked(tsk, mm, start, nr_pages,
> >> + ret = __get_user_pages_locked(tsk, mm, start, nr_pages,
> >> pages, vmas, NULL,
> >> gup_flags);
> >> - if ((nr_pages > 0) && migrate_allow) {
> >> + nr_pages = ret;
> >> + if (ret > 0 && migrate_allow) {
> >> drain_allow = true;
> >> goto check_again;
> >> }
> >> }
> >> - return nr_pages;
> >> + return ret;
> >> }
> >> #else
> >> static long check_and_migrate_cma_pages(struct task_struct *tsk,
> >>
> >
> > +1 for this approach, please.
> >
> >
> > thanks,
> Hi, Andrew
>
> I didn't see the fix for the issue in the upstream. Your proposal should be
> appiled to upstream. Could you appiled the patch or repost by me ?

Forgotten about it ;) Please send a patch sometime?