---
name: "UFFDIO_SET_MODE"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/UFFDIO_SET_MODE"
---

# UFFDIO\_SET\_MODE(2const)

toggle userfaultfd runtime mode bits

## NAME

UFFDIO\_SET\_MODE - toggle userfaultfd runtime mode bits

## LIBRARY

Standard C library (*libc*, *-lc*)

## 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 */
};
```

## DESCRIPTION

Toggle userfaultfd features that may be flipped at runtime.

Bits set in *.enable* turn the named features on; bits set in *.disable* turn them off. The two fields must not overlap. Today only **UFFD\_FEATURE\_RWP\_ASYNC** is a valid bit in either field; any other bit causes the ioctl to fail with **EINVAL**. Enabling **UFFD\_FEATURE\_RWP\_ASYNC** also requires **UFFD\_FEATURE\_RWP** to have been negotiated at [**UFFDIO\_API**(2const)](/UFFDIO_API/2const.md) time.

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. This allows a single userfaultfd to switch between lightweight async detection and synchronous eviction without re-registering its ranges.

## 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*.

- **EINVAL**

  The fields *.enable* and *.disable* overlap.

- **EINVAL**

  **UFFD\_FEATURE\_RWP\_ASYNC** was requested without **UFFD\_FEATURE\_RWP** having been negotiated.

- **EFAULT**

  *argp* refers to an address that is outside the calling process's accessible address space.

## STANDARDS

Linux.

## HISTORY

Linux 7.2.

## EXAMPLES

See [**userfaultfd**(2)](/userfaultfd/2.md).

## SEE ALSO

[**ioctl**(2)](/ioctl/2.md), [**ioctl\_userfaultfd**(2)](/ioctl_userfaultfd/2.md), [**userfaultfd**(2)](/userfaultfd/2.md)

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