From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE67C433E1 for ; Wed, 19 Aug 2020 03:09:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B32ED2083B for ; Wed, 19 Aug 2020 03:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597806551; bh=GvR89N09DxHYvMVbKVHonsMhERR+e9cz9jf7v/owYvA=; h=Date:From:To:Subject:In-Reply-To:Reply-To:List-ID:From; b=hvoOGDY4f6KI7ZTXra8UyUD8Pn9E0nq/wWKiZMmIGPtKHM2/HgndMlrZFBJW8iRJA tkulqPYLYEuyKq9TX2JNozPAUJDZ1IuOZGKQPHRARPNbqFPe/SmbkXmogpGLXWxUwi puIy1XKnhOD4irps1fcUo8pSQIHwCgpQa7zeeZjg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgHSDJK (ORCPT ); Tue, 18 Aug 2020 23:09:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:40488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726605AbgHSDJG (ORCPT ); Tue, 18 Aug 2020 23:09:06 -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 C8F1B2078B; Wed, 19 Aug 2020 03:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597806544; bh=GvR89N09DxHYvMVbKVHonsMhERR+e9cz9jf7v/owYvA=; h=Date:From:To:Subject:In-Reply-To:From; b=SHI+r1YONavxNOb4wUoZUVZCDwVHEBURsaEYuMJvSrOo7JVHN9indRzcItt9FmWhe 7lCs5o3kwysgqo284BdSdi3CwYxc2O+fgi6UOnCf+48k5q2XGCf633wsnwOPSfusfx Ph81UANXplfVLr+iKdx04MIb2/W+sy/FiDNO2Aj8= Date: Tue, 18 Aug 2020 20:09:03 -0700 From: Andrew Morton To: corbet@lwn.net, dan.j.williams@intel.com, david@fromorbit.com, hch@infradead.org, jack@suse.cz, jgg@ziepe.ca, jglisse@redhat.com, jhubbard@nvidia.com, mhocko@suse.com, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, shuah@kernel.org, song.bao.hua@hisilicon.com, vbabka@suse.cz, viro@zeniv.linux.org.uk, willy@infradead.org Subject: + mm-gup_benchmark-use-pin_user_pages-for-foll_longterm-flag.patch added to -mm tree Message-ID: <20200819030903.ksWiof_uX%akpm@linux-foundation.org> In-Reply-To: <20200814172939.55d6d80b6e21e4241f1ee1f3@linux-foundation.org> User-Agent: s-nail v14.8.16 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: mm-commits-owner@vger.kernel.org Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: mm/gup_benchmark: use pin_user_pages for FOLL_LONGTERM flag has been added to the -mm tree. Its filename is mm-gup_benchmark-use-pin_user_pages-for-foll_longterm-flag.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-gup_benchmark-use-pin_user_= pages-for-foll_longterm-flag.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-gup_benchmark-use-pin_user_= pages-for-foll_longterm-flag.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing= your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ =46rom: Barry Song Subject: mm/gup_benchmark: use pin_user_pages for FOLL_LONGTERM flag According to Documentation/core-api/pin_user_pages.rst, FOLL_PIN is a prerequisite to FOLL_LONGTERM. Another way of saying that is, FOLL_LONGTERM is a specific case, more restrictive case of FOLL_PIN. Almost all kernel modules are using pin_user_pages() with FOLL_LONGTERM, mm/gup_benchmark.c seems to the only exception in which FOLL_PIN is not a prerequisite to FOLL_LONGTERM. Link: http://lkml.kernel.org/r/20200815122056.29508-1-song.bao.hua@hisilico= n.com Signed-off-by: Barry Song Reviewed-by: John Hubbard Cc: Jan Kara Cc: J=C3=A9r=C3=B4me Glisse Cc: "Matthew Wilcox (Oracle)" Cc: Al Viro Cc: Christoph Hellwig Cc: Dan Williams Cc: Dave Chinner Cc: Jason Gunthorpe Cc: Jonathan Corbet Cc: Michal Hocko Cc: Mike Kravetz Cc: Shuah Khan Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- mm/gup_benchmark.c | 23 +++++++++---------- tools/testing/selftests/vm/gup_benchmark.c | 14 +++++------ 2 files changed, 19 insertions(+), 18 deletions(-) --- a/mm/gup_benchmark.c~mm-gup_benchmark-use-pin_user_pages-for-foll_longt= erm-flag +++ a/mm/gup_benchmark.c @@ -6,10 +6,10 @@ #include =20 #define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_benchmark) -#define GUP_LONGTERM_BENCHMARK _IOWR('g', 2, struct gup_benchmark) -#define GUP_BENCHMARK _IOWR('g', 3, struct gup_benchmark) -#define PIN_FAST_BENCHMARK _IOWR('g', 4, struct gup_benchmark) -#define PIN_BENCHMARK _IOWR('g', 5, struct gup_benchmark) +#define GUP_BENCHMARK _IOWR('g', 2, struct gup_benchmark) +#define PIN_FAST_BENCHMARK _IOWR('g', 3, struct gup_benchmark) +#define PIN_BENCHMARK _IOWR('g', 4, struct gup_benchmark) +#define PIN_LONGTERM_BENCHMARK _IOWR('g', 5, struct gup_benchmark) =20 struct gup_benchmark { __u64 get_delta_usec; @@ -28,7 +28,6 @@ static void put_back_pages(unsigned int =20 switch (cmd) { case GUP_FAST_BENCHMARK: - case GUP_LONGTERM_BENCHMARK: case GUP_BENCHMARK: for (i =3D 0; i < nr_pages; i++) put_page(pages[i]); @@ -36,6 +35,7 @@ static void put_back_pages(unsigned int =20 case PIN_FAST_BENCHMARK: case PIN_BENCHMARK: + case PIN_LONGTERM_BENCHMARK: unpin_user_pages(pages, nr_pages); break; } @@ -50,6 +50,7 @@ static void verify_dma_pinned(unsigned i switch (cmd) { case PIN_FAST_BENCHMARK: case PIN_BENCHMARK: + case PIN_LONGTERM_BENCHMARK: for (i =3D 0; i < nr_pages; i++) { page =3D pages[i]; if (WARN(!page_maybe_dma_pinned(page), @@ -101,11 +102,6 @@ static int __gup_benchmark_ioctl(unsigne nr =3D get_user_pages_fast(addr, nr, gup->flags, pages + i); break; - case GUP_LONGTERM_BENCHMARK: - nr =3D get_user_pages(addr, nr, - gup->flags | FOLL_LONGTERM, - pages + i, NULL); - break; case GUP_BENCHMARK: nr =3D get_user_pages(addr, nr, gup->flags, pages + i, NULL); @@ -118,6 +114,11 @@ static int __gup_benchmark_ioctl(unsigne nr =3D pin_user_pages(addr, nr, gup->flags, pages + i, NULL); break; + case PIN_LONGTERM_BENCHMARK: + nr =3D pin_user_pages(addr, nr, + gup->flags | FOLL_LONGTERM, + pages + i, NULL); + break; default: kvfree(pages); ret =3D -EINVAL; @@ -162,10 +163,10 @@ static long gup_benchmark_ioctl(struct f =20 switch (cmd) { case GUP_FAST_BENCHMARK: - case GUP_LONGTERM_BENCHMARK: case GUP_BENCHMARK: case PIN_FAST_BENCHMARK: case PIN_BENCHMARK: + case PIN_LONGTERM_BENCHMARK: break; default: return -EINVAL; --- a/tools/testing/selftests/vm/gup_benchmark.c~mm-gup_benchmark-use-pin_u= ser_pages-for-foll_longterm-flag +++ a/tools/testing/selftests/vm/gup_benchmark.c @@ -15,12 +15,12 @@ #define PAGE_SIZE sysconf(_SC_PAGESIZE) =20 #define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_benchmark) -#define GUP_LONGTERM_BENCHMARK _IOWR('g', 2, struct gup_benchmark) -#define GUP_BENCHMARK _IOWR('g', 3, struct gup_benchmark) +#define GUP_BENCHMARK _IOWR('g', 2, struct gup_benchmark) =20 /* Similar to above, but use FOLL_PIN instead of FOLL_GET. */ -#define PIN_FAST_BENCHMARK _IOWR('g', 4, struct gup_benchmark) -#define PIN_BENCHMARK _IOWR('g', 5, struct gup_benchmark) +#define PIN_FAST_BENCHMARK _IOWR('g', 3, struct gup_benchmark) +#define PIN_BENCHMARK _IOWR('g', 4, struct gup_benchmark) +#define PIN_LONGTERM_BENCHMARK _IOWR('g', 5, struct gup_benchmark) =20 /* Just the flags we need, copied from mm.h: */ #define FOLL_WRITE 0x01 /* check pte is writable */ @@ -52,6 +52,9 @@ int main(int argc, char **argv) case 'b': cmd =3D PIN_BENCHMARK; break; + case 'L': + cmd =3D PIN_LONGTERM_BENCHMARK; + break; case 'm': size =3D atoi(optarg) * MB; break; @@ -67,9 +70,6 @@ int main(int argc, char **argv) case 'T': thp =3D 0; break; - case 'L': - cmd =3D GUP_LONGTERM_BENCHMARK; - break; case 'U': cmd =3D GUP_BENCHMARK; break; _ Patches currently in -mm which might be from song.bao.hua@hisilicon.com are mm-gup_benchmark-use-pin_user_pages-for-foll_longterm-flag.patch