userfaultfd: switch to exclusive wakeup for blocking reads

The uffd can't short-read. Lengths not multiple of sizeof(struct
uffd_msg) immediately return -EINVAL. The userfaults aren't
broadcasted to all readers.

read will return one or more events, sizeof(struct uffd_msg). Signal
interruptions only are reported if it's about to block and it found

Every new userfault blocking (and at max 1 event to read is generated
for each new blocking userfaults) wakes one more reader, and each
reader is guaranteed to be blocked only if the pending (pending as not
read yet) waitqueue is truly empty.

Signed-off-by: Andrea Arcangeli <>
1 file changed