linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Weiny, Ira" <ira.weiny@intel.com>
To: Vlastimil Babka <vbabka@suse.cz>,
	zhong jiang <zhongjiang@huawei.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"mhocko@kernel.org" <mhocko@kernel.org>
Cc: "anshuman.khandual@arm.com" <anshuman.khandual@arm.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Subject: RE: [PATCH] mm: Unsigned 'nr_pages' always larger than zero
Date: Wed, 4 Sep 2019 18:25:19 +0000	[thread overview]
Message-ID: <2807E5FD2F6FDA4886F6618EAC48510E898E9559@CRSMSX101.amr.corp.intel.com> (raw)
In-Reply-To: <5505fa16-117e-8890-0f48-38555a61a036@suse.cz>

> On 9/4/19 12:26 PM, zhong jiang wrote:
> > With the help of unsigned_lesser_than_zero.cocci. Unsigned 'nr_pages"'
> > compare with zero. And __get_user_pages_locked will return an long
> value.
> > Hence, Convert the long to compare with zero is feasible.
> 
> It would be nicer if the parameter nr_pages was long again instead of
> unsigned long (note there are two variants of the function, so both should be
> changed).

Why?  What does it mean for nr_pages to be negative?  The check below seems valid.  Unsigned can be 0 so the check can fail.  IOW Checking unsigned > 0 seems ok.

What am I missing?

Ira

> 
> > Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> 
> Fixes: 932f4a630a69 ("mm/gup: replace get_user_pages_longterm() with
> FOLL_LONGTERM")
> 
> (which changed long to unsigned long)
> 
> AFAICS... stable shouldn't be needed as the only "risk" is that we goto
> check_again even when we fail, which should be harmless.
> 
> Vlastimil
> 
> > ---
> >  mm/gup.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/gup.c b/mm/gup.c
> > index 23a9f9c..956d5a1 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -1508,7 +1508,7 @@ static long check_and_migrate_cma_pages(struct
> task_struct *tsk,
> >  						   pages, vmas, NULL,
> >  						   gup_flags);
> >
> > -		if ((nr_pages > 0) && migrate_allow) {
> > +		if (((long)nr_pages > 0) && migrate_allow) {
> >  			drain_allow = true;
> >  			goto check_again;
> >  		}
> >


  reply	other threads:[~2019-09-04 18:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 10:26 [PATCH] mm: Unsigned 'nr_pages' always larger than zero zhong jiang
2019-09-04 11:24 ` Vlastimil Babka
2019-09-04 18:25   ` Weiny, Ira [this message]
2019-09-04 18:39     ` Matthew Wilcox
2019-09-04 18:48   ` Andrew Morton
2019-09-04 20:20     ` Weiny, Ira
2019-09-04 20:40     ` Vlastimil Babka
2019-09-05  6:18     ` zhong jiang
2019-09-05  7:19       ` Vlastimil Babka
2019-09-05  6:19     ` John Hubbard
2019-10-16  9:07       ` zhong jiang
2019-10-17  0:49         ` Andrew Morton
2019-10-17  1:38           ` zhong jiang
2019-09-04 19:01   ` Andrew Morton
2019-09-04 20:44     ` Vlastimil Babka
2019-09-05  2:05   ` zhong jiang
2019-10-17  3:19 zhong jiang
2019-10-17 18:01 ` Ira Weiny
2019-10-18  2:01   ` zhong jiang
2019-10-17 20:42 ` John Hubbard
2019-10-18  2:15   ` zhong jiang
2019-10-18 14:00   ` zhong jiang
2019-10-18 16:07     ` Alexander Duyck
2019-10-21 15:11       ` zhong jiang
2019-10-21 12:57   ` Vlastimil Babka
2019-10-21 13:47     ` zhong jiang

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=2807E5FD2F6FDA4886F6618EAC48510E898E9559@CRSMSX101.amr.corp.intel.com \
    --to=ira.weiny@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=zhongjiang@huawei.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).