The patch titled Subject: mm-add-account_locked_vm-utility-function-v3 has been removed from the -mm tree. Its filename was mm-add-account_locked_vm-utility-function-v3.patch This patch was dropped because it was folded into mm-add-account_locked_vm-utility-function.patch ------------------------------------------------------ From: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> Subject: mm-add-account_locked_vm-utility-function-v3 - uninline account_locked_vm (Andrew) - fix doc comment (Ira) - retain down_write_killable in vfio type1 (Alex) - leave Alexey's T-b since the code is the same aside from uninlining - sanity tested with vfio type1, sanity-built on ppc Link: http://lkml.kernel.org/r/20190529205019.20927-1-daniel.m.jordan@xxxxxxxxxx Signed-off-by: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> Tested-by: Alexey Kardashevskiy <aik@xxxxxxxxx> Cc: Alan Tull <atull@xxxxxxxxxx> Cc: Alex Williamson <alex.williamson@xxxxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Christophe Leroy <christophe.leroy@xxxxxx> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx> Cc: Ira Weiny <ira.weiny@xxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Moritz Fischer <mdf@xxxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxxx> Cc: Steve Sistare <steven.sistare@xxxxxxxxxx> Cc: Wu Hao <hao.wu@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/mm.h | 17 +---------------- mm/util.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 18 deletions(-) --- a/include/linux/mm.h~mm-add-account_locked_vm-utility-function-v3 +++ a/include/linux/mm.h @@ -1543,25 +1543,10 @@ long get_user_pages_unlocked(unsigned lo int get_user_pages_fast(unsigned long start, int nr_pages, unsigned int gup_flags, struct page **pages); +int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc); int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc, struct task_struct *task, bool bypass_rlim); -static inline int account_locked_vm(struct mm_struct *mm, unsigned long pages, - bool inc) -{ - int ret; - - if (pages == 0 || !mm) - return 0; - - down_write(&mm->mmap_sem); - ret = __account_locked_vm(mm, pages, inc, current, - capable(CAP_IPC_LOCK)); - up_write(&mm->mmap_sem); - - return ret; -} - /* Container for pinned pfns / pages */ struct frame_vector { unsigned int nr_allocated; /* Number of frames we have space for */ --- a/mm/util.c~mm-add-account_locked_vm-utility-function-v3 +++ a/mm/util.c @@ -303,7 +303,7 @@ void arch_pick_mmap_layout(struct mm_str /** * __account_locked_vm - account locked pages to an mm's locked_vm - * @mm: mm to account against, may be NULL + * @mm: mm to account against * @pages: number of pages to account * @inc: %true if @pages should be considered positive, %false if not * @task: task used to check RLIMIT_MEMLOCK @@ -314,7 +314,6 @@ void arch_pick_mmap_layout(struct mm_str * * Return: * * 0 on success - * * 0 if @mm is NULL (can happen for example if the task is exiting) * * -ENOMEM if RLIMIT_MEMLOCK would be exceeded. */ int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc, @@ -323,6 +322,8 @@ int __account_locked_vm(struct mm_struct unsigned long locked_vm, limit; int ret = 0; + lockdep_assert_held_exclusive(&mm->mmap_sem); + locked_vm = mm->locked_vm; if (inc) { if (!bypass_rlim) { @@ -346,6 +347,34 @@ int __account_locked_vm(struct mm_struct } EXPORT_SYMBOL_GPL(__account_locked_vm); +/** + * account_locked_vm - account locked pages to an mm's locked_vm + * @mm: mm to account against, may be NULL + * @pages: number of pages to account + * @inc: %true if @pages should be considered positive, %false if not + * + * Assumes a non-NULL @mm is valid (i.e. at least one reference on it). + * + * Return: + * * 0 on success, or if mm is NULL + * * -ENOMEM if RLIMIT_MEMLOCK would be exceeded. + */ +int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc) +{ + int ret; + + if (pages == 0 || !mm) + return 0; + + down_write(&mm->mmap_sem); + ret = __account_locked_vm(mm, pages, inc, current, + capable(CAP_IPC_LOCK)); + up_write(&mm->mmap_sem); + + return ret; +} +EXPORT_SYMBOL_GPL(account_locked_vm); + unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long pgoff) _ Patches currently in -mm which might be from daniel.m.jordan@xxxxxxxxxx are mm-add-account_locked_vm-utility-function.patch