Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1069335ybe; Wed, 4 Sep 2019 12:04:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwA7G9oL+9kZXc/eP07amMahX1yh5wB4v4LAVgJOErWh035RA3E9sbZB8QJIMxzVOzjUcwG X-Received: by 2002:aa7:8259:: with SMTP id e25mr8252140pfn.166.1567623877124; Wed, 04 Sep 2019 12:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567623877; cv=none; d=google.com; s=arc-20160816; b=Au9NhkmqquRCb9Xad3PG3Gr5p1XAX4JDXp1A96ViEEncIL8exws7WXSqsIOwT3riRu nI+bYjKKUGL0PQxOFmPYoXlGkHNoFYDDQ/b5JU/O0ZMYlk427QpP4/cQFIHsBR6tRq6d pC3VEAaU9ZrulZyg/zqz6W3EfH897+yysKpj14kNki1lrYitohdhnS50/uC+hsn34aMV ML1FtxulAJ6282jU4+f2/uMo+747ZozdW85wx+0sGu69zzubRzNSJy4Is2wxWqWKJK2S loxMCSr2U77kUWmgticnCjqrD77rJz19jXpx3x93FzF5ykmg/DAGOw+OUJBAkv9b10KT tz8A== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=//J52yD2Qo40mqtPseUi+K+JrgmiY6ByKZoKlVX8uqY=; b=sRGFPLS/Y47uhrKt8W73iasu2rghRFxiTwpny+oJ9tzvLq2hs139NrBSlUYRAZ7x2V rhO+UYxj/52LMC7JwJ5q/zVrTy8lDLCNdadHoae1Lt9h4qiCIx/gshU2Q3Ci5IbNj6EO q5uwjNpw8I2zwz1Kut3rCkXWmFHo+ASG/mXm5wjo8c88EQ/G+MdLAk3BTptvHDavrLvt 2KWiN9WAEvAnbLcNbOEI/8fqV69JA2eL9m29PP04p/cEcm9iPdbU7jNvDPlMrxEroKQe p0oZNvm/e8NP3e3nwBigF12z3U0w6R1m17x0ze8Mij/J7+qnYzoL43Pu5OqRzBqut+bT qR9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pDxHaccz; 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 y8si17151479pgv.541.2019.09.04.12.04.18; Wed, 04 Sep 2019 12:04:37 -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=pass header.i=@kernel.org header.s=default header.b=pDxHaccz; 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 S2387883AbfIDTCB (ORCPT + 99 others); Wed, 4 Sep 2019 15:02:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:50772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730410AbfIDTCB (ORCPT ); Wed, 4 Sep 2019 15:02:01 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE7CD2087E; Wed, 4 Sep 2019 19:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567623720; bh=A0p265L38NV6UyAt6+h0NKJkV9Yhds5FJHvN1ygxV4c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pDxHacczS7aRbBpwyiXA4vrhf5y08lCIaa7YP/dIu1wq26LCRg6bclT5fKTTVLyGH 1U3klZixQDuOyfP5k6u7kLvIMKM4+3SRc7wXpKnAnVKk8yB7IRbiJtdR3maDYRkAfA mu7Oteopa+BITB2kX1vIAZjqSCc0R63PbOkQ7VYE= Date: Wed, 4 Sep 2019 12:01:59 -0700 From: Andrew Morton To: Vlastimil Babka Cc: zhong jiang , mhocko@kernel.org, anshuman.khandual@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny , "Aneesh Kumar K.V" Subject: Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero Message-Id: <20190904120159.d4026b573f419838d77e991d@linux-foundation.org> In-Reply-To: <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> References: <1567592763-25282-1-git-send-email-zhongjiang@huawei.com> <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Sep 2019 13:24:58 +0200 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). > > > 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. > Really? If nr_pages gets a value of -EFAULT from the __get_user_pages_locked() call, check_and_migrate_cma_pages() will go berzerk? And does __get_user_pages_locked() correctly handle a -ve errno returned by __get_user_pages()? It's hard to see how...