@@ -615,15 +615,12 @@ static void userfaultfd_event_complete(struct userfaultfd_ctx *ctx,
__remove_wait_queue(&ctx->event_wqh, &ewq->wq);
}
-int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
+int __dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
{
struct userfaultfd_ctx *ctx = NULL, *octx;
struct userfaultfd_fork_ctx *fctx;
octx = vma->vm_userfaultfd_ctx.ctx;
- if (!octx)
- return 0;
-
if (!(octx->features & UFFD_FEATURE_EVENT_FORK)) {
userfaultfd_reset_ctx(vma);
return 0;
@@ -247,7 +247,16 @@ static inline bool vma_can_userfault(struct vm_area_struct *vma,
vma_is_shmem(vma);
}
-extern int dup_userfaultfd(struct vm_area_struct *, struct list_head *);
+int __dup_userfaultfd(struct vm_area_struct *, struct list_head *);
+static inline int dup_userfaultfd(struct vm_area_struct *vma,
+ struct list_head *fcs)
+{
+ if (likely(!vma->vm_userfaultfd_ctx.ctx))
+ return 0;
+
+ return __dup_userfaultfd(vma, fcs);
+}
+
extern void dup_userfaultfd_complete(struct list_head *);
void dup_userfaultfd_fail(struct list_head *);
Make the NULL check for vma's userfaultfd ctx inline, so we can avoid the function call overhead if the ctx is NULL. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- fs/userfaultfd.c | 5 +---- include/linux/userfaultfd_k.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 5 deletions(-)