lkml.org 
[lkml]   [2019]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v3 12/41] genwqe: convert put_page() to put_user_page*()
    Date
    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").

    This changes the release code slightly, because each page slot in the
    page_list[] array is no longer checked for NULL. However, that check
    was wrong anyway, because the get_user_pages() pattern of usage here
    never allowed for NULL entries within a range of pinned pages.

    Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    Cc: Frank Haverkamp <haver@linux.vnet.ibm.com>
    Cc: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: John Hubbard <jhubbard@nvidia.com>
    ---
    drivers/misc/genwqe/card_utils.c | 17 +++--------------
    1 file changed, 3 insertions(+), 14 deletions(-)

    diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c
    index 2e1c4d2905e8..2a888f31d2c5 100644
    --- a/drivers/misc/genwqe/card_utils.c
    +++ b/drivers/misc/genwqe/card_utils.c
    @@ -517,24 +517,13 @@ int genwqe_free_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl)
    /**
    * genwqe_free_user_pages() - Give pinned pages back
    *
    - * Documentation of get_user_pages is in mm/gup.c:
    - *
    - * If the page is written to, set_page_dirty (or set_page_dirty_lock,
    - * as appropriate) must be called after the page is finished with, and
    - * before put_page is called.
    + * The pages may have been written to, so we call put_user_pages_dirty_lock(),
    + * rather than put_user_pages().
    */
    static int genwqe_free_user_pages(struct page **page_list,
    unsigned int nr_pages, int dirty)
    {
    - unsigned int i;
    -
    - for (i = 0; i < nr_pages; i++) {
    - if (page_list[i] != NULL) {
    - if (dirty)
    - set_page_dirty_lock(page_list[i]);
    - put_page(page_list[i]);
    - }
    - }
    + put_user_pages_dirty_lock(page_list, nr_pages, dirty);
    return 0;
    }

    --
    2.22.0
    \
     
     \ /
      Last update: 2019-08-07 03:54    [W:3.165 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site