From patchwork Sun Mar 22 11:32:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11451639 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1903E1668 for ; Sun, 22 Mar 2020 11:34:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D9935206C3 for ; Sun, 22 Mar 2020 11:34:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B09uNYE3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9935206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0D0AC6B0006; Sun, 22 Mar 2020 07:34:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 081826B0007; Sun, 22 Mar 2020 07:34:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED88B6B0008; Sun, 22 Mar 2020 07:34:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id D5D546B0006 for ; Sun, 22 Mar 2020 07:34:41 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9F507181AEF09 for ; Sun, 22 Mar 2020 11:34:41 +0000 (UTC) X-FDA: 76622790762.20.park84_8040f73885d11 X-Spam-Summary: 2,0,0,023d887529c044fa,d41d8cd98f00b204,kernelfans@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1431:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3871:4117:4321:4605:5007:6119:6261:6653:6742:7514:7901:7903:9413:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12895:13846:14096:14181:14394:14687:14721:21080:21444:21451:21627:21666:21990:30012:30045:30054:30064,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: park84_8040f73885d11 X-Filterd-Recvd-Size: 6088 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sun, 22 Mar 2020 11:34:41 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id g9so608235pjp.0 for ; Sun, 22 Mar 2020 04:34:41 -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=QuuZlnXBB6ZyMlqZxkWOvGEzFlQmkjLbogPBDgNrEFZQX+CQsU/m7OL7ZslK4MD12U oVesvjZCQyaz4qPfH/VRj/iLKcVC8Y4YxiYefN+5yUZpuaLeHffYOZuwByCaBzcFb2Z8 e+G7/EEy2F4vbE9M+3FX6PEc1Hm/tZnqUr91y3QInnXdbA+Db7KiEexx9YO4aSj1colf HCzY9X3MIV9p/IjvO5Mt34zUfLIDqrRuBpX56F/4YLNtZ7xYZdVg9Yn0/R4/0fmskHPk mgw9iuLYNk0i4uUOM6EcE7F09utxPcAy6yl3nDD+xl47uakIC8mmkOV/SxzKLWUghsuZ f9Wg== X-Gm-Message-State: ANhLgQ1lKEaHYLIY8F+hnZMtaWf3G2BJYGZniyxyG4lrvC4WlFObG8Iv Xnvx4HwXv9aQn+0ptpaZMtJSUeA= X-Google-Smtp-Source: ADFU+vuBbHVBMZ9Vibcd72WJpS7tH/vUS4fAO297iYtCc/GotCgFfnIIeUnW/cf7GDw8qlaRmAyAbg== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(-) -- 2.7.5 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; } }