UFFDIO_SET_MODE(2const)

πŸ“¦
version 6.20 Β· 2 versions
, in arch rolling, nixpkgs unstable

✨ 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 than UFFD_FEATURE_RWP_ASYNC was specified in .enable or .disable. yeah, only that one bit is allowed, sorry babe.
  • EINVAL β€” The fields .enable and .disable overlap. you cannot turn the same thing on and off, pick a lane 🚫
  • EINVAL β€” UFFD_FEATURE_RWP_ASYNC was requested without UFFD_FEATURE_RWP having been negotiated. should've done the handshake at UFFDIO_API(2const) time, king πŸ’€
  • EFAULT β€” argp refers 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


πŸ’œ reminder bestie: every detail on this page is load-bearing. .enable and .disable must never overlap, only UFFD_FEATURE_RWP_ASYNC is a valid bit today, and you must have negotiated UFFD_FEATURE_RWP at UFFDIO_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