Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp564531ybe; Wed, 4 Sep 2019 04:26:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvmIlvD70Kv99ydllVgCs4axK5ItJQRriPxhgpg3SbV2Dr/44K0kGyRX5Vre1eNTSpxDTI X-Received: by 2002:a63:1743:: with SMTP id 3mr22284427pgx.435.1567596369186; Wed, 04 Sep 2019 04:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567596369; cv=none; d=google.com; s=arc-20160816; b=UuSbfL935Oc0g1g6je0YnxRyZluXW+599e6E6K8IytxcRRu73ILjDavznYJB9ZOhwF 2XjrtaoBYWTnhGL+MAqmBALnfImPMO7UUwfooC+UKWvap8ymo4Cv70Zwa4uq/50nnUiE bYhi7S0RccsU05C52HtVOittVhyi724BlK6rEAhM8mUI453XIT8lNwfZVPv39rSaSU/a wM2B3kWgpk/rg2ip1z8vqmkzpAmA44W44c1vndrjb4E6oe92fv1Q4gwyRUeaK3dywC78 PtnTuj8JSEqGjoVc8fpXjVCOE20gr65ykmgAJ6vk+l8r+qLb2n0COWVKVpvs8bAazExR PNVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=oUU6/+HWzrrcdYaWQfk2iRQtVn2PwfutPwCvSsJCxEc=; b=qQ8Q5uzb70OOAWBjTA9lqUL6QPDk5NS86MburaBemggaOD8DA+E/Il+X7HOuiC6N9F +IkOr33iS4rpBxkBIVyq6ySRqiHQDMI4EnUUGX+NYpKBBwosKml8Hye+QoHAiAJjmFw5 A55C+r0wPqSsmg+YlVx6DyPcmtCASjVyvXZDlAKnajUUY9KtNkJqmd80QOJ4xrD/Sfb8 M8eUcLwVILd2PQDppVt3Rbp0iN8o/enT1bfwZD7GRhYt2Us2NLA67R1Bchz04ljw5Hqu ksmaP0bNpEjg+i+kA5RWx0Wj94x0P3E+Otb+s5DeVLTf6N6AWWmWqd69ghcltdFYft7k oZJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x15si17263481plm.74.2019.09.04.04.25.53; Wed, 04 Sep 2019 04:26:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbfIDLZB (ORCPT + 99 others); Wed, 4 Sep 2019 07:25:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:55568 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726010AbfIDLZA (ORCPT ); Wed, 4 Sep 2019 07:25:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9693EB049; Wed, 4 Sep 2019 11:24:59 +0000 (UTC) Subject: Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero To: zhong jiang , akpm@linux-foundation.org, mhocko@kernel.org Cc: anshuman.khandual@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny , "Aneesh Kumar K.V" References: <1567592763-25282-1-git-send-email-zhongjiang@huawei.com> From: Vlastimil Babka Message-ID: <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> Date: Wed, 4 Sep 2019 13:24:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1567592763-25282-1-git-send-email-zhongjiang@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). > Signed-off-by: zhong jiang 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; > } >