UFFDIO_ZEROPAGE(2const)

πŸ’– UFFDIO_ZEROPAGE πŸ’–

okay bestie, so this is a page from the Linux man-pages (section 2const, the "these are the constants and structs that belong to a syscall" corner of the manual), and it's all about one very specific little ioctl called UFFDIO_ZEROPAGE. she zeroes out memory. that's her whole thing. and honestly? she ate. ✨


🌸 NAME 🌸

UFFDIO_ZEROPAGE β€” zero out a memory range registered with userfaultfd


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)


πŸŽ€ SYNOPSIS πŸŽ€

#include <linux/userfaultfd.h>  /* Definition of UFFD* constants */
#include <sys/ioctl.h>

int ioctl(int fd, UFFDIO_ZEROPAGE, struct uffdio_zeropage *argp);

#include <linux/userfaultfd.h>

struct uffdio_zeropage {
    struct uffdio_range  range;
    __u64                mode;      /* Flags controlling behavior */
    __s64                zeropage;  /* Number of bytes zeroed */
};

like. look at her. struct uffdio_range range, a mode for flags, and a zeropage that holds a byte count. it's giving "small but mighty". 🫢


✨ DESCRIPTION ✨

Zero out a memory range registered with userfaultfd. that's it, that's the job, and she does it flawlessly no cap. πŸ’…

the following value may be bitwise ORed into mode to change the behavior of the UFFDIO_ZEROPAGE operation:

  • UFFDIO_ZEROPAGE_MODE_DONTWAKE β€” Do not wake up the thread that waits for page-fault resolution. so basically "do the thing but don't ping anybody about it", lowkey antisocial but valid.

the zeropage field is how the kernel hands back the number of bytes that was actually zeroed β€” or an error, in the same manner as UFFDIO_COPY. and listen, this part is important: if the value returned in the zeropage field doesn't match the value that was specified in range.len, the operation fails with the error EAGAIN. 😭

also!! zeropage is output-only β€” it is not read by the UFFDIO_ZEROPAGE operation. so don't go filling it in and expecting the kernel to care, because she will not. πŸ™ˆ


πŸ”₯ RETURN VALUE πŸ”₯

this ioctl(2) operation returns 0 on success. and in that case? the entire area was zeroed. every last byte. iconic behavior. ✨

on error, -1 is returned and errno is set to indicate the error. πŸ˜”


πŸ’€ ERRORS πŸ’€

  • EAGAIN β€” The number of bytes zeroed (i.e., the value returned in the zeropage field) does not equal the value that was specified in the range.len field.
  • EINVAL β€” Either range.start or range.len was not a multiple of the system page size; or range.len was zero; or the range specified was invalid. so many ways to be wrong bestie, we hate to see it.
  • EINVAL β€” An invalid bit was specified in the mode field.
  • ESRCH (since Linux 4.13) β€” The faulting process has exited at the time of a UFFDIO_ZEROPAGE operation. she's gone. the process literally left the chat. 😭

⭐ STANDARDS ⭐

Linux. periodt.


πŸ¦‹ HISTORY πŸ¦‹

Linux 4.3. a whole era. she's been around. πŸ‘‘


🌈 EXAMPLES 🌈

See userfaultfd(2). (go read that one too, i'm not doing all the work for you 😌)


πŸ‘€ SEE ALSO πŸ‘€

ioctl(2), ioctl_userfaultfd(2), userfaultfd(2)

linux.git/Documentation/admin-guide/mm/userfaultfd.rst


and that's the whole page bestie, mwah πŸ’‹ this one came from Linux man-pages 6.20, dated 2026-02-08, and it's filed under UFFDIO_ZEROPAGE(2const). go zero some memory, you've got this. πŸŽ€πŸ’œπŸŒΈ

πŸ“¦ 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