Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1046553ybe; Wed, 4 Sep 2019 11:41:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlky3qR3WXWsCX0JYkeiAX9r00LvmZHW1abxZEQXbPniSDNWumyPW5jNRJSq03lUnZNRf7 X-Received: by 2002:a17:90a:1110:: with SMTP id d16mr6658316pja.29.1567622508283; Wed, 04 Sep 2019 11:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567622508; cv=none; d=google.com; s=arc-20160816; b=ZzrhoJ44iAi4mywRpypGKVz1h9fpZHGb/QafVUTwGoiLyGe3+/IOy6FIoHQh1j4a0A MDkCRQV8Kg9TPh6Khfo+6ZKarYRhy2Cf2rUT42CtRhlQCLRADtm/6QppBZalshBQ1j9i oZ/DYmORSD/XxMB3/CMUWQGZZrfXnA25if4ja/GgZb6Bk9l6YXZepDuUfmCOaaV4p8+1 zOyYvNfa4aTLXS+vdw9J9kqcSFm/xZCODmqWNIOKEyEUxBzUDLXiAYG2tuq2yKjWqkjN vbRQYU/jpyfOWnKnS+iS9fsglkuVVe0hWTWmg3vBdiq/5JbwwaqVIfK/h2I8buh0LBSe K8Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yERScqNIF39dI0X95RDXlycUNcqsABfDkiiYU0N0y6w=; b=eFWHusBdEyswp+pkFFE3JJQ5zFCvkLJU5Odyezc6Tf2UHI3t2mIKftNw2uaxgurmWj JnXUFXx8GPzkQwkqU4qpCXEBZxZcJkbNZ1UOi9LDn92+dxT3RpPKru0KvCvXf1ufU0Y9 OApPpVVgLtomfxCT6Eesy1uhoz2/ZsqR/z0iyUbGIqQZt2pd7YU4MVwHxantiZGvjXCg p+E/psi2UTyjTVUJ68y4+kQ7Zfz4hJEyrkwkZvLrY5Nd+THF4WJxqYC1yS6o4TRVh3YD rrSbFo+HfSi8kZzc7kgOQPGjo+89RtdxqJV1Jb3fgUV6Qdq9+04ZFVhW7PzuA33hEsuc v57g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=C91q5g6w; 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 k20si13989609pll.184.2019.09.04.11.41.32; Wed, 04 Sep 2019 11:41:48 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=C91q5g6w; 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 S2387424AbfIDSkI (ORCPT + 99 others); Wed, 4 Sep 2019 14:40:08 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35638 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730209AbfIDSkH (ORCPT ); Wed, 4 Sep 2019 14:40:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yERScqNIF39dI0X95RDXlycUNcqsABfDkiiYU0N0y6w=; b=C91q5g6wf8Un02twMhuc1wem4 lh8cE7eHxYptydS+Kuq23QypIA6dXMbY1OEEpkBg8JXSWwuvbFQajQodSHGbTIBA2O+eLFX0ui/rn rgWcKNIcmfFIdqoXFWRoLkVHFiVC10rUfMqDGISiy3nEpDiLUnp5QBVWCUivvZyU9odUyNeSykLMG tCpJydUovjDXSf0QeWfCfIinn0YqJ36HnF5x2Ldp/jYB5HPz7RSPZXHGU/ZSJv8TkcDAADsuO0H5I xTfAOtk8GUoNzV231PSwWa3BMNqfu77YUCYp9058XMvELRsY/oIBjsmJQqBSDt1GBzWK38c/FKKW8 qKMuhhwpQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1i5aCE-0000h3-PQ; Wed, 04 Sep 2019 18:39:58 +0000 Date: Wed, 4 Sep 2019 11:39:58 -0700 From: Matthew Wilcox To: "Weiny, Ira" Cc: Vlastimil Babka , zhong jiang , "akpm@linux-foundation.org" , "mhocko@kernel.org" , "anshuman.khandual@arm.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "Aneesh Kumar K.V" Subject: Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero Message-ID: <20190904183958.GM29434@bombadil.infradead.org> References: <1567592763-25282-1-git-send-email-zhongjiang@huawei.com> <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> <2807E5FD2F6FDA4886F6618EAC48510E898E9559@CRSMSX101.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2807E5FD2F6FDA4886F6618EAC48510E898E9559@CRSMSX101.amr.corp.intel.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 04, 2019 at 06:25:19PM +0000, Weiny, Ira 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). > > 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? __get_user_pages can return a negative errno.