Hello, Sorry for delay. So this is the same patch, just I added the helpers for get/put mm->mm_users. I won't mind to change userfaultfd_get_mm() to return mm_struct-or- NULL, or perhaps instead we should simply add the trivial helper which does atomic_inc_not_zero(mm->mm_users) into sched.h, it can have more callers (fs/proc, uprobes).
Testing. I have found selftests/vm/userfaultfd.c and it seems to work. Oleg.

