From: Alexei Starovoitov <[email protected]> Commit cf95e337cb63 ("mm: delete mmap_write_trylock() and vma_try_start_write()") removed it when khugepaged stopped using it. uprobes and dup_mmap() are going to use it.
Signed-off-by: Alexei Starovoitov <[email protected]> --- include/linux/mmap_lock.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h index b8a13b8d36a4..e5420b0ce61b 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -566,6 +566,18 @@ static inline int __must_check mmap_write_lock_killable(struct mm_struct *mm) return ret; } +static inline bool __must_check mmap_write_trylock(struct mm_struct *mm) +{ + bool ret; + + __mmap_lock_trace_start_locking(mm, true); + ret = down_write_trylock(&mm->mmap_lock) != 0; + if (ret) + mm_lock_seqcount_begin(mm); + __mmap_lock_trace_acquire_returned(mm, true, ret); + return ret; +} + /* * Drop all currently-held per-VMA locks. * This is called from the mmap_lock implementation directly before releasing -- 2.55.0
