hwpm: remove unused vmas parameter from get_user_pages()

Remove unused vmas parameter from get_user_pages() based
on following change in core kernel.

=====
    Upstream commit "54d020692b34"

    mm/gup: remove unused vmas parameter from get_user_pages()

    Patch series "remove the vmas parameter from GUP APIs", v6.

    (pin_/get)_user_pages[_remote]() each provide an optional output parameter
    for an array of VMA objects associated with each page in the input range.

    These provide the means for VMAs to be returned, as long as mm->mmap_lock
    is never released during the GUP operation (i.e.  the internal flag
    FOLL_UNLOCKABLE is not specified).

    In addition, these VMAs can only be accessed with the mmap_lock held and
    become invalidated the moment it is released.

    The vast majority of invocations do not use this functionality and of
    those that do, all but one case retrieve a single VMA to perform checks
    upon.

    It is not egregious in the single VMA cases to simply replace the
    operation with a vma_lookup().  In these cases we duplicate the (fast)
    lookup on a slow path already under the mmap_lock, abstracted to a new
    get_user_page_vma_remote() inline helper function which also performs
    error checking and reference count maintenance.

    The special case is io_uring, where io_pin_pages() specifically needs to
    assert that the VMAs underlying the range do not result in broken
    long-term GUP file-backed mappings.

    As GUP now internally asserts that FOLL_LONGTERM mappings are not
    file-backed in a broken fashion (i.e.  requiring dirty tracking) - as
    implemented in "mm/gup: disallow FOLL_LONGTERM GUP-nonfast writing to
    file-backed mappings" - this logic is no longer required and so we can
    simply remove it altogether from io_uring.

    Eliminating the vmas parameter eliminates an entire class of danging
    pointer errors that might have occured should the lock have been
    incorrectly released.

    In addition, the API is simplified and now clearly expresses what it is
    intended for - applying the specified GUP flags and (if pinning) returning
    pinned pages.

    This change additionally opens the door to further potential improvements
    in GUP and the possible marrying of disparate code paths.

    I have run this series against gup_test with no issues.

    Thanks to Matthew Wilcox for suggesting this refactoring!

    This patch (of 6):

    No invocation of get_user_pages() use the vmas parameter, so remove it.

    The GUP API is confusing and caveated.  Recent changes have done much to
    improve that, however there is more we can do.  Exporting vmas is a prime
    target as the caller has to be extremely careful to preclude their use
    after the mmap_lock has expired or otherwise be left with dangling
    pointers.

    Removing the vmas parameter focuses the GUP functions upon their primary
    purpose - pinning (and outputting) pages as well as performing the actions
    implied by the input flags.

    This is part of a patch series aiming to remove the vmas parameter
    altogether.

    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
=====

Bug 4276500

Change-Id: Ie2833b7aa4e8fef1362694de6e8a27bba553e3d4
Signed-off-by: Shardar Mohammed <smohammed@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2978634
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Shardar Mohammed
2023-09-09 20:32:31 +00:00
committed by mobile promotions
parent f116216688
commit 85732c9084

View File

@@ -457,8 +457,13 @@ int tegra_hwpm_map_update_allowlist(struct tegra_soc_hwpm *hwpm,
goto fail; goto fail;
} }
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0))
pinned_pages = get_user_pages(user_va & PAGE_MASK, pinned_pages = get_user_pages(user_va & PAGE_MASK,
hwpm->alist_map->num_pages, 0, hwpm->alist_map->pages, NULL); hwpm->alist_map->num_pages, 0, hwpm->alist_map->pages, NULL);
#else
pinned_pages = get_user_pages(user_va & PAGE_MASK,
hwpm->alist_map->num_pages, 0, hwpm->alist_map->pages);
#endif
if (pinned_pages != hwpm->alist_map->num_pages) { if (pinned_pages != hwpm->alist_map->num_pages) {
tegra_hwpm_err(hwpm, "Requested %llu pages / Got %ld pages", tegra_hwpm_err(hwpm, "Requested %llu pages / Got %ld pages",
hwpm->alist_map->num_pages, pinned_pages); hwpm->alist_map->num_pages, pinned_pages);