History

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.

Andrea Arcangeli committed 9 years ago

Commit 163e11b1 parent 21205bf1 file · +25 −3Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/userfaultfd.h+25−3
@@ -18,9 +18,10 @@ · 17 unmodified lines
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 { · 98 unmodified lines
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;