Skip to content

Commit 163e11b

Browse files
aagittorvalds
authored andcommitted
userfaultfd: hugetlbfs: UFFD_FEATURE_MISSING_HUGETLBFS
Userland developers asked to be notified immediately by the UFFDIO_API ioctl if hugetlbfs missing mode is supported by userfaultfd in the running kernel. This avoids the need to run UFFDIO_REGISTER on a hugetlbfs virtual memory range to find out. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Andrea Arcangeli <[email protected]> Cc: "Dr. David Alan Gilbert" <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Michael Rapoport <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Pavel Emelyanov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 21205bf commit 163e11b

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

include/uapi/linux/userfaultfd.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
* means the userland is reading).
1919
*/
2020
#define UFFD_API ((__u64)0xAA)
21-
#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \
22-
UFFD_FEATURE_EVENT_REMAP | \
23-
UFFD_FEATURE_EVENT_MADVDONTNEED)
21+
#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \
22+
UFFD_FEATURE_EVENT_REMAP | \
23+
UFFD_FEATURE_EVENT_MADVDONTNEED | \
24+
UFFD_FEATURE_MISSING_HUGETLBFS)
2425
#define UFFD_API_IOCTLS \
2526
((__u64)1 << _UFFDIO_REGISTER | \
2627
(__u64)1 << _UFFDIO_UNREGISTER | \
@@ -125,11 +126,32 @@ struct uffdio_api {
125126
* Note: UFFD_EVENT_PAGEFAULT and UFFD_PAGEFAULT_FLAG_WRITE
126127
* are to be considered implicitly always enabled in all kernels as
127128
* long as the uffdio_api.api requested matches UFFD_API.
129+
*
130+
* UFFD_FEATURE_MISSING_HUGETLBFS means an UFFDIO_REGISTER
131+
* with UFFDIO_REGISTER_MODE_MISSING mode will succeed on
132+
* hugetlbfs virtual memory ranges. Adding or not adding
133+
* UFFD_FEATURE_MISSING_HUGETLBFS to uffdio_api.features has
134+
* no real functional effect after UFFDIO_API returns, but
135+
* it's only useful for an initial feature set probe at
136+
* UFFDIO_API time. There are two ways to use it:
137+
*
138+
* 1) by adding UFFD_FEATURE_MISSING_HUGETLBFS to the
139+
* uffdio_api.features before calling UFFDIO_API, an error
140+
* will be returned by UFFDIO_API on a kernel without
141+
* hugetlbfs missing support
142+
*
143+
* 2) the UFFD_FEATURE_MISSING_HUGETLBFS can not be added in
144+
* uffdio_api.features and instead it will be set by the
145+
* kernel in the uffdio_api.features if the kernel supports
146+
* it, so userland can later check if the feature flag is
147+
* present in uffdio_api.features after UFFDIO_API
148+
* succeeded.
128149
*/
129150
#define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0)
130151
#define UFFD_FEATURE_EVENT_FORK (1<<1)
131152
#define UFFD_FEATURE_EVENT_REMAP (1<<2)
132153
#define UFFD_FEATURE_EVENT_MADVDONTNEED (1<<3)
154+
#define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4)
133155
__u64 features;
134156

135157
__u64 ioctls;

0 commit comments

Comments
 (0)