From 1b8ccb29720b4a3345d37a3f76566244709d1575 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 28 Oct 2025 21:09:35 -0400 Subject: [PATCH] mm/userfaultfd: Move ctx unlock to its own function Clean up the mfill_atomic() function by moving the unlock to its own function - like locking has done already. Signed-off-by: Liam R. Howlett --- mm/userfaultfd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 6324c114dfd9..1e6e7a670bf2 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -589,6 +589,12 @@ uffd_ctx_lock_and_validate_dst(struct uffd_info *info) return 0; } +static inline void uffd_ctx_unlock(struct uffd_info *info) +{ + up_read(&info->ctx->map_changing_lock); + uffd_mfill_unlock(info->dst_vma); +} + ssize_t uffd_get_dst_pmd(struct vm_area_struct *dst_vma, unsigned long dst_addr, pmd_t **dst_pmd) @@ -743,8 +749,7 @@ retry: } out_unlock: - up_read(&ctx->map_changing_lock); - uffd_mfill_unlock(info.dst_vma); + uffd_ctx_unlock(&info); out: if (info.foliop) folio_put(info.foliop); -- 2.51.0