Thread (64 messages) 64 messages, 13 authors, 2019-08-09

Re: [PATCH 20/34] xen: convert put_page() to put_user_page*()

From: Juergen Gross <jgross@suse.com>
Date: 2019-08-02 04:37:05
Also in: amd-gfx, ceph-devel, dri-devel, intel-gfx, kvm, linux-arm-kernel, linux-block, linux-crypto, linux-fsdevel, linux-media, linux-mm, linux-nfs, linux-rdma, linux-xfs, lkml, netdev, sparclinux, xen-devel

On 02.08.19 04:19, john.hubbard@gmail.com wrote:
quoted hunk ↗ jump to hunk
From: John Hubbard <jhubbard@nvidia.com>

For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").

Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
  drivers/xen/gntdev.c  | 5 +----
  drivers/xen/privcmd.c | 7 +------
  2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 4c339c7e66e5..2586b3df2bb6 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -864,10 +864,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt,
  
  static void gntdev_put_pages(struct gntdev_copy_batch *batch)
  {
-	unsigned int i;
-
-	for (i = 0; i < batch->nr_pages; i++)
-		put_page(batch->pages[i]);
+	put_user_pages(batch->pages, batch->nr_pages);
  	batch->nr_pages = 0;
  }
  
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 2f5ce7230a43..29e461dbee2d 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -611,15 +611,10 @@ static int lock_pages(
  
  static void unlock_pages(struct page *pages[], unsigned int nr_pages)
  {
-	unsigned int i;
-
  	if (!pages)
  		return;
  
-	for (i = 0; i < nr_pages; i++) {
-		if (pages[i])
-			put_page(pages[i]);
-	}
+	put_user_pages(pages, nr_pages);
You are not handling the case where pages[i] is NULL here. Or am I
missing a pending patch to put_user_pages() here?


Juergen
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help