From: john.hubbard@gmail.com
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Alexander Viro" <viro@zeniv.linux.org.uk>,
"Björn Töpel" <bjorn.topel@intel.com>,
"Boaz Harrosh" <boaz@plexistor.com>,
"Christoph Hellwig" <hch@lst.de>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Dan Williams" <dan.j.williams@intel.com>,
"Dave Chinner" <david@fromorbit.com>,
"David Airlie" <airlied@linux.ie>,
"David S . Miller" <davem@davemloft.net>,
"Ilya Dryomov" <idryomov@gmail.com>, "Jan Kara" <jack@suse.cz>,
"Jason Gunthorpe" <jgg@ziepe.ca>, "Jens Axboe" <axboe@kernel.dk>,
"Jérôme Glisse" <jglisse@redhat.com>,
"Johannes Thumshirn" <jthumshirn@suse.de>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Ming Lei" <ming.lei@redhat.com>, "Sage Weil" <sage@redhat.com>,
"Santosh Shilimkar" <santosh.shilimkar@oracle.com>,
"Yan Zheng" <zyan@redhat.com>,
netdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-mm@kvack.org, linux-rdma@vger.kernel.org,
bpf@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH 3/3] gup: new put_user_page_dirty*() helpers
Date: Sun, 21 Jul 2019 21:30:12 -0700 [thread overview]
Message-ID: <20190722043012.22945-4-jhubbard@nvidia.com> (raw)
In-Reply-To: <20190722043012.22945-1-jhubbard@nvidia.com>
From: John Hubbard <jhubbard@nvidia.com>
While converting call sites to use put_user_page*() [1], quite a few
places ended up needing a single-page routine to put and dirty a
page.
Provide put_user_page_dirty() and put_user_page_dirty_lock(),
and use them in a few places: net/xdp, drm/via/, drivers/infiniband.
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/gpu/drm/via/via_dmablit.c | 2 +-
drivers/infiniband/core/umem.c | 2 +-
drivers/infiniband/hw/usnic/usnic_uiom.c | 2 +-
include/linux/mm.h | 10 ++++++++++
net/xdp/xdp_umem.c | 2 +-
5 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index 219827ae114f..d30b2d75599f 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -189,7 +189,7 @@ via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
for (i = 0; i < vsg->num_pages; ++i) {
if (NULL != (page = vsg->pages[i])) {
if (!PageReserved(page) && (DMA_FROM_DEVICE == vsg->direction))
- put_user_pages_dirty(&page, 1);
+ put_user_page_dirty(page);
else
put_user_page(page);
}
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 08da840ed7ee..a7337cc3ca20 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -55,7 +55,7 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
for_each_sg_page(umem->sg_head.sgl, &sg_iter, umem->sg_nents, 0) {
page = sg_page_iter_page(&sg_iter);
if (umem->writable && dirty)
- put_user_pages_dirty_lock(&page, 1);
+ put_user_page_dirty_lock(page);
else
put_user_page(page);
}
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index 0b0237d41613..d2ded624fb2a 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -76,7 +76,7 @@ static void usnic_uiom_put_pages(struct list_head *chunk_list, int dirty)
page = sg_page(sg);
pa = sg_phys(sg);
if (dirty)
- put_user_pages_dirty_lock(&page, 1);
+ put_user_page_dirty_lock(page);
else
put_user_page(page);
usnic_dbg("pa: %pa\n", &pa);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0334ca97c584..c0584c6d9d78 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1061,6 +1061,16 @@ void put_user_pages_dirty(struct page **pages, unsigned long npages);
void put_user_pages_dirty_lock(struct page **pages, unsigned long npages);
void put_user_pages(struct page **pages, unsigned long npages);
+static inline void put_user_page_dirty(struct page *page)
+{
+ put_user_pages_dirty(&page, 1);
+}
+
+static inline void put_user_page_dirty_lock(struct page *page)
+{
+ put_user_pages_dirty_lock(&page, 1);
+}
+
#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
#define SECTION_IN_PAGE_FLAGS
#endif
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 9cbbb96c2a32..1d122e52c6de 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -171,7 +171,7 @@ static void xdp_umem_unpin_pages(struct xdp_umem *umem)
for (i = 0; i < umem->npgs; i++) {
struct page *page = umem->pgs[i];
- put_user_pages_dirty_lock(&page, 1);
+ put_user_page_dirty_lock(page);
}
kfree(umem->pgs);
--
2.22.0
next prev parent reply other threads:[~2019-07-22 4:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-22 4:30 [PATCH 0/4] put_user_page: new put_user_page_dirty*() helpers john.hubbard
2019-07-22 4:30 ` [PATCH 1/3] drivers/gpu/drm/via: convert put_page() to put_user_page*() john.hubbard
2019-07-22 9:33 ` Christoph Hellwig
2019-07-22 18:53 ` John Hubbard
2019-07-22 19:07 ` Matthew Wilcox
2019-07-22 19:10 ` John Hubbard
2019-07-22 4:30 ` [PATCH 2/3] net/xdp: " john.hubbard
2019-07-22 9:34 ` Christoph Hellwig
2019-07-22 4:30 ` john.hubbard [this message]
2019-07-22 19:05 ` [PATCH 3/3] gup: new put_user_page_dirty*() helpers John Hubbard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190722043012.22945-4-jhubbard@nvidia.com \
--to=john.hubbard@gmail.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bjorn.topel@intel.com \
--cc=boaz@plexistor.com \
--cc=bpf@vger.kernel.org \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=davem@davemloft.net \
--cc=david@fromorbit.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@lst.de \
--cc=idryomov@gmail.com \
--cc=jack@suse.cz \
--cc=jgg@ziepe.ca \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=jthumshirn@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=miklos@szeredi.hu \
--cc=ming.lei@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sage@redhat.com \
--cc=santosh.shilimkar@oracle.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=zyan@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).