On Tue, Jun 11, 2019 at 04:40:56PM +0200, Christoph Hellwig wrote: > We only support the generic GUP now, so rename the config option to > be more clear, and always use the mm/Kconfig definition of the > symbol and select it from the arch Kconfigs. Looks OK to me Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> But could you also roll something like this in to the series? There is no longer any reason for the special __weak stuff that I can see - just follow the normal pattern for stubbing config controlled functions through the header file. diff --git a/include/linux/mm.h b/include/linux/mm.h index 0e8834ac32b76c..13b1cb573383d5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1561,8 +1561,17 @@ long get_user_pages_locked(unsigned long start, unsigned long nr_pages, long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags); +#ifdef CONFIG_HAVE_FAST_GUP int get_user_pages_fast(unsigned long start, int nr_pages, unsigned int gup_flags, struct page **pages); +#else +static inline int get_user_pages_fast(unsigned long start, int nr_pages, + unsigned int gup_flags, + struct page **pages) +{ + return get_user_pages_unlocked(start, nr_pages, pages, gup_flags); +} +#endif /* Container for pinned pfns / pages */ struct frame_vector { @@ -1668,8 +1677,17 @@ extern int mprotect_fixup(struct vm_area_struct *vma, /* * doesn't attempt to fault and will return short. */ +#ifdef CONFIG_HAVE_FAST_GUP int __get_user_pages_fast(unsigned long start, int nr_pages, int write, struct page **pages); +#else +static inline int __get_user_pages_fast(unsigned long start, int nr_pages, + int write, struct page **pages) +{ + return 0; +} +#endif + /* * per-process(per-mm_struct) statistics. */ diff --git a/mm/util.c b/mm/util.c index 9834c4ab7d8e86..68575a315dc5ad 100644 --- a/mm/util.c +++ b/mm/util.c @@ -300,53 +300,6 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) } #endif -/* - * Like get_user_pages_fast() except its IRQ-safe in that it won't fall - * back to the regular GUP. - * Note a difference with get_user_pages_fast: this always returns the - * number of pages pinned, 0 if no pages were pinned. - * If the architecture does not support this function, simply return with no - * pages pinned. - */ -int __weak __get_user_pages_fast(unsigned long start, - int nr_pages, int write, struct page **pages) -{ - return 0; -} -EXPORT_SYMBOL_GPL(__get_user_pages_fast); - -/** - * get_user_pages_fast() - pin user pages in memory - * @start: starting user address - * @nr_pages: number of pages from start to pin - * @gup_flags: flags modifying pin behaviour - * @pages: array that receives pointers to the pages pinned. - * Should be at least nr_pages long. - * - * get_user_pages_fast provides equivalent functionality to get_user_pages, - * operating on current and current->mm, with force=0 and vma=NULL. However - * unlike get_user_pages, it must be called without mmap_sem held. - * - * get_user_pages_fast may take mmap_sem and page table locks, so no - * assumptions can be made about lack of locking. get_user_pages_fast is to be - * implemented in a way that is advantageous (vs get_user_pages()) when the - * user memory area is already faulted in and present in ptes. However if the - * pages have to be faulted in, it may turn out to be slightly slower so - * callers need to carefully consider what to use. On many architectures, - * get_user_pages_fast simply falls back to get_user_pages. - * - * Return: number of pages pinned. This may be fewer than the number - * requested. If nr_pages is 0 or negative, returns 0. If no pages - * were pinned, returns -errno. - */ -int __weak get_user_pages_fast(unsigned long start, - int nr_pages, unsigned int gup_flags, - struct page **pages) -{ - return get_user_pages_unlocked(start, nr_pages, pages, gup_flags); -} -EXPORT_SYMBOL_GPL(get_user_pages_fast); - unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long pgoff)