Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp254401ybe; Wed, 4 Sep 2019 19:20:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlfFHV+NvR9OPIpYIs72SCtMxxMk6P+ttI9QFsTkR5Otqwi9N/RoTHjn58D2z0+wcXDA0B X-Received: by 2002:a63:2903:: with SMTP id p3mr1012292pgp.306.1567650024468; Wed, 04 Sep 2019 19:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567650024; cv=none; d=google.com; s=arc-20160816; b=aP1Y7AvoEWh7/Mv+QHj66gflGLPg8CHtbgcXe/+hBOzAJSkHGi0OxAp5ahmSoFzFGt 9Y05eEwGkvZtGJEthRUXM4WxyRcdFWAUZ/e4CGX/bAzYbggI/R42N+KYKVU1O6rTlmYg H5YZG53v8qUEPdZWS3nzgJt0Pa9Y8NOsJlkPfAsjG4MU/PQCWjL+RfbKMDk1uuFpkbPG TV5mkKEoPM29fH7Eor0Qjkj3pjKyJtLc5qGaV+WSULfgcdVhBBC2YWm7ZKS0PsCDhBnH IDPtIGH9oVebh1Murz8rEGSDZkFMythp3Zb07U9FjcZBHoxv115ETsnevsNsWv5XL5TH RSgw== 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:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=J4pOw4eZCd3ppovLcSbFy2qU4n97VzyKRnLRKqFiO80=; b=QG9SlPzWDeWMXusc18eYBxFf77F9/cIRkVU1JvOMYUICpyXMFgbWoy3fFJJGfOERIN amzzNAgY6gAvrYjZoiBpJ8RLZ4n293/5N4W4d0SbkJnwPDcpSLmWrrA8SJz8w0niR8Wl zuf3ltpr6U8Ir2YMJuIMKCK1EvfIXEnvZWI3FeDQQEt2Lgi9Z9sEmHgeYmCF66hnQCV2 2WTcRxNAr53B3UfytZu3XLcHbnDN4DtOycpo1Yi00+z1lRqkQBXSbMDtkMK9CioKGr/6 9nu51hmaR/c2W53AgIGJ3G/fLetVRaLoI61eB2OjRQCKic7xq5UBjUgSwb+dZ92MCuP7 2+Mg== 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 k8si462488pgi.49.2019.09.04.19.20.08; Wed, 04 Sep 2019 19:20:24 -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 S1730780AbfIECFJ (ORCPT + 99 others); Wed, 4 Sep 2019 22:05:09 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6214 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727162AbfIECFJ (ORCPT ); Wed, 4 Sep 2019 22:05:09 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C90804BEDD822EA701C6; Thu, 5 Sep 2019 10:05:07 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Thu, 5 Sep 2019 10:05:04 +0800 Message-ID: <5D706D50.3090305@huawei.com> Date: Thu, 5 Sep 2019 10:05:04 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Vlastimil Babka CC: , , , , , Ira Weiny , "Aneesh Kumar K.V" Subject: Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero References: <1567592763-25282-1-git-send-email-zhongjiang@huawei.com> <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> In-Reply-To: <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/9/4 19:24, Vlastimil Babka wrote: > 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). Yep, the parameter 'nr_pages' was changed to long. and the variants ‘i、step’ should be changed accordingly. >> 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. Agreed, Thanks. Sincerely, zhong jiang > 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; >> } >> > > . >