Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp252488ybg; Thu, 17 Oct 2019 22:26:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTyTYdLV21IvdCq6B8SjLOp7ClVOqIobgs1wG7sPpD6OnqpCnrD2jIQmlrYyaF8hmrKXWY X-Received: by 2002:a05:6402:13d6:: with SMTP id a22mr7731481edx.165.1571376410552; Thu, 17 Oct 2019 22:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571376410; cv=none; d=google.com; s=arc-20160816; b=IYRswujjOy2HHwcU44Qr+K9mX+gb3iBgqvxW0G0qZpJZzDuZ4dGfncN/a2+sIwzv+Z w6xzdtnDFEoUnzLuGCHJsJNjLhH/zKbshF5lRJEP3JBK5JHkpI2asNi+6A22VGITk6Lx SeuTGN/VQnhT3kOeCLky09B/c5wJAV61b400D/Z7DmzaDCnCHERxxzJOXU1io5c/EeSY lVx6fEa7lvyjLuL2t2ARgyW4V0hQSpo8EkDvUaLpc4tJc8JOPa3vUp8NiE2PLDz9tDSO 8u0+AsJaS2tOE2NmSDYENe1y1TIv25WRQUafw5te54SG9n1/zIPB5PcxlA7w64Uu4Lz4 AMbw== 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=NZ1aFp/cczXsydg4eBCqgUJov9uOEtHg7GCWhw2IuFA=; b=VNjc9PfDbvAPINEZRKTMfp4SPzZKWK7yySzQwjmYpv7JtqJ39G9qpt9+T58vJt1EAi Obj2m4P5DVqxpIQZTWoU45ITFclxYxGKGNDneg6EEwLpXbk2Mi38BSup4pcbPwCV0JhX 0HFStEc6Suni7GXXlvdNC7aCgV70avwHL4JgNFlTrtdWyU930HItyab99ecfC9dUBDZO uACjJAIgA0o03LNfGN+TJaE7drTwnTD5BTCD2yUfqScNy2ij4QW88i6zk7z8f7IZaTVn 2fJiKVERjXo35JVONz6+Bpyj59QPWUWGbXWkOK3JuZmk7AhjFWcGgxv6kd6ialttBbaW f3dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZF1baU1o; 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 h12si3042325edq.437.2019.10.17.22.26.27; Thu, 17 Oct 2019 22:26: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; dkim=pass header.i=@kernel.org header.s=default header.b=ZF1baU1o; 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 S2405144AbfJQAt5 (ORCPT + 99 others); Wed, 16 Oct 2019 20:49:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:37304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403893AbfJQAt4 (ORCPT ); Wed, 16 Oct 2019 20:49:56 -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 CC56420872; Thu, 17 Oct 2019 00:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571273396; bh=IYJzNb9unWNMZK55GWXexB0DpsKeOwmGxuFGk3dxhMA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZF1baU1o3y5gSgLWTM6fEbQK9smKG/HjbhMqyqekJ0qvU5Nm6MbJeLUHCSeNh5w3J tg3gDIAsXqpfhuNrM0faCk4eASmCQYMgKcHSZJkC4YFi7z7U1XUCR6tXGkZFgICAao UECGGb/C/2pSDVkEp9eeIi9yxgwjVWUtPiI79YTw= Date: Wed, 16 Oct 2019 17:49:55 -0700 From: Andrew Morton To: zhong jiang Cc: John Hubbard , Vlastimil Babka , , , , , Ira Weiny , "Aneesh Kumar K.V" Subject: Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero Message-Id: <20191016174955.300d5fd4968537151d3ad43f@linux-foundation.org> In-Reply-To: <5DA6DDE0.6000804@huawei.com> References: <1567592763-25282-1-git-send-email-zhongjiang@huawei.com> <5505fa16-117e-8890-0f48-38555a61a036@suse.cz> <20190904114820.42d9c4daf445ded3d0da52ab@linux-foundation.org> <73c49a1b-4f42-c21d-ccd8-2b063cdf1293@nvidia.com> <5DA6DDE0.6000804@huawei.com> 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, 16 Oct 2019 17:07:44 +0800 zhong jiang wrote: > >> --- a/mm/gup.c~a > >> +++ a/mm/gup.c > >> @@ -1450,6 +1450,7 @@ static long check_and_migrate_cma_pages( > >> bool drain_allow = true; > >> bool migrate_allow = true; > >> LIST_HEAD(cma_page_list); > >> + long ret; > >> check_again: > >> for (i = 0; i < nr_pages;) { > >> @@ -1511,17 +1512,18 @@ check_again: > >> * again migrating any new CMA pages which we failed to isolate > >> * earlier. > >> */ > >> - nr_pages = __get_user_pages_locked(tsk, mm, start, nr_pages, > >> + ret = __get_user_pages_locked(tsk, mm, start, nr_pages, > >> pages, vmas, NULL, > >> gup_flags); > >> - if ((nr_pages > 0) && migrate_allow) { > >> + nr_pages = ret; > >> + if (ret > 0 && migrate_allow) { > >> drain_allow = true; > >> goto check_again; > >> } > >> } > >> - return nr_pages; > >> + return ret; > >> } > >> #else > >> static long check_and_migrate_cma_pages(struct task_struct *tsk, > >> > > > > +1 for this approach, please. > > > > > > thanks, > Hi, Andrew > > I didn't see the fix for the issue in the upstream. Your proposal should be > appiled to upstream. Could you appiled the patch or repost by me ? Forgotten about it ;) Please send a patch sometime?