Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Souptick 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.com
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

authored by

Souptick Joarder and committed by
Boris Ostrovsky
d6bbc2ff 77905584

+2 -8
+2 -8
drivers/xen/gntdev.c
··· 731 731 unsigned long xen_pfn; 732 732 int ret; 733 733 734 - ret = get_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page); 734 + ret = pin_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page); 735 735 if (ret < 0) 736 736 return ret; 737 737 ··· 745 745 746 746 static void gntdev_put_pages(struct gntdev_copy_batch *batch) 747 747 { 748 - unsigned int i; 749 - 750 - for (i = 0; i < batch->nr_pages; i++) { 751 - if (batch->writeable && !PageDirty(batch->pages[i])) 752 - set_page_dirty_lock(batch->pages[i]); 753 - put_page(batch->pages[i]); 754 - } 748 + unpin_user_pages_dirty_lock(batch->pages, batch->nr_pages, batch->writeable); 755 749 batch->nr_pages = 0; 756 750 batch->writeable = false; 757 751 }