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=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 4E314C33CAC for ; Mon, 3 Feb 2020 13:58:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F1D852082E for ; Mon, 3 Feb 2020 13:58:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="qKCSEPA3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1D852082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 80A336B065E; Mon, 3 Feb 2020 08:58:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BA7A6B065F; Mon, 3 Feb 2020 08:58:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D0B76B0660; Mon, 3 Feb 2020 08:58:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 570CB6B065E for ; Mon, 3 Feb 2020 08:58:36 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1ED5B180AD802 for ; Mon, 3 Feb 2020 13:58:36 +0000 (UTC) X-FDA: 76448971032.18.error66_2de6cf2b03810 X-HE-Tag: error66_2de6cf2b03810 X-Filterd-Recvd-Size: 7086 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 13:58:35 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id v201so9740856lfa.11 for ; Mon, 03 Feb 2020 05:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Q7EhG/mHxujJqjIax+tX/L6XnMUCZchWEgmsqcRY8O4=; b=qKCSEPA3x8kojnT0VGPWx1REhr2EhqE6i1LsFUAGRHw89eQpMMqBQ9S9OSvrvMREnc Kqf2KRHdvRc9eNFj0Fbr8amLlQZMLRlz6zKBMg1WL7/HIA+tXPcqjLVjTQ2R7KakPHd8 jwLdRMJfSReB3MhMaxEKhmAyNYGue1eXm2uMQreQl/L3J3E4gO+Q1+0WudsQbAd9bkPn tpo6FUUIsaQOfmxjgM5AMcQ+fxVRdOxwlQKq6LqAAqxfW9Lb9cGiXiPNFT0E2TvHmN+Z vo1cDgpRnH/G5otSfVV8D6MokorSsYfD5tcRiWSrkfw8urfjsB3lWjxMQIv0hsoauceU fDLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Q7EhG/mHxujJqjIax+tX/L6XnMUCZchWEgmsqcRY8O4=; b=LB5Y8sxmjB6F7SksNVmbAiKkZYLCrhXKBLxiXemmPXwHtfxex0mgPpj5TeFBRb+Za8 XuMtsS0WORFhpTR/5afw6IPczYU+zI1B0pGe6xF3PB3zycwIsPqNIFCr+YmWCLCJ+wHS +0lkQhR7nlS30DLTIFDkXndLxTQ6ufNAvG2IgwSjuJRGy0S5ZWfclY2eMLwDi63M1Kwj WPYpr/ihBFXrhP3wgPmwfOogKLNgJwLeQHYy8QiP/7TrZ1nunqoiDzYiUcqjJAuwa3ZC haJP4C8n3aJDDzbE2uyBPzwj572W0JUTaDeKIB18OwCZ3SUSWY4JIFf07vbnBAoL9kbi IAyw== X-Gm-Message-State: APjAAAWIzBZhXvjMMHQzqDh2NGWGJU0EcuvfBjXNYV7NYZRu7y7muA6c crS1B76gR/tW9lsLJLF2eBa3pA== X-Google-Smtp-Source: APXvYqwy/AMeACpJx+sRC2T4Q93xcTj2QVF/axvUST/Peo/4AOgO4Rx5SZuMTvzfMfCoqFdSX1vYAA== X-Received: by 2002:ac2:4246:: with SMTP id m6mr12228504lfl.165.1580738313898; Mon, 03 Feb 2020 05:58:33 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id n2sm9868111ljj.1.2020.02.03.05.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 05:58:33 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id C5259100DC8; Mon, 3 Feb 2020 16:58:45 +0300 (+03) Date: Mon, 3 Feb 2020 16:58:45 +0300 From: "Kirill A. Shutemov" To: John Hubbard Cc: Andrew Morton , Al Viro , Christoph Hellwig , Dan Williams , Dave Chinner , Ira Weiny , Jan Kara , Jason Gunthorpe , Jonathan Corbet , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Michal Hocko , Mike Kravetz , Shuah Khan , Vlastimil Babka , Matthew Wilcox , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, LKML Subject: Re: [PATCH v3 11/12] mm/gup_benchmark: support pin_user_pages() and related calls Message-ID: <20200203135845.ymfbghs7rf67awex@box> References: <20200201034029.4063170-1-jhubbard@nvidia.com> <20200201034029.4063170-12-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200201034029.4063170-12-jhubbard@nvidia.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: On Fri, Jan 31, 2020 at 07:40:28PM -0800, John Hubbard wrote: > Up until now, gup_benchmark supported testing of the > following kernel functions: > > * get_user_pages(): via the '-U' command line option > * get_user_pages_longterm(): via the '-L' command line option > * get_user_pages_fast(): as the default (no options required) > > Add test coverage for the new corresponding pin_*() functions: > > * pin_user_pages_fast(): via the '-a' command line option > * pin_user_pages(): via the '-b' command line option > > Also, add an option for clarity: '-u' for what is now (still) the > default choice: get_user_pages_fast(). > > Also, for the commands that set FOLL_PIN, verify that the pages > really are dma-pinned, via the new is_dma_pinned() routine. > Those commands are: > > PIN_FAST_BENCHMARK : calls pin_user_pages_fast() > PIN_BENCHMARK : calls pin_user_pages() > > In between the calls to pin_*() and unpin_user_pages(), > check each page: if page_maybe_dma_pinned() returns false, then > WARN and return. > > Do this outside of the benchmark timestamps, so that it doesn't > affect reported times. > > Reviewed-by: Ira Weiny > Signed-off-by: John Hubbard > --- > mm/gup_benchmark.c | 71 ++++++++++++++++++++-- > tools/testing/selftests/vm/gup_benchmark.c | 15 ++++- > 2 files changed, 80 insertions(+), 6 deletions(-) > > diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c > index 8dba38e79a9f..447628d0131f 100644 > --- a/mm/gup_benchmark.c > +++ b/mm/gup_benchmark.c > @@ -8,6 +8,8 @@ > #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) > > struct gup_benchmark { > __u64 get_delta_usec; > @@ -19,6 +21,48 @@ struct gup_benchmark { > __u64 expansion[10]; /* For future use */ > }; > > +static void put_back_pages(unsigned int cmd, struct page **pages, > + unsigned long nr_pages) > +{ > + int i; > + > + switch (cmd) { > + case GUP_FAST_BENCHMARK: > + case GUP_LONGTERM_BENCHMARK: > + case GUP_BENCHMARK: > + for (i = 0; i < nr_pages; i++) 'i' is 'int' and 'nr_pages' is 'unsigned long'. There's space for trouble :P > + put_page(pages[i]); > + break; > + > + case PIN_FAST_BENCHMARK: > + case PIN_BENCHMARK: > + unpin_user_pages(pages, nr_pages); > + break; > + } > +} > + > +static void verify_dma_pinned(unsigned int cmd, struct page **pages, > + unsigned long nr_pages) > +{ > + int i; > + struct page *page; > + > + switch (cmd) { > + case PIN_FAST_BENCHMARK: > + case PIN_BENCHMARK: > + for (i = 0; i < nr_pages; i++) { Ditto. > + page = pages[i]; > + if (WARN(!page_maybe_dma_pinned(page), > + "pages[%d] is NOT dma-pinned\n", i)) { > + > + dump_page(page, "gup_benchmark failure"); > + break; > + } > + } > + break; > + } > +} > + > static int __gup_benchmark_ioctl(unsigned int cmd, > struct gup_benchmark *gup) > { -- Kirill A. Shutemov