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.
Unified · Split
| @@ -18,9 +18,10 @@ · 17 unmodified lines | |||
| 18 | * means the userland is reading). | 18 | * means the userland is reading). |
| 19 | */ | 19 | */ |
| 20 | #define UFFD_API ((__u64)0xAA) | 20 | #define UFFD_API ((__u64)0xAA) |
| 21 | #define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \ | 21 | #define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \ |
| 22 | UFFD_FEATURE_EVENT_REMAP | \ | 22 | UFFD_FEATURE_EVENT_REMAP | \ |
| 23 | UFFD_FEATURE_EVENT_MADVDONTNEED) | 23 | UFFD_FEATURE_EVENT_MADVDONTNEED | \ |
| 24 | UFFD_FEATURE_MISSING_HUGETLBFS) | ||
| 24 | #define UFFD_API_IOCTLS \ | 25 | #define UFFD_API_IOCTLS \ |
| 25 | ((__u64)1 << _UFFDIO_REGISTER | \ | 26 | ((__u64)1 << _UFFDIO_REGISTER | \ |
| 26 | (__u64)1 << _UFFDIO_UNREGISTER | \ | 27 | (__u64)1 << _UFFDIO_UNREGISTER | \ |
| @@ -125,11 +126,32 @@ struct uffdio_api { · 98 unmodified lines | |||
| 125 | * Note: UFFD_EVENT_PAGEFAULT and UFFD_PAGEFAULT_FLAG_WRITE | 126 | * Note: UFFD_EVENT_PAGEFAULT and UFFD_PAGEFAULT_FLAG_WRITE |
| 126 | * are to be considered implicitly always enabled in all kernels as | 127 | * are to be considered implicitly always enabled in all kernels as |
| 127 | * long as the uffdio_api.api requested matches UFFD_API. | 128 | * 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. | ||
| 128 | */ | 149 | */ |
| 129 | #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) | 150 | #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) |
| 130 | #define UFFD_FEATURE_EVENT_FORK (1<<1) | 151 | #define UFFD_FEATURE_EVENT_FORK (1<<1) |
| 131 | #define UFFD_FEATURE_EVENT_REMAP (1<<2) | 152 | #define UFFD_FEATURE_EVENT_REMAP (1<<2) |
| 132 | #define UFFD_FEATURE_EVENT_MADVDONTNEED (1<<3) | 153 | #define UFFD_FEATURE_EVENT_MADVDONTNEED (1<<3) |
| 154 | #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) | ||
| 133 | __u64 features; | 155 | __u64 features; |
| 134 | 156 | ||
| 135 | __u64 ioctls; | 157 | __u64 ioctls; |