It is quite a maze of EXPORTED symbols leading up to the three actual worker functions of GUP. Simplify this by reorganizing some of the code so the EXPORTED symbols directly call the correct internal function with validated and consistent arguments. Consolidate all the assertions into one place at the top of the call chains. Remove some dead code. Move more things into the mm/internal.h header v2: - Call the new flag FOLL_UNLOCKABLE - Revise comments around locked to reflect FOLL_UNLOCKABLE - s/lock_dropped/must_unlock/ - Various grammer fixes - Add missing FOLL_UNLOCKABLE users populate_vma_page_range, faultin_vma_page_range - Make the mmap_lock assertion unconditional - Move internal FOLL_ flags to mm/internal.h - Rebase onto 41c457e96ba5 ("Merge branch 'mm-nonmm-unstable' into mm-everything") v1: https://lore.kernel.org/r/0-v1-dd94f8f0d5ad+716-gup_tidy_jgg@xxxxxxxxxx Jason Gunthorpe (13): mm/gup: have internal functions get the mmap_read_lock() mm/gup: remove obsolete FOLL_LONGTERM comment mm/gup: don't call __gup_longterm_locked() if FOLL_LONGTERM cannot be set mm/gup: move try_grab_page() to mm/internal.h mm/gup: simplify the external interface functions and consolidate invariants mm/gup: add an assertion that the mmap lock is locked mm/gup: remove locked being NULL from faultin_vma_page_range() mm/gup: add FOLL_UNLOCKABLE mm/gup: make locked never NULL in the internal GUP functions mm/gup: remove pin_user_pages_fast_only() mm/gup: make get_user_pages_fast_only() return the common return value mm/gup: move gup_must_unshare() to mm/internal.h mm/gup: move private gup FOLL_ flags to internal.h include/linux/mm.h | 69 -------- include/linux/mm_types.h | 62 ++++--- mm/gup.c | 370 +++++++++++++++++++-------------------- mm/huge_memory.c | 10 -- mm/internal.h | 81 +++++++++ 5 files changed, 292 insertions(+), 300 deletions(-) base-commit: 41c457e96ba51547c6e80b125dcba91aa6a00699 -- 2.39.0