Skip to content

Commit

Permalink
prov/util: Add uffd user mode flag for kernels
Browse files Browse the repository at this point in the history
Linux kernels 5.11 and later introduced a UFFD_USER_MODE_ONLY. When
set, the userfaultfd object will only be able to handle page faults
originated from the user space on the registered regions.

If this is not set on kernels 5.11 or later, uffd will not work.

Signed-off-by: Ian Ziemba <[email protected]>
  • Loading branch information
chuckfossen authored and j-xiong committed Sep 13, 2024
1 parent f8a5b20 commit 27b977d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion prov/util/src/util_mem_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include <ofi_enosys.h>
#include <rdma/fi_ext.h>

#ifndef UFFD_USER_MODE_ONLY
#define UFFD_USER_MODE_ONLY 0
#endif

pthread_mutex_t mm_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mm_state_lock = PTHREAD_MUTEX_INITIALIZER;
Expand Down Expand Up @@ -701,7 +704,8 @@ static int ofi_uffd_start(struct ofi_mem_monitor *monitor)
if (!num_page_sizes)
return -FI_ENODATA;

uffd.fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
uffd.fd = syscall(__NR_userfaultfd,
O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
if (uffd.fd < 0) {
FI_WARN(&core_prov, FI_LOG_MR,
"syscall/userfaultfd %s\n", strerror(errno));
Expand Down

0 comments on commit 27b977d

Please sign in to comment.