Re: [PATCH 1/1] userfaultfd: don't pin the user memory in userfaultfd_file_create()

From: Oleg Nesterov
Date: Mon May 16 2016 - 12:21:10 EST


On 05/16, Andrea Arcangeli wrote:
>
> Reviewed-by: Andrea Arcangeli <aarcange@xxxxxxxxxx>

Thanks,

> > +static inline bool userfaultfd_get_mm(struct userfaultfd_ctx *ctx)
> > +{
> > + return atomic_inc_not_zero(&ctx->mm->mm_users);
> > +}
>
> Nice cleanup, but wouldn't it be more generic to implement this as
> mmget(&ctx->mm) (or maybe mmget_not_zero) in include/linux/mm.h
> instead of userfaultfd.c, so then others can use it too, see:

Yes, agreed. userfaultfd_get_mm() doesn't look as good as I initially thought.

So I guess it would be better to make V2 right now, to avoid another change in
userfaultfd.c which changes the same code.

Except I think mmget_not_zero() should go to linux/sched.h, until we move
mmdrop/mmput/etc to linux/mm.h.

I'll send V2 soon...

Oleg.