UFFDIO_SET_MODE(2const)
β¨ UFFDIO_SET_MODE β¨
okay bestie, welcome to the UFFDIO_SET_MODE(2const) page β yes it's a 2const situation, we're in the constants and ioctl args corner of the Linux man-pages universe, and honestly? it's giving very niche, very cute, very "only three people on earth need this and one of them is you" π
π LIBRARY
Standard C library (libc, -lc) β the usual queen, nothing new here π«Ά
πΈ SYNOPSIS
#include <linux/userfaultfd.h> /* Definition of UFFD* constants */
#include <sys/ioctl.h>
int ioctl(int fd, UFFDIO_SET_MODE, struct uffdio_set_mode *argp);
#include <linux/userfaultfd.h>
struct uffdio_set_mode {
__u64 enable; /* Feature bits to set */
__u64 disable; /* Feature bits to clear */
};
not me showing you a struct with two __u64 fields and calling it a day π it's literally just "turn this on, turn that off", that's the whole vibe.
π¦ DESCRIPTION
Toggle userfaultfd features that may be flipped at runtime. like, at runtime runtime. mid-flight. no restart, no re-registration, she's flexible π
Bits set in .enable turn the named features on; bits set in .disable turn them off. The two fields must not overlap β no cap, they just can't, that's the rule π«
Today only UFFD_FEATURE_RWP_ASYNC is a valid bit in either field; any other bit causes the ioctl to fail with EINVAL. So if you're out here trying to be creative with bits, the kernel said "no β€οΈ" and threw EINVAL in your face.
Enabling UFFD_FEATURE_RWP_ASYNC also requires UFFD_FEATURE_RWP to have been negotiated at UFFDIO_API(2const) time. so it's a package deal β you can't get the async upgrade unless you already signed up for RWP at the API handshake. prerequisites, bestie, we love a prerequisites moment β¨
The operation is serialized against in-flight page faults, so the new mode takes effect only after every fault that started before the call has finished, and any fault that starts after the call observes the new mode. very "we take attendance, then we change the rules" energy π
This allows a single userfaultfd to switch between lightweight async detection and synchronous eviction without re-registering its ranges. which is the slay β one fd, two moods, zero re-registration drama π¦
π RETURN VALUE
On success, 0 is returned. π
On error, -1 is returned and errno is set to indicate the error. π
π₯ ERRORS
EINVALβ A bit other thanUFFD_FEATURE_RWP_ASYNCwas specified in.enableor.disable. yeah, only that one bit is allowed, sorry babe.EINVALβ The fields.enableand.disableoverlap. you cannot turn the same thing on and off, pick a lane π«EINVALβUFFD_FEATURE_RWP_ASYNCwas requested withoutUFFD_FEATURE_RWPhaving been negotiated. should've done the handshake atUFFDIO_API(2const)time, king πEFAULTβargprefers to an address that is outside the calling process's accessible address space. can't read that pointer, it's Not From Here π
π STANDARDS
Linux. that's it, that's the standard. periodt.
β HISTORY
Linux 7.2. β¨ new-ish, shiny, freshly dropped.
π EXAMPLES
See userfaultfd(2) β the main character of the userfaultfd cinematic universe, she has the examples, go look π
π«Ά SEE ALSO
ioctl(2)ioctl_userfaultfd(2)userfaultfd(2)linux.git/Documentation/admin-guide/mm/userfaultfd.rst
π reminder bestie: every detail on this page is load-bearing..enableand.disablemust never overlap, onlyUFFD_FEATURE_RWP_ASYNCis a valid bit today, and you must have negotiatedUFFD_FEATURE_RWPatUFFDIO_API(2const)time to enable it. iykyk πΈ
and that's a wrap on UFFDIO_SET_MODE(2const)! π brought to you by the Linux man-pages 6.20, dated 2026-05-28 β she's documented, she's iconic, she's yours π
π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms