Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2651789ybb; Sun, 22 Mar 2020 04:36:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsX0I5y5IaoflkkzFsG7xFbG5RxnRqbELhWgDGRRdLEfMy/gPVxl2yLLyEfI48YVe/Xz0a6 X-Received: by 2002:aca:d10:: with SMTP id 16mr725200oin.142.1584877006628; Sun, 22 Mar 2020 04:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584877006; cv=none; d=google.com; s=arc-20160816; b=SwZBo54LMS+QRI5PEEfVG1ry7TSu4VFaGpjixTMf7RReoR+J9419ucZ4hSRBjoJ3xN rW+VGwwD86dPJAktKvjpwxW1hjMomxt19Fa84wVO3Kf/16QxU3lXtnlIJs4L0/RUllDc 8gZQHJ4g4CqzYHkdGbsC3szXUSH3vR/CgNDetwFXwyEQ26UBi5RDicKLPB2ylBo7n0T0 lF8/T97QCgsQ7f1JrETYTACTmQbrGdd+Puuae4DW523bKih6XlX5oUl73jAyclCQTWki 7u21rfTTeI8yFylA0drrJyRt2EZI8zyha5k9NHQwgmTP6YgeQk9qUudNK7cmouh2FbLQ JJfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xWoNlFcF04oMTTvMbHBq5MIT/9eTXh290wY6htrAIuI=; b=0EP7oV2rabZ1O7qPtooB4fEtfPtyVjN8MDKWSWNRPRlsTUSZo9lB7DYybAecx/ZGYc jcDhe35XIXEzUBBh2SMx2FmYc2h2p5Y6Zvv0aoExiRCy0LNdZYeF/OUsCBjrNFxSsO6s x6K42VKimLcYxGIpKXUNs7947/7PY4ox7D8I3/cdNHJiEt7VoCjSI3wSQrzF8xH4Z9jT hcI5IDgToPrJ4UDkNw+aIJ70N6Y+QQwhJz5lR53co6pXRJWvdPup71LZkHeyROvyCCAS plZCLp9Wh9zypJFyJlpnWbmeL4uSRrNdXMOBu1wp4WJCRq4xXh6Z/+cP0ofw/qRYvw0Q J4dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B09uNYE3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20si6064237oti.311.2020.03.22.04.36.33; Sun, 22 Mar 2020 04:36:46 -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=@gmail.com header.s=20161025 header.b=B09uNYE3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727011AbgCVLel (ORCPT + 99 others); Sun, 22 Mar 2020 07:34:41 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34128 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbgCVLek (ORCPT ); Sun, 22 Mar 2020 07:34:40 -0400 Received: by mail-pl1-f196.google.com with SMTP id a23so4634682plm.1 for ; Sun, 22 Mar 2020 04:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xWoNlFcF04oMTTvMbHBq5MIT/9eTXh290wY6htrAIuI=; b=B09uNYE3YLv9AUjIpSkhK9RLo1vpui/8HJtBFrQRwJytPlHEfd+gH9dEuhggII+Iew FtfkGoevnyc3b/xFGOIfHowiEK/PkSuEylcdNlvBkgjwwpWKnFiP09E/H43f9M0/HmCE 2E92oKmD/v5FmM+jfbsdvdbDp7d8gTGtpD+oxRHvWBfCS4re2l8TkuDksKLaPz4XelZ8 zbL00C3XSyROMjSTUPc1c3yzfGzxZCbsuldi58WuwreDsJljc44YZrqCpN2fVqSpKHcV 8FXS3M7hHYvdqoWec6ZiVyVCULlpZR36AIp4DFnq3++gCRVtu4ALtVbn+enIGEQlUbV2 XS4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xWoNlFcF04oMTTvMbHBq5MIT/9eTXh290wY6htrAIuI=; b=C8AdzqZnjaaxvo6PcCWRa6XPJlzX06WHey4FT9FW9Qdek4RgNwFG6QTqhhVMCG+HE5 fc46ECrWawOZUm2YSG85yH9qkXzXyKGLg83SmLAgPYFpkemqrRbYvP2xbxF0qe1Snf0G 91Txv0Cmjo8r+QWkcsxzhziDDCuISdYWkH9BkAAx6XFcx83WrWGoWdgUJULASLnhFW2T K9Bfq3D/tQlfchdYMxv2wzVSHlEyqugiEi+hDS74VHG6ZANl8R6gtvOH+PGVlVL7BymJ j4S1H2PUMq3LsBFRvqRatZi6bQQvRh1F98scy/6RyQ+Y7umCqPbuxL02MUpLCK/6KywK yvPg== X-Gm-Message-State: ANhLgQ1TZ2OUgfIPSOSeq372h2/m/FQbqIp+jyqv9LwrOPnnchOpHx7G BC/ZiqdwU5kAIJw4f95bIA== X-Received: by 2002:a17:902:6acc:: with SMTP id i12mr16839795plt.87.1584876880017; Sun, 22 Mar 2020 04:34:40 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id i23sm10474445pfq.157.2020.03.22.04.34.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2020 04:34:39 -0700 (PDT) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Ira Weiny , Andrew Morton , Mike Rapoport , Dan Williams , Matthew Wilcox , "Aneesh Kumar K.V" , Christoph Hellwig , Shuah Khan , Jason Gunthorpe , linux-kernel@vger.kernel.org Subject: [PATCHv8 1/2] mm/gup: rename nr as nr_pinned in get_user_pages_fast() Date: Sun, 22 Mar 2020 19:32:12 +0800 Message-Id: <1584876733-17405-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1584876733-17405-1-git-send-email-kernelfans@gmail.com> References: <1584876733-17405-1-git-send-email-kernelfans@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To better reflect the held state of pages and make code self-explaining, rename nr as nr_pinned. Signed-off-by: Pingfan Liu Reviewed-by: John Hubbard Cc: Ira Weiny Cc: Andrew Morton Cc: Mike Rapoport Cc: Dan Williams Cc: Matthew Wilcox Cc: "Aneesh Kumar K.V" Cc: Christoph Hellwig Cc: Shuah Khan Cc: Jason Gunthorpe To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/gup.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index e8aaa40..02a95b1 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2665,7 +2665,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, { unsigned long len, end; unsigned long flags; - int nr = 0; + int nr_pinned = 0; /* * Internally (within mm/gup.c), gup fast variants must set FOLL_GET, * because gup fast is always a "pin with a +1 page refcount" request. @@ -2699,11 +2699,11 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && gup_fast_permitted(start, end)) { local_irq_save(flags); - gup_pgd_range(start, end, gup_flags, pages, &nr); + gup_pgd_range(start, end, gup_flags, pages, &nr_pinned); local_irq_restore(flags); } - return nr; + return nr_pinned; } EXPORT_SYMBOL_GPL(__get_user_pages_fast); @@ -2735,7 +2735,7 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, struct page **pages) { unsigned long addr, len, end; - int nr = 0, ret = 0; + int nr_pinned = 0, ret = 0; if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM | FOLL_FORCE | FOLL_PIN | FOLL_GET))) @@ -2754,25 +2754,25 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && gup_fast_permitted(start, end)) { local_irq_disable(); - gup_pgd_range(addr, end, gup_flags, pages, &nr); + gup_pgd_range(addr, end, gup_flags, pages, &nr_pinned); local_irq_enable(); - ret = nr; + ret = nr_pinned; } - if (nr < nr_pages) { + if (nr_pinned < nr_pages) { /* Try to get the remaining pages with get_user_pages */ - start += nr << PAGE_SHIFT; - pages += nr; + start += nr_pinned << PAGE_SHIFT; + pages += nr_pinned; - ret = __gup_longterm_unlocked(start, nr_pages - nr, + ret = __gup_longterm_unlocked(start, nr_pages - nr_pinned, gup_flags, pages); /* Have to be a bit careful with return values */ - if (nr > 0) { + if (nr_pinned > 0) { if (ret < 0) - ret = nr; + ret = nr_pinned; else - ret += nr; + ret += nr_pinned; } } -- 2.7.5