From patchwork Mon Oct 14 18:46:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 11189323 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 7E88176 for ; Mon, 14 Oct 2019 18:46:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4BD5021925 for ; Mon, 14 Oct 2019 18:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="Y6d1pU4Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BD5021925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 85AF38E0006; Mon, 14 Oct 2019 14:46:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 80BE68E0001; Mon, 14 Oct 2019 14:46:43 -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 748F68E0006; Mon, 14 Oct 2019 14:46:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 57C698E0001 for ; Mon, 14 Oct 2019 14:46:43 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id F1DD8758D for ; Mon, 14 Oct 2019 18:46:42 +0000 (UTC) X-FDA: 76043271444.15.coach79_74c86a17fcc3b X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jhubbard@nvidia.com,:akpm@linux-foundation.org:hch@infradead.org:aneesh.kumar@linux.ibm.com:keith.busch@intel.com:ira.weiny@intel.com:linux-kernel@vger.kernel.org::jhubbard@nvidia.com:kirill.shutemov@linux.intel.com:shuah@kernel.org:linux-kselftest@vger.kernel.org,RULES_HIT:30012:30054:30056:30064,0,RBL:216.228.121.64:@nvidia.com:.lbl8.mailshell.net-62.18.0.100 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: coach79_74c86a17fcc3b X-Filterd-Recvd-Size: 4077 Received: from hqemgate15.nvidia.com (hqemgate15.nvidia.com [216.228.121.64]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Oct 2019 18:46:42 +0000 (UTC) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 14 Oct 2019 11:46:51 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 14 Oct 2019 11:46:41 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 14 Oct 2019 11:46:41 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 14 Oct 2019 18:46:40 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 14 Oct 2019 18:46:40 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 14 Oct 2019 11:46:40 -0700 From: John Hubbard To: Andrew Morton CC: Christoph Hellwig , "Aneesh Kumar K . V" , Keith Busch , Ira Weiny , LKML , , John Hubbard , "Kirill A . Shutemov" , Shuah Khan , Subject: [PATCH v2 1/2] mm/gup_benchmark: add a missing "w" to getopt string Date: Mon, 14 Oct 2019 11:46:38 -0700 Message-ID: <20191014184639.1512873-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191014184639.1512873-1-jhubbard@nvidia.com> References: <20191014184639.1512873-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1571078812; bh=5hKzjpJ7hSymwD+fnlyUM1PRMpQBY6h8z/VrTk1YOhY=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=Y6d1pU4QVkfR8c9VkZXMGDQnnOY+swROfYBkhaijQdhbwnELag/LF0A6xEqzhObzw UbWR+M1aIy+28ryAaHiZSRwh15dYpQGaaZdoZglf/2v9ZcONrupGl7TGm5yq/5LBD0 UaI6vIKzOt1VQ+prtisy8Ocm3kbs6Ky+Q+kypFH9denbWOid1cvGI7cFUaabIbCxsL rc1r798NSguwitOGWG7ysijZazXrhGd+ux9x6WhRXsxSE6NDLpay3GugeG94c2RVym 4Hl8svSHbiMEzC6QRcBbdu9wUtQmd0YtC0vWC7T3UGRP2CpC9cDDdjprfawFEV41aV w6pGf/nyZE05g== 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: Even though gup_benchmark.c has code to handle the -w command-line option, the "w" is not part of the getopt string. It looks as if it has been missing the whole time. On my machine, this leads naturally to the following predictable result: $ sudo ./gup_benchmark -w ./gup_benchmark: invalid option -- 'w' ...which is fixed, with this commit. Acked-by: Kirill A. Shutemov Cc: Keith Busch Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Signed-off-by: John Hubbard --- tools/testing/selftests/vm/gup_benchmark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/selftests/vm/gup_benchmark.c index c0534e298b51..cb3fc09645c4 100644 --- a/tools/testing/selftests/vm/gup_benchmark.c +++ b/tools/testing/selftests/vm/gup_benchmark.c @@ -37,7 +37,7 @@ int main(int argc, char **argv) char *file = "/dev/zero"; char *p; - while ((opt = getopt(argc, argv, "m:r:n:f:tTLUSH")) != -1) { + while ((opt = getopt(argc, argv, "m:r:n:f:tTLUwSH")) != -1) { switch (opt) { case 'm': size = atoi(optarg) * MB; From patchwork Mon Oct 14 18:46:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 11189325 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 8776276 for ; Mon, 14 Oct 2019 18:46:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C876217D9 for ; Mon, 14 Oct 2019 18:46:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="F+Jh8WoV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C876217D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D943A8E0008; Mon, 14 Oct 2019 14:46:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D3B838E0001; Mon, 14 Oct 2019 14:46:43 -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 C53148E0007; Mon, 14 Oct 2019 14:46:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id A22AE8E0001 for ; Mon, 14 Oct 2019 14:46:43 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 471E8831E323 for ; Mon, 14 Oct 2019 18:46:43 +0000 (UTC) X-FDA: 76043271486.02.toad60_74cfa6482ce48 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jhubbard@nvidia.com,:akpm@linux-foundation.org:hch@infradead.org:aneesh.kumar@linux.ibm.com:keith.busch@intel.com:ira.weiny@intel.com:linux-kernel@vger.kernel.org::jhubbard@nvidia.com:lkp@intel.com:kirill@shutemov.name:hch@lst.de,RULES_HIT:30012:30054:30064:30070,0,RBL:216.228.121.65:@nvidia.com:.lbl8.mailshell.net-62.18.0.100 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: toad60_74cfa6482ce48 X-Filterd-Recvd-Size: 6383 Received: from hqemgate16.nvidia.com (hqemgate16.nvidia.com [216.228.121.65]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Oct 2019 18:46:42 +0000 (UTC) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 14 Oct 2019 11:46:43 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 14 Oct 2019 11:46:41 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 14 Oct 2019 11:46:41 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 14 Oct 2019 18:46:40 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 14 Oct 2019 18:46:41 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 14 Oct 2019 11:46:40 -0700 From: John Hubbard To: Andrew Morton CC: Christoph Hellwig , "Aneesh Kumar K . V" , Keith Busch , Ira Weiny , LKML , , John Hubbard , kbuild test robot , "Kirill A . Shutemov" , Christoph Hellwig Subject: [PATCH v2 2/2] mm/gup: fix a misnamed "write" argument, and a related bug Date: Mon, 14 Oct 2019 11:46:39 -0700 Message-ID: <20191014184639.1512873-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191014184639.1512873-1-jhubbard@nvidia.com> References: <20191014184639.1512873-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1571078803; bh=skAqYRFCTEBaQBD0vznLHEXuI8b4CNYHQBQAfVdjZLE=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=F+Jh8WoVbLh4BP2uRlLg/lpa7hRTJwIR4UVAG0JOWt3OhDukegfSL1+0nhZ2Tjr8u kwMC9Z5xV+4IyqEYvGtWMi8NM4+iO6qwyJn6cQRtB8FuHfPTqwMdJPICrB0GSEmnE1 upns7fy41N12jeX5vQAwBPSMsZrectB2D1sRKeXRQ5X1l5B5iyZPccAE4AIqNyv2Yl FiV/fWKyijg/uxtWfY1nRguEx8OQiMbveltK93po9qwuN1Y0TER+2WFy7RBdMdnYpd E7zvscD+UqgY+BOVWfWdOAp9WfIM4tlfzUVnBFVY9yot1Br6vkXY+uzdP5AnbhM1gZ hpU4zjElW6RSQ== 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: In several routines, the "flags" argument is incorrectly named "write". Change it to "flags". Also, in one place, the misnaming led to an actual bug: "flags & FOLL_WRITE" is required, rather than just "flags". (That problem was flagged by krobot, in v1 of this patch.) Also, change the flags argument from int, to unsigned int. You can see that this was a simple oversight, because the calling code passes "flags" to the fifth argument: gup_pgd_range(): ... if (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr, PGDIR_SHIFT, next, flags, pages, nr)) ...which, until this patch, the callees referred to as "write". Also, change two lines to avoid checkpatch line length complaints, and another line to fix another oversight that checkpatch called out: missing "int" on pdshift. Fixes: b798bec4741b ("mm/gup: change write parameter to flags in fast walk") Reported-by: kbuild test robot Suggested-by: Kirill A. Shutemov Suggested-by: Ira Weiny Cc: Christoph Hellwig Cc: Aneesh Kumar K.V Signed-off-by: John Hubbard Reviewed-by: Ira Weiny --- mm/gup.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 23a9f9c9d377..8f236a335ae9 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1973,7 +1973,8 @@ static unsigned long hugepte_addr_end(unsigned long addr, unsigned long end, } static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, - unsigned long end, int write, struct page **pages, int *nr) + unsigned long end, unsigned int flags, + struct page **pages, int *nr) { unsigned long pte_end; struct page *head, *page; @@ -1986,7 +1987,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, pte = READ_ONCE(*ptep); - if (!pte_access_permitted(pte, write)) + if (!pte_access_permitted(pte, flags & FOLL_WRITE)) return 0; /* hugepages are never "special" */ @@ -2023,7 +2024,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, } static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, - unsigned int pdshift, unsigned long end, int write, + unsigned int pdshift, unsigned long end, unsigned int flags, struct page **pages, int *nr) { pte_t *ptep; @@ -2033,7 +2034,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, ptep = hugepte_offset(hugepd, addr, pdshift); do { next = hugepte_addr_end(addr, end, sz); - if (!gup_hugepte(ptep, sz, addr, end, write, pages, nr)) + if (!gup_hugepte(ptep, sz, addr, end, flags, pages, nr)) return 0; } while (ptep++, addr = next, addr != end); @@ -2041,7 +2042,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, } #else static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr, - unsigned pdshift, unsigned long end, int write, + unsigned int pdshift, unsigned long end, unsigned int flags, struct page **pages, int *nr) { return 0; @@ -2049,7 +2050,8 @@ static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr, #endif /* CONFIG_ARCH_HAS_HUGEPD */ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, - unsigned long end, unsigned int flags, struct page **pages, int *nr) + unsigned long end, unsigned int flags, + struct page **pages, int *nr) { struct page *head, *page; int refs;