Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp454762ybe; Thu, 5 Sep 2019 00:05:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyN0zjMxYeGaYyEW1N0PVYUT7y2Bu8zFcPHwLcsHSDl6EMF0PHW6kMWOVE6hd6965okQUgR X-Received: by 2002:a17:90a:ac13:: with SMTP id o19mr2275558pjq.134.1567667150465; Thu, 05 Sep 2019 00:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567667150; cv=none; d=google.com; s=arc-20160816; b=sFpYcHRkusl4l+EMowRbSD6eodOzzYvYq8UEMvrXq8kOVTJ4+1pZbf1gDyZkI+zu/w e3aUMQKtXfzrIJ1rQUobTkugSWIkpAT6DPmGfRM/4A+yD5bY4N5zRsy/AMaTyrkUXVEl 4KVRo8SN7JgIkMVawuIliInF4LUrs8BHRDjNEvGG5WF+B/XRHc+Af8tR+IUkf/+5V5g+ gQ01OQO7LqvTW7wUi78D/ii4iE7Vhm1msgfRgytHvQNluGR7XtQvvBkC2ldcZZQoGvh3 QRPQwbjLnvFyA+cYvwiajQKsfxUi20HciIkVmerZlKIw+dk9beBng58p5sjgSymKTUhx J1vQ== 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=SylB7oi3HQveIXInS0iRVzWOLMtjEbsx9JoAnTbeeoc=; b=jbkaeQpzSWmaNzdJIM+eAtrEt6srxD+sWOmXi6pK8Wffl6IRaVdgAPbYL7Cff3PjAI 5wCEk2SlgVXQvwnZAaSnV9fo3WBKgspe3VWw0bycdkS8+c4DZoO/oz8ylUI/v1wtyEZz lws1jhf4YMQvdZAA4MtS5iT5ZMwUpbfG1FclNIVN/L/Y2Kr+ELjyu5Q3amT3lz1Nzser k9UxiPaI9H7kaDGAwMdbeTZua2Bn+MsrZLirtqjL8IuwrrGA2vogtRSt8w1Hnvb8BUXo qE4qZ4CfYQJgU5F3cQ9F4t2Dv62Au+eWXAlTxrfxUvyQInivi4ZJUpvDZ8K6Rxk5OOFl ZXRA== 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 r16si981312pgh.385.2019.09.05.00.05.34; Thu, 05 Sep 2019 00:05:50 -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 S1731486AbfIEGZJ (ORCPT + 99 others); Thu, 5 Sep 2019 02:25:09 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33254 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731231AbfIEGZI (ORCPT ); Thu, 5 Sep 2019 02:25:08 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 04943DFB539C480715D5; Thu, 5 Sep 2019 14:09:32 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Thu, 5 Sep 2019 14:09:26 +0800 Message-ID: <5D70A695.60706@huawei.com> Date: Thu, 5 Sep 2019 14:09:25 +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: Matthew Wilcox CC: , , , , Subject: Re: [PATCH v2] mm: Unsigned 'nr_pages' always larger than zero References: <1567649871-60594-1-git-send-email-zhongjiang@huawei.com> <20190905031252.GN29434@bombadil.infradead.org> In-Reply-To: <20190905031252.GN29434@bombadil.infradead.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit 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/5 11:12, Matthew Wilcox wrote: > On Thu, Sep 05, 2019 at 10:17:51AM +0800, zhong jiang wrote: >> With the help of unsigned_lesser_than_zero.cocci. Unsigned 'nr_pages' >> compare with zero. And __gup_longterm_locked pass an long local variant >> 'rc' to check_and_migrate_cma_pages. Hence it is nicer to change the >> parameter to long to fix the issue. > I think this patch is right, but I have concerns about this cocci grep. > > The code says: > > if ((nr_pages > 0) && migrate_allow) { > > There's nothing wrong with this (... other than the fact that nr_pages might > happen to be a negative errno). nr_pages might be 0, and this would be > exactly the right test for that situation. I suppose some might argue > that this should be != 0 instead of > 0, but it depends on the situation > which one would read better. > > So please don't blindly make these changes; you're right this time. Thanks for your affirmation. but Andrew come up with anther fix, using an local long variant to store the nr_pages. which one do you prefer ? Thanks, zhong jiang