Commit d6bbc2ff authored by Souptick Joarder's avatar Souptick Joarder Committed by Boris Ostrovsky

xen/gntdev.c: Convert get_user_pages*() to pin_user_pages*()

In 2019, we introduced pin_user_pages*() and now we are converting
get_user_pages*() to the new API as appropriate. [1] & [2] could
be referred for more information. This is case 5 as per document [1].

[1] Documentation/core-api/pin_user_pages.rst

[2] "Explicit pinning of user-space pages":
        https://lwn.net/Articles/807108/Signed-off-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Link: https://lore.kernel.org/r/1599375114-32360-2-git-send-email-jrdr.linux@gmail.comReviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent 77905584
...@@ -731,7 +731,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt, ...@@ -731,7 +731,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt,
unsigned long xen_pfn; unsigned long xen_pfn;
int ret; int ret;
ret = get_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page); ret = pin_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -745,13 +745,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt, ...@@ -745,13 +745,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt,
static void gntdev_put_pages(struct gntdev_copy_batch *batch) static void gntdev_put_pages(struct gntdev_copy_batch *batch)
{ {
unsigned int i; unpin_user_pages_dirty_lock(batch->pages, batch->nr_pages, batch->writeable);
for (i = 0; i < batch->nr_pages; i++) {
if (batch->writeable && !PageDirty(batch->pages[i]))
set_page_dirty_lock(batch->pages[i]);
put_page(batch->pages[i]);
}
batch->nr_pages = 0; batch->nr_pages = 0;
batch->writeable = false; batch->writeable = false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment