Message ID | 20221021174116.7200-7-logang@deltatee.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp825928wrr; Fri, 21 Oct 2022 10:45:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WhK9q7gBx5yXDnXQrRFxvHMGa+7jQZ6lTRpA1veIH/WjGdHKQBW6jibyE3OtDjW/RF1+1 X-Received: by 2002:a17:90b:1c87:b0:20a:e485:4e21 with SMTP id oo7-20020a17090b1c8700b0020ae4854e21mr23455654pjb.194.1666374344687; Fri, 21 Oct 2022 10:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666374344; cv=none; d=google.com; s=arc-20160816; b=QvrEO55C5RS0shHLuz+4BPVBz2NKiBIv9mm2nqtL2+JwUfFoSLXmlfwaNFMgJQe4Eq v53wlyLMlrTozbuRXHdZgQG1+64pZnMlJ/GyQXxYzunb3ARZ1IlGM+9TqhfXByOZKe/r 4NzSgCA3LmPXxBKayGcfcdiR5kXbie3D4Jf/h5///ZYukraaYoTmKXO9eEMRrNdnQFq2 4xogtiYwLhK9GfsnKd51gzSFilUNrRY8ucSg71JaTQd+0wEHBecTyLvMCQki2g3ECmwo e1VUn7z4k6jr8kKr7JkrqfQC8a+pNz/UpXMTOTfDF/Rcail37IMiGLcwEtlw9BBv9Wiu an2g== 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:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=meh9MET/cLorzCFSIwyZ+v6c79pnFv9f4AD/6AjXlyA=; b=XiGuJuAbFq3gwoaxWqo35rtml5Kg2+9DvFLzasrfTaJak5wR1OhbCAoWmelpyGOOh1 ogQ5rKAOPZxaOPSrohTRplEB7vjGGhCQGNfBsjgbDmLvYchHcxvChIt+Fsu4HOHUY8Tz dPQGtdgyc11spnXeu9CV8AcWYsH/3DWVSB5eTir/u4sGTmZJoB9bEpg41WFuSNUWLXHb eDIF1H6CtpvqhJrpyIaLOdROcJhoGeNGzw9R7/ALEO/R+mPHm/JpxREkX5O3W6vUZdco qYEbWREDco0BY/XN7rzvmSFRgwmIobDyZTEyJYg/hn8gjLaKhngY7fGrvtlLnrhkpOne uGzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Dnxvz9bu; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l16-20020a170903245000b0017340861a6bsi28813064pls.611.2022.10.21.10.45.32; Fri, 21 Oct 2022 10:45:44 -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=Dnxvz9bu; 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 S230334AbiJURl7 (ORCPT <rfc822;mntrajkot1@gmail.com> + 99 others); Fri, 21 Oct 2022 13:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiJURla (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Oct 2022 13:41:30 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FD424AE36; Fri, 21 Oct 2022 10:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=meh9MET/cLorzCFSIwyZ+v6c79pnFv9f4AD/6AjXlyA=; b=Dnxvz9bu1650+6uPD6XmeHI8eu FNbTzbtOAcPLiaUgO8REsgHo8opYH6vss+qGqThk6nRcTRIELX8h8YRVbg6Ca5T2yOEfwOlWq30tw oQeQyefasTRB1O5m9JCPDxe5NoxoS7huiM1FYEB7omz+P3NEF5VgI1na+UVWb+Ziru45774Hvg/CL dAc5a953b5uESq8n8B9SwRQr3ls/SNQDGedrN6mu0fSx/4NRAU71kWNzt/7LZ3DRJi9lBH6Q2fMKG X1NmaE8uLSpHCWFCWUWvYHCR3zJDh8DN8psovNNZh4wOx/tlDlzp99Ot8tMbZyB38AYefT7BQEXij jWwmIZcQ==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <gunthorp@deltatee.com>) id 1olw1L-00DoHx-6Z; Fri, 21 Oct 2022 11:41:23 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from <gunthorp@deltatee.com>) id 1olw1G-0001tL-5n; Fri, 21 Oct 2022 11:41:18 -0600 From: Logan Gunthorpe <logang@deltatee.com> To: 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 <hch@lst.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Dan Williams <dan.j.williams@intel.com>, Jason Gunthorpe <jgg@ziepe.ca>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, John Hubbard <jhubbard@nvidia.com>, Don Dutile <ddutile@redhat.com>, Matthew Wilcox <willy@infradead.org>, Daniel Vetter <daniel.vetter@ffwll.ch>, Minturn Dave B <dave.b.minturn@intel.com>, Jason Ekstrand <jason@jlekstrand.net>, Dave Hansen <dave.hansen@linux.intel.com>, Xiong Jianxin <jianxin.xiong@intel.com>, Bjorn Helgaas <helgaas@kernel.org>, Ira Weiny <ira.weiny@intel.com>, Robin Murphy <robin.murphy@arm.com>, Martin Oliveira <martin.oliveira@eideticom.com>, Chaitanya Kulkarni <ckulkarnilinux@gmail.com>, Ralph Campbell <rcampbell@nvidia.com>, Stephen Bates <sbates@raithlin.com>, Logan Gunthorpe <logang@deltatee.com> Date: Fri, 21 Oct 2022 11:41:13 -0600 Message-Id: <20221021174116.7200-7-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221021174116.7200-1-logang@deltatee.com> References: <20221021174116.7200-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, gregkh@linuxfoundation.org, jgg@ziepe.ca, christian.koenig@amd.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, jason@jlekstrand.net, dave.hansen@linux.intel.com, helgaas@kernel.org, dan.j.williams@intel.com, dave.b.minturn@intel.com, jianxin.xiong@intel.com, ira.weiny@intel.com, robin.murphy@arm.com, martin.oliveira@eideticom.com, ckulkarnilinux@gmail.com, jhubbard@nvidia.com, rcampbell@nvidia.com, sbates@raithlin.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@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,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v11 6/9] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages() 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747320144730398230?= X-GMAIL-MSGID: =?utf-8?q?1747320144730398230?= |
Series |
Userspace P2PDMA with O_DIRECT NVMe devices
|
|
Commit Message
Logan Gunthorpe
Oct. 21, 2022, 5:41 p.m. UTC
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the O_DIRECT path in iomap based filesystems and direct to block devices. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: John Hubbard <jhubbard@nvidia.com> --- block/bio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Comments
/* > * Each segment in the iov is required to be a block size multiple. > * However, we may not be able to get the entire segment if it spans > @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) > * result to ensure the bio's total size is correct. The remainder of > * the iov data will be picked up in the next bio iteration. > */ > - size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size, > - nr_pages, &offset); > + size = iov_iter_get_pages(iter, pages, > + UINT_MAX - bio->bi_iter.bi_size, > + nr_pages, &offset, gup_flags); nit, 3rd param in above call fits on the first line ? plz check :- iov_iter_get_pages(iter, pages, UINT_MAX - bio->bi_iter.bi_size, nr_pages, &offset, gup_flags); Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
* Each segment in the iov is required to be a block size multiple. > * However, we may not be able to get the entire segment if it spans > @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) > * result to ensure the bio's total size is correct. The remainder of > * the iov data will be picked up in the next bio iteration. > */ > - size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size, > - nr_pages, &offset); > + size = iov_iter_get_pages(iter, pages, > + UINT_MAX - bio->bi_iter.bi_size, > + nr_pages, &offset, gup_flags); nit:- 3rd parameter in the above call fits on the 1st line? plz check Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
On 2022-10-24 19:23, Chaitanya Kulkarni wrote: > /* >> * Each segment in the iov is required to be a block size multiple. >> * However, we may not be able to get the entire segment if it spans >> @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) >> * result to ensure the bio's total size is correct. The remainder of >> * the iov data will be picked up in the next bio iteration. >> */ >> - size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size, >> - nr_pages, &offset); >> + size = iov_iter_get_pages(iter, pages, >> + UINT_MAX - bio->bi_iter.bi_size, >> + nr_pages, &offset, gup_flags); > > nit, 3rd param in above call fits on the first line ? plz check :- > > iov_iter_get_pages(iter, pages, UINT_MAX - bio->bi_iter.bi_size, > nr_pages, &offset, gup_flags); Oh, yup, this just fits. I'll queue up the fix for if I send v12. Logan
diff --git a/block/bio.c b/block/bio.c index 439469370b7c..a7abf9b1b66a 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1197,6 +1197,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; struct page **pages = (struct page **)bv; + unsigned int gup_flags = 0; ssize_t size, left; unsigned len, i = 0; size_t offset, trim; @@ -1210,6 +1211,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2); pages += entries_left * (PAGE_PTRS_PER_BVEC - 1); + if (bio->bi_bdev && blk_queue_pci_p2pdma(bio->bi_bdev->bd_disk->queue)) + gup_flags |= FOLL_PCI_P2PDMA; + /* * Each segment in the iov is required to be a block size multiple. * However, we may not be able to get the entire segment if it spans @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) * result to ensure the bio's total size is correct. The remainder of * the iov data will be picked up in the next bio iteration. */ - size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size, - nr_pages, &offset); + size = iov_iter_get_pages(iter, pages, + UINT_MAX - bio->bi_iter.bi_size, + nr_pages, &offset, gup_flags); if (unlikely(size <= 0)) return size ? size : -EFAULT;