Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp310774ybe; Wed, 4 Sep 2019 20:46:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8gl3a0z2dh7Gmf6lQOtuOiv8U5EjbVfEdhrglKuXGzNuBhxrKI4zwWHdIzjwH1HgWid06 X-Received: by 2002:a63:d615:: with SMTP id q21mr1202283pgg.296.1567655198073; Wed, 04 Sep 2019 20:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567655198; cv=none; d=google.com; s=arc-20160816; b=cRm8Ns4yCgUHZaU/F9Otjhzr79n9erUUNg0TncTH9ptUtc+5aD+yekqSBeqBaKdlT5 0znePSbFNI+zZU7JkvDZ4nfQXuQ1MpJYwVyudBWE1oPxRhec38/S9fpR/L0w9yaDBEvc xbchvG2VQh3BaIr67lwLRs3eDb4vQ5N2kPbyyl7uucF/gE9AGWIhQuFB6Z0PVsQa7Gwz qEE8eQh+dafuBO1A0I8Eu+Xgb3OYJLlvOLtpJZ4Ui1g4bWgcMxIWcBeiNupL7xGwGLDj epDPVsuPBA87CVfI68SYJKrwM498M2DotX3K636Pg+fqYLkVcVEdSQquD+2poIjkvQnS DXLg== 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=WEjrnZDEQ7TEULc6lJk+4RAyKQtPI4nwd9rxNIbJ2jo=; b=vqDI4Pmw4BdM8oE5400qRFkM9iNzzbNoPQ1xTsTCYfBp2aanSofn42AsmGtV3By+fl 8edXZSj9gNdOk7VR9W8AzoOHv90AU+tTXBN0sDKf9cSl72bs0+n0fj9Oi3OhSiTy14gN cpdLTcsscEW9lwdwzkJLOKJCfstA2+xlcOqh6ryjNHN0fiDHB8zYVPTkd4tYvpjvUKPM U4oOmfTIk5P9jFLGonQ43BjoRmU7rwMqqbr1zUppp/sjdi9N1FwDsRBuno86yCppz+R9 N6js0SwTQXZ94zTDhlZL7OZiHF7vMtCeJrTIhTphaNz5QAbRei4Sha9Tj7R6gRI/2vPQ XpjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=cHAm9zd5; 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 z2si582090pgv.417.2019.09.04.20.46.21; Wed, 04 Sep 2019 20:46:38 -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=cHAm9zd5; 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 S1731043AbfIEDM7 (ORCPT + 99 others); Wed, 4 Sep 2019 23:12:59 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39738 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730799AbfIEDM7 (ORCPT ); Wed, 4 Sep 2019 23:12:59 -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=WEjrnZDEQ7TEULc6lJk+4RAyKQtPI4nwd9rxNIbJ2jo=; b=cHAm9zd5r9eSCAYO8QFECjnW4 0Dk5zbKC31VWKl/JUYWtv00YeI7QfLQiGXbxIlOorWOUanHJ2hMa99ADeWrROCZg9JNGf4ksACh6z zRF696B1RJbXdL8oQ4SrmxJLHvYh7hr5eMXUrNrBCErM17z5ixySKuhuBYvLvKP4OesVV8HxaURg/ 39Asm8TljlGNtzOvKofXbjApxD89NCGNtbNSOXb/H0XiE1KXes2DaxJu7DqLVaUYIIJGFNGXomtE4 7iVN3beLW0y90LSzkhJPK9u4wuiEZ4d5jo6DycTHi6fvygzFTpvnXz+k0OwKvkt6Zozn17mu/LxUM F18Z+LMjA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1i5iCa-0004wA-Mu; Thu, 05 Sep 2019 03:12:52 +0000 Date: Wed, 4 Sep 2019 20:12:52 -0700 From: Matthew Wilcox To: zhong jiang Cc: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: Unsigned 'nr_pages' always larger than zero Message-ID: <20190905031252.GN29434@bombadil.infradead.org> References: <1567649871-60594-1-git-send-email-zhongjiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567649871-60594-1-git-send-email-zhongjiang@huawei.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 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.