Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8630985rwi; Tue, 25 Oct 2022 08:58:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7wR5/4uMlAyAOoPwbWGVNqdnendo8YveBXmwNHH6PTGIiVKKlGPGUdLGjPUIXhuBag9N2L X-Received: by 2002:a05:6402:3551:b0:462:2a17:f147 with SMTP id f17-20020a056402355100b004622a17f147mr2568444edd.281.1666713536936; Tue, 25 Oct 2022 08:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666713536; cv=none; d=google.com; s=arc-20160816; b=ncLkMULJRh+4er1qZnOAlO7PVtVt2ByuO9q1QciscVvqyQQQqBFtKfEwX3p/nu1JZl ezvCf6y344gEJM7vS2AshvAl5WN8v8+NrduIOq4UxGh+RodfoRECfbkZWCfgB1Wc1nLw 4x1wMhLhF0jVLNrCj8pXOeX1mwDuuxzbA/2t3/5y1yXJwVNc3tXrjfMWQHrQ0q0RrLGg m0Scfu0Bq9k4kS12XPpOhP/jzExFubDajc+zG49FySSiM4+UcID20QFOYnBXOL1f4C5x 7FF3rOXFKB4NYL/4aiOAf2O3i7rodUK7QGbYkhRnbIKhpcEMH2t4Fo6KF1Y+eh8Owvvk 8hew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:in-reply-to :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=x0Yzo3aybKV00mvxm0n+9+v1NGi8dTPJwFPa0omZxuE=; b=TIS+JTjy6urD5lSktueIdVT4V2U5f14dOMJYdYkmLJ44CPAOzrkGaNMFaa0fLY/8vq 6AIGNEEr/wUoaoRkZl0E/FSVgqbtKfXQcaOX40ApvO+9G2W+95Js/sN5QQSQ0ezWy4Qb maVISVYMRvNMqaRdlLGuO5lpZ5ShM5UY4yQusWiNygRsGlNDd7hn8a2E0n3QgQOUKl4E U0aQ0jqxkqn7bHTVE+pOxhOZO+dbx/Q0nJiq5rOCwQB2FlCnCII8+emYTeZcCypaAywK Zeh1PZ3iHT+oR2Tjej85xnPY78mukxLBJDAZhg1CZi2fNGv7d/vHvhsR7fCERaLrzgey D5qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=TECqBrsd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170906708900b0078d8614e809si2752414ejk.504.2022.10.25.08.58.31; Tue, 25 Oct 2022 08:58:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=TECqBrsd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbiJYPfe (ORCPT + 99 others); Tue, 25 Oct 2022 11:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233263AbiJYPfc (ORCPT ); Tue, 25 Oct 2022 11:35:32 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 186B8AE860; Tue, 25 Oct 2022 08:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:From:References:Cc:To: MIME-Version:Date:Message-ID:content-disposition; bh=x0Yzo3aybKV00mvxm0n+9+v1NGi8dTPJwFPa0omZxuE=; b=TECqBrsdO3eJvM/HwoglBPPjsi dzMGqk2j2XncTUg3/bTvE9onc3miFg+MAkyNsga8bElyzRLnAvjYeSkIv+weqKScShndHJOo1rNGx /MSeBNPOBQzoaEF+lwDkJV1MvB/MZY+2ONVduaX1mcgFn7/A3C1VwH/FXVkppjmzXuQQpe3Y2xW/O KZenWN8CDqmV5JSRsm/v2dvyE5pkksWI9GfcoYs6ecrr/g1iXHiMwXwtDSS3CaUu8/T+5oC9vKi3w +etNolO1BjumECdDkTpeWXLoKwzZizi4zMD4uP8rOT1DO6H+twuEbalWwlcabsXQ8ZvEWd7UI0SYP CboL3j9w==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1onLxd-00H0QY-Ic; Tue, 25 Oct 2022 09:35:26 -0600 Message-ID: <41e621bb-e836-4a86-e6db-0beed19f5ddc@deltatee.com> Date: Tue, 25 Oct 2022 09:35:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: en-CA To: Chaitanya Kulkarni , "linux-kernel@vger.kernel.org" , "linux-nvme@lists.infradead.org" , "linux-block@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-mm@kvack.org" Cc: Christoph Hellwig , Greg Kroah-Hartman , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni , Ralph Campbell , Stephen Bates References: <20221021174116.7200-1-logang@deltatee.com> <20221021174116.7200-4-logang@deltatee.com> <929ac68b-cf07-8df6-e589-49b0576a50c5@nvidia.com> From: Logan Gunthorpe In-Reply-To: <929ac68b-cf07-8df6-e589-49b0576a50c5@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: chaitanyak@nvidia.com, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, gregkh@linuxfoundation.org, dan.j.williams@intel.com, jgg@ziepe.ca, christian.koenig@amd.com, jhubbard@nvidia.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, dave.b.minturn@intel.com, jason@jlekstrand.net, dave.hansen@linux.intel.com, jianxin.xiong@intel.com, helgaas@kernel.org, ira.weiny@intel.com, robin.murphy@arm.com, martin.oliveira@eideticom.com, ckulkarnilinux@gmail.com, rcampbell@nvidia.com, sbates@raithlin.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: [PATCH v11 3/9] iov_iter: introduce iov_iter_get_pages_[alloc_]flags() X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-10-24 19:14, Chaitanya Kulkarni wrote: > On 10/21/22 10:41, Logan Gunthorpe wrote: >> Add iov_iter_get_pages_flags() and iov_iter_get_pages_alloc_flags() >> which take a flags argument that is passed to get_user_pages_fast(). >> >> This is so that FOLL_PCI_P2PDMA can be passed when appropriate. >> >> Signed-off-by: Logan Gunthorpe >> Reviewed-by: Christoph Hellwig >> --- >> include/linux/uio.h | 6 ++++++ >> lib/iov_iter.c | 32 ++++++++++++++++++++++++-------- >> 2 files changed, 30 insertions(+), 8 deletions(-) >> >> diff --git a/include/linux/uio.h b/include/linux/uio.h >> index 2e3134b14ffd..9ede533ce64c 100644 >> --- a/include/linux/uio.h >> +++ b/include/linux/uio.h >> @@ -247,8 +247,14 @@ void iov_iter_pipe(struct iov_iter *i, unsigned int direction, struct pipe_inode >> void iov_iter_discard(struct iov_iter *i, unsigned int direction, size_t count); >> void iov_iter_xarray(struct iov_iter *i, unsigned int direction, struct xarray *xarray, >> loff_t start, size_t count); >> +ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages, >> + size_t maxsize, unsigned maxpages, size_t *start, >> + unsigned gup_flags); >> ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages, >> size_t maxsize, unsigned maxpages, size_t *start); >> +ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, >> + struct page ***pages, size_t maxsize, size_t *start, >> + unsigned gup_flags); >> ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, struct page ***pages, >> size_t maxsize, size_t *start); >> int iov_iter_npages(const struct iov_iter *i, int maxpages); >> diff --git a/lib/iov_iter.c b/lib/iov_iter.c >> index c3ca28ca68a6..53efad017f3c 100644 >> --- a/lib/iov_iter.c >> +++ b/lib/iov_iter.c >> @@ -1430,7 +1430,8 @@ static struct page *first_bvec_segment(const struct iov_iter *i, >> >> static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, >> struct page ***pages, size_t maxsize, >> - unsigned int maxpages, size_t *start) >> + unsigned int maxpages, size_t *start, >> + unsigned int gup_flags) >> { >> unsigned int n; >> >> @@ -1442,7 +1443,6 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, >> maxsize = MAX_RW_COUNT; >> >> if (likely(user_backed_iter(i))) { >> - unsigned int gup_flags = 0; >> unsigned long addr; >> int res; >> >> @@ -1492,33 +1492,49 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, >> return -EFAULT; >> } >> >> -ssize_t iov_iter_get_pages2(struct iov_iter *i, >> +ssize_t iov_iter_get_pages(struct iov_iter *i, >> struct page **pages, size_t maxsize, unsigned maxpages, >> - size_t *start) >> + size_t *start, unsigned gup_flags) >> { >> if (!maxpages) >> return 0; >> BUG_ON(!pages); >> >> - return __iov_iter_get_pages_alloc(i, &pages, maxsize, maxpages, start); >> + return __iov_iter_get_pages_alloc(i, &pages, maxsize, maxpages, >> + start, gup_flags); >> +} >> +EXPORT_SYMBOL_GPL(iov_iter_get_pages); >> + >> +ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages, >> + size_t maxsize, unsigned maxpages, size_t *start) >> +{ >> + return iov_iter_get_pages(i, pages, maxsize, maxpages, start, 0); >> } >> EXPORT_SYMBOL(iov_iter_get_pages2); >> >> -ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, >> +ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, >> struct page ***pages, size_t maxsize, >> - size_t *start) >> + size_t *start, unsigned gup_flags) >> { >> ssize_t len; >> >> *pages = NULL; >> >> - len = __iov_iter_get_pages_alloc(i, pages, maxsize, ~0U, start); >> + len = __iov_iter_get_pages_alloc(i, pages, maxsize, ~0U, start, >> + gup_flags); >> if (len <= 0) { >> kvfree(*pages); >> *pages = NULL; >> } >> return len; >> } >> +EXPORT_SYMBOL_GPL(iov_iter_get_pages_alloc); >> + >> +ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, >> + struct page ***pages, size_t maxsize, size_t *start) >> +{ >> + return iov_iter_get_pages_alloc(i, pages, maxsize, start, 0); >> +} >> EXPORT_SYMBOL(iov_iter_get_pages_alloc2); > Just one minor question why not make following functions > EXPORT_SYMBOL_GPL() ? > > 1. iov_iter_get_pages2() > 2. iov_iter_get_pages_alloc2() They previously were not GPL, so I didn't think that should be changed in this patch. Thanks for the review! Logan