---
name: "io_uring_register"
section: "2"
platform: "linux"
package: "liburing"
version: "2.15-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/io_uring_register"
---

# io\_uring\_register(2)

register files or user buffers for asynchronous I/O

## NAME

io\_uring\_register - register files or user buffers for asynchronous I/O

## SYNOPSIS

```
#include <liburing.h>
```

**int io\_uring\_register(unsigned int** *fd***, unsigned int** *opcode***,**                       **void \****arg***, unsigned int** *nr\_args***);**

## DESCRIPTION

The [**io\_uring\_register**(2)](/io_uring_register/2.md) system call registers resources (e.g. user buffers, files, eventfd, personality, restrictions) for use in an [**io\_uring**(7)](/io_uring/7.md) instance referenced by *fd*. Registering files or user buffers allows the kernel to take long term references to internal data structures or create long term mappings of application memory, greatly reducing per-I/O overhead.

*fd* is the file descriptor returned by a call to [**io\_uring\_setup**(2)](/io_uring_setup/2.md). If *opcode* has the flag **IORING\_REGISTER\_USE\_REGISTERED\_RING** ored into it, *fd* is instead the index of a registered ring fd.

*opcode* can be one of:

- **IORING\_REGISTER\_BUFFERS**

  *arg* points to a *struct iovec* array of *nr\_args* entries.  The buffers associated with the iovecs will be locked in memory and charged against the user's **RLIMIT\_MEMLOCK** resource limit.  See [**getrlimit**(2)](/getrlimit/2.md) for more information.  Additionally, there is a size limit of 1GiB per buffer.  Currently, the buffers must be anonymous, non-file-backed memory, such as that returned by [**malloc**(3)](/malloc/3.md) or [**mmap**(2)](/mmap/2.md) with the **MAP\_ANONYMOUS** flag set.  It is expected that this limitation will be lifted in the future. Huge pages are supported as well. Note that the entire huge page will be pinned in the kernel, even if only a portion of it is used.

  After a successful call, the supplied buffers are mapped into the kernel and eligible for I/O.  To make use of them, the application must specify the **IORING\_OP\_READ\_FIXED** or **IORING\_OP\_WRITE\_FIXED** opcodes in the submission queue entry (see the *struct io\_uring\_sqe* definition in [**io\_uring\_enter**(2)](/io_uring_enter/2.md)), and set the *buf\_index* field to the desired buffer index.  The memory range described by the submission queue entry's *addr* and *len* fields must fall within the indexed buffer.

  It is perfectly valid to setup a large buffer and then only use part of it for an I/O, as long as the range is within the originally mapped region.

  An application can increase or decrease the size or number of registered buffers by first unregistering the existing buffers, and then issuing a new call to [**io\_uring\_register**(2)](/io_uring_register/2.md) with the new buffers.

  Note that before 5.13 registering buffers would wait for the ring to idle. If the application currently has requests in-flight, the registration will wait for those to finish before proceeding.

  An application need not unregister buffers explicitly before shutting down the io\_uring instance. Note, however, that shutdown processing may run asynchronously within the kernel. As a result, it is not guaranteed that pages are immediately unpinned in this case. Available since 5.1.

- **IORING\_REGISTER\_BUFFERS2**

  Register buffers for I/O. Similar to **IORING\_REGISTER\_BUFFERS** but aims to have a more extensible ABI.

  *arg* points to a *struct* *io\_uring\_rsrc\_register*, and *nr\_args* should be set to the number of bytes in the structure.

-

  ```
  struct io_uring_rsrc_register {
      __u32 nr;
      __u32 flags;
      __u64 resv2;
      __aligned_u64 data;
      __aligned_u64 tags;
  };
  ```

-

  The *data* field contains a pointer to a *struct iovec* array of *nr* entries. The *tags* field should either be 0, then tagging is disabled, or point to an array of *nr* "tags" (unsigned 64 bit integers). If a tag is zero, then tagging for this particular resource (a buffer in this case) is disabled. Otherwise, after the resource had been unregistered and it's not used anymore, a CQE will be posted with *user\_data* set to the specified tag and all other fields zeroed.

  The *flags* field supports the following flags:

-

  **IORING\_RSRC\_REGISTER\_SPARSE** If set, io\_uring will register *nr* empty buffers, which need to be updated before use. When this flag is set, *data* and *tags* must be NULL. Available since 5.19.

-

  Note that resource updates, e.g. **IORING\_REGISTER\_BUFFERS\_UPDATE**, don't necessarily deallocate resources by the time it returns, but they might be held alive until all requests using it complete.

  Available since 5.13.

- **IORING\_REGISTER\_BUFFERS\_UPDATE**

  Updates registered buffers with new ones, either turning a sparse entry into a real one, or replacing an existing entry.

  *arg* must contain a pointer to a *struct* *io\_uring\_rsrc\_update2*, which contains an offset on which to start the update, and an array of *struct* *iovec*. *tags* points to an array of tags. *nr* must contain the number of descriptors in the passed in arrays. See **IORING\_REGISTER\_BUFFERS2** for the resource tagging description.

```
struct io_uring_rsrc_update2 {
    __u32 offset;
    __u32 resv;
    __aligned_u64 data;
    __aligned_u64 tags;
    __u32 nr;
    __u32 resv2;
};
```

Available since 5.13.

- **IORING\_UNREGISTER\_BUFFERS**

  This operation takes no argument, and *arg* must be passed as NULL.  All previously registered buffers associated with the io\_uring instance will be released synchronously. Available since 5.1.

- **IORING\_REGISTER\_FILES**

  Register files for I/O. *arg* contains a pointer to an array of *nr\_args* file descriptors (signed 32 bit integers).

  To make use of the registered files, the **IOSQE\_FIXED\_FILE** flag must be set in the *flags* member of the *struct io\_uring\_sqe*, and the *fd* member is set to the index of the file in the file descriptor array.

  The file set may be sparse, meaning that the **fd** field in the array may be set to **-1**. See **IORING\_REGISTER\_FILES\_UPDATE** for how to update files in place.

  Note that before 5.13 registering files would wait for the ring to idle. If the application currently has requests in-flight, the registration will wait for those to finish before proceeding. See **IORING\_REGISTER\_FILES\_UPDATE** for how to update an existing set without that limitation.

  Files are automatically unregistered when the io\_uring instance is torn down. An application needs only unregister if it wishes to register a new set of fds. Available since 5.1.

- **IORING\_REGISTER\_FILES2**

  Register files for I/O. Similar to **IORING\_REGISTER\_FILES**.

  *arg* points to a *struct* *io\_uring\_rsrc\_register*, and *nr\_args* should be set to the number of bytes in the structure.

  The *data* field contains a pointer to an array of *nr* file descriptors (signed 32 bit integers). *tags* field should either be 0 or or point to an array of *nr* "tags" (unsigned 64 bit integers). See **IORING\_REGISTER\_BUFFERS2** for more info on resource tagging.

  Note that resource updates, e.g. **IORING\_REGISTER\_FILES\_UPDATE**, don't necessarily deallocate resources, they might be held until all requests using that resource complete.

  Available since 5.13.

- **IORING\_REGISTER\_FILES\_UPDATE**

  This operation replaces existing files in the registered file set with new ones, either turning a sparse entry (one where fd is equal to **-1**) into a real one, removing an existing entry (new one is set to **-1**), or replacing an existing entry with a new existing entry.

  *arg* must contain a pointer to a *struct* *io\_uring\_rsrc\_update*, which contains an offset on which to start the update, and an array of file descriptors to use for the update. *nr\_args* must contain the number of descriptors in the passed in array. Available since 5.5.

  File descriptors can be skipped if they are set to **IORING\_REGISTER\_FILES\_SKIP**. Skipping an fd will not touch the file associated with the previous fd at that index. Available since 5.12.

- **IORING\_REGISTER\_FILES\_UPDATE2**

  Similar to **IORING\_REGISTER\_FILES\_UPDATE**, replaces existing files in the registered file set with new ones, either turning a sparse entry (one where fd is equal to **-1**) into a real one, removing an existing entry (new one is set to **-1**), or replacing an existing entry with a new existing entry.

  *arg* must contain a pointer to a *struct* *io\_uring\_rsrc\_update2*, which contains an offset on which to start the update, and an array of file descriptors to use for the update stored in *data*. *tags* points to an array of tags. *nr* must contain the number of descriptors in the passed in arrays. See **IORING\_REGISTER\_BUFFERS2** for the resource tagging description.

  Available since 5.13.

- **IORING\_UNREGISTER\_FILES**

  This operation requires no argument, and *arg* must be passed as NULL.  All previously registered files associated with the io\_uring instance will be unregistered. Available since 5.1.

- **IORING\_REGISTER\_EVENTFD**

  It's possible to use [**eventfd**(2)](/eventfd/2.md) to get notified of completion events on an io\_uring instance. If this is desired, an eventfd file descriptor can be registered through this operation. *arg* must contain a pointer to the eventfd file descriptor, and *nr\_args* must be 1. Note that while io\_uring generally takes care to avoid spurious events, they can occur. Similarly, batched completions of CQEs may only trigger a single eventfd notification even if multiple CQEs are posted. The application should make no assumptions on number of events being available having a direct correlation to eventfd notifications posted. An eventfd notification must thus only be treated as a hint to check the CQ ring for completions. Available since 5.2.

  An application can temporarily disable notifications, coming through the registered eventfd, by setting the **IORING\_CQ\_EVENTFD\_DISABLED** bit in the *flags* field of the CQ ring. Available since 5.8.

- **IORING\_REGISTER\_EVENTFD\_ASYNC**

  This works just like **IORING\_REGISTER\_EVENTFD**, except notifications are only posted for events that complete in an async manner. This means that events that complete inline while being submitted do not trigger a notification event. The arguments supplied are the same as for **IORING\_REGISTER\_EVENTFD**. Available since 5.6.

- **IORING\_UNREGISTER\_EVENTFD**

  Unregister an eventfd file descriptor to stop notifications. Since only one eventfd descriptor is currently supported, this operation takes no argument, and *arg* must be passed as NULL and *nr\_args* must be zero. Available since 5.2.

- **IORING\_REGISTER\_PROBE**

  This operation returns a structure, io\_uring\_probe, which contains information about the opcodes supported by io\_uring on the running kernel. *arg* must contain a pointer to a struct io\_uring\_probe, and *nr\_args* must contain the size of the ops array in that probe struct. The ops array is of the type io\_uring\_probe\_op, which holds the value of the opcode and a flags field. If the flags field has **IO\_URING\_OP\_SUPPORTED** set, then this opcode is supported on the running kernel. Available since 5.6.

- **IORING\_REGISTER\_PERSONALITY**

  This operation registers credentials of the running application with io\_uring, and returns an id associated with these credentials. Applications wishing to share a ring between separate users/processes can pass in this credential id in the sqe **personality** field. If set, that particular sqe will be issued with these credentials. Must be invoked with *arg* set to NULL and *nr\_args* set to zero. Available since 5.6.

- **IORING\_UNREGISTER\_PERSONALITY**

  This operation unregisters a previously registered personality with io\_uring. *nr\_args* must be set to the id in question, and *arg* must be set to NULL. Available since 5.6.

- **IORING\_REGISTER\_ENABLE\_RINGS**

  This operation enables an io\_uring ring started in a disabled state (**IORING\_SETUP\_R\_DISABLED** was specified in the call to [**io\_uring\_setup**(2)](/io_uring_setup/2.md)). While the io\_uring ring is disabled, submissions are not allowed and registrations are not restricted.

  After the execution of this operation, the io\_uring ring is enabled: submissions and registration are allowed, but they will be validated following the registered restrictions (if any). This operation takes no argument, must be invoked with *arg* set to NULL and *nr\_args* set to zero. Available since 5.10.

- **IORING\_REGISTER\_RESTRICTIONS**

  *arg* points to a *struct io\_uring\_restriction* array of *nr\_args* entries.

  With an entry it is possible to allow an [**io\_uring\_register**(2)](/io_uring_register/2.md) *opcode*, or specify which *opcode* and *flags* of the submission queue entry are allowed, or require certain *flags* to be specified (these flags must be set on each submission queue entry).

  All the restrictions must be submitted with a single [**io\_uring\_register**(2)](/io_uring_register/2.md) call and they are handled as an allowlist (opcodes and flags not registered, are not allowed).

  Restrictions can be registered only if the io\_uring ring started in a disabled state (**IORING\_SETUP\_R\_DISABLED** must be specified in the call to [**io\_uring\_setup**(2)](/io_uring_setup/2.md)).

  Available since 5.10.

- **IORING\_REGISTER\_IOWQ\_AFF**

  By default, async workers created by io\_uring will inherit the CPU mask of its parent. This is usually all the CPUs in the system, unless the parent is being run with a limited set. If this isn't the desired outcome, the application may explicitly tell io\_uring what CPUs the async workers may run on. *arg* must point to a **cpu\_set\_t** mask, and *nr\_args* the byte size of that mask.

  Available since 5.14.

- **IORING\_UNREGISTER\_IOWQ\_AFF**

  Undoes a CPU mask previously set with **IORING\_REGISTER\_IOWQ\_AFF**. Must not have *arg* or *nr\_args* set.

  Available since 5.14.

- **IORING\_REGISTER\_IOWQ\_MAX\_WORKERS**

  By default, io\_uring limits the unbounded workers created to the maximum processor count set by *RLIMIT\_NPROC* and the bounded workers is a function of the SQ ring size and the number of CPUs in the system. Sometimes this can be excessive (or too little, for bounded), and this command provides a way to change the count per ring (per NUMA node) instead.

  *arg* must be set to an *unsigned int* pointer to an array of two values, with the values in the array being set to the maximum count of workers per NUMA node. Index 0 holds the bounded worker count, and index 1 holds the unbounded worker count. On successful return, the passed in array will contain the previous maximum values for each type. If the count being passed in is 0, then this command returns the current maximum values and doesn't modify the current setting. *nr\_args* must be set to 2, as the command takes two values.

  Available since 5.15.

- **IORING\_REGISTER\_RING\_FDS**

  Whenever [**io\_uring\_enter**(2)](/io_uring_enter/2.md) is called to submit request or wait for completions, the kernel must grab a reference to the file descriptor. If the application using io\_uring is threaded, the file table is marked as shared, and the reference grab and put of the file descriptor count is more expensive than it is for a non-threaded application.

  Similarly to how io\_uring allows registration of files, this allow registration of the ring file descriptor itself. This reduces the overhead of the [**io\_uring\_enter**(2)](/io_uring_enter/2.md) system call.

  *arg* must be set to a pointer to an array of type *struct io\_uring\_rsrc\_update* of *nr\_args* number of entries. The **data** field of this struct must contain an io\_uring file descriptor, and the **offset** field can be either **-1** or an explicit offset desired for the registered file descriptor value. If **-1** is used, then upon successful return of this system call, the field will contain the value of the registered file descriptor to be used for future [**io\_uring\_enter**(2)](/io_uring_enter/2.md) system calls.

  On successful completion of this request, the returned descriptors may be used instead of the real file descriptor for [**io\_uring\_enter**(2)](/io_uring_enter/2.md), provided that **IORING\_ENTER\_REGISTERED\_RING** is set in the *flags* for the system call. This flag tells the kernel that a registered descriptor is used rather than a real file descriptor.

  Each thread or process using a ring must register the file descriptor directly by issuing this request.

  The maximum number of supported registered ring descriptors is currently limited to **16.**

  Available since 5.18.

- **IORING\_UNREGISTER\_RING\_FDS**

  Unregister descriptors previously registered with **IORING\_REGISTER\_RING\_FDS**.

  *arg* must be set to a pointer to an array of type *struct io\_uring\_rsrc\_update* of *nr\_args* number of entries. Only the **offset** field should be set in the structure, containing the registered file descriptor offset previously returned from **IORING\_REGISTER\_RING\_FDS** that the application wishes to unregister.

  Note that this isn't done automatically on ring exit, if the thread or task that previously registered a ring file descriptor isn't exiting. It is recommended to manually unregister any previously registered ring descriptors if the ring is closed and the task persists. This will free up a registration slot, making it available for future use.

  Available since 5.18.

- **IORING\_REGISTER\_PBUF\_RING**

  Registers a shared buffer ring to be used with provided buffers. This is a newer alternative to using **IORING\_OP\_PROVIDE\_BUFFERS** which is more efficient, to be used with request types that support the **IOSQE\_BUFFER\_SELECT** flag.

  The *arg* argument must be filled in with the appropriate information. It looks as follows:

```
struct io_uring_buf_reg {
    __u64 ring_addr;
    __u32 ring_entries;
    __u16 bgid;
    __u16 flags;
    __u32 min_left;
    __u32 resv[5];
};
```

The *ring\_addr* field must contain the address to the memory allocated to fit this ring. The memory must be page aligned and hence allocated appropriately using eg [**posix\_memalign**(3)](/posix_memalign/3.md) or similar. The size of the ring is the product of *ring\_entries* and the size of *struct io\_uring\_buf*. *ring\_entries* is the desired size of the ring, and must be a power-of-2 in size. The maximum size allowed is 2^15 (32768). *bgid* is the buffer group ID associated with this ring. SQEs that select a buffer have a buffer group associated with them in their *buf\_group* field, and the associated CQEs will have **IORING\_CQE\_F\_BUFFER** set in their *flags* member, which will also contain the specific ID of the buffer selected. *min\_left* is the minimum value that should be left in an incrementally consumed buffer ring for the buffer to be considered valid. If not set, defaults to a single byte. Only valid with **IOU\_PBUF\_RING\_INC** set in *flags .* The rest of the fields are reserved and must be cleared to zero.

*nr\_args* must be set to 1.

Also see [**io\_uring\_register\_buf\_ring**(3)](/io_uring_register_buf_ring/3.md) for more details. Available since 5.19.

- **IORING\_UNREGISTER\_PBUF\_RING**

  Unregister a previously registered provided buffer ring. *arg* must be set to the address of a struct io\_uring\_buf\_reg, with just the *bgid* field set to the buffer group ID of the previously registered provided buffer group. *nr\_args* must be set to 1. Also see **IORING\_REGISTER\_PBUF\_RING**.

  Available since 5.19.

- **IORING\_REGISTER\_SYNC\_CANCEL**

  Performs a synchronous cancelation request, which works in a similar fashion to **IORING\_OP\_ASYNC\_CANCEL** except it completes inline. This can be useful for scenarios where cancelations should happen synchronously, rather than needing to issue an SQE and wait for completion of that specific CQE.

  *arg* must be set to a pointer to a struct io\_uring\_sync\_cancel\_reg structure, with the details filled in for what request(s) to target for cancelation. See [**io\_uring\_register\_sync\_cancel**(3)](/io_uring_register_sync_cancel/3.md) for details on that. The return values are the same, except they are passed back synchronously rather than through the CQE *res* field. *nr\_args* must be set to 1.

  Available since 6.0.

- **IORING\_REGISTER\_FILE\_ALLOC\_RANGE**

  sets the allowable range for fixed file index allocations within the kernel. When requests that can instantiate a new fixed file are used with **IORING\_FILE\_INDEX\_ALLOC**, the application is asking the kernel to allocate a new fixed file descriptor rather than pass in a specific value for one. By default, the kernel will pick any available fixed file descriptor within the range available. This effectively allows the application to set aside a range just for dynamic allocations, with the remainder being used for specific values.

  *nr\_args* must be set to 1 and *arg* must be set to a pointer to a struct io\_uring\_file\_index\_range:

```
struct io_uring_file_index_range {
    __u32 off;
    __u32 len;
    __u64 resv;
};
```

with *off* being set to the starting value for the range, and *len* being set to the number of descriptors. The reserved *resv* field must be cleared to zero.

The application must have registered a file table first.

Available since 6.0.

- **IORING\_REGISTER\_PBUF\_STATUS**

  Can be used to retrieve the current head of a ringbuffer provided earlier via **IORING\_REGISTER\_PBUF\_RING**. *arg* must point to a

```
struct io_uring_buf_status {
	__u32	buf_group;	/* input */
	__u32	head;		/* output */
	__u32	resv[8];
};
```

of which *arg-\>buf\_group* should contain the buffer group ID for the buffer ring in question, *nr\_args* should be set to 1 and *arg-\>resv* should be zeroed out. The current head of the ringbuffer will be returned in *arg-\>head*.

Available since 6.8.

- **IORING\_REGISTER\_NAPI**

  Registers a napi instance with the io\_uring instance of *fd*. *arg* should point to a

```
struct io_uring_napi {
	__u32	busy_poll_to;
	__u8	prefer_busy_poll;
	__u8	pad[3];
	__u64	resv;
};
```

in which *arg-\>busy\_poll\_to* should contain the busy poll timeout in micro seconds and *arg-\>prefer\_busy\_poll* should specify whether busy polling should be used rather than IRQs. *nr\_args* should be set to 1 and *arg-\>pad* and *arg-\>resv* should be zeroed out. On successful return the *io\_uring\_napi* struct pointed to by *arg* will contain the previously used settings.

Available since 6.9.

- **IORING\_UNREGISTER\_NAPI**

  Unregisters a napi instance previously registered via **IORING\_REGISTER\_NAPI** to the io\_uring instance of *fd*. *arg* should point to a *struct* *io\_uring\_napi*. On successful return the *io\_uring\_napi* struct pointed to by *arg* will contain the previously used settings.

  Available since 6.9.

- **IORING\_REGISTER\_CLOCK**

  Specifies which clock id io\_uring will use for timers while waiting for completion events with **IORING\_ENTER\_GETEVENTS**. It's only effective if the timeout argument in *struct io\_uring\_getevents\_arg* is passed, ignored otherwise. When used in conjunction with **IORING\_ENTER\_ABS\_TIMER**, interprets the timeout argument as absolute time of the specified clock.

  The default clock is **CLOCK\_MONOTONIC**.

  Available since 6.12 and supports **CLOCK\_MONOTONIC** and **CLOCK\_BOOTTIME**.

- **IORING\_REGISTER\_CLONE\_BUFFERS**

  Supports cloning buffers from a source ring to a destination ring, duplicating previously registered buffers from source to destination. *arg* must be set to a pointer to a *struct io\_uring\_clone\_buffers* and *nr\_args* must be set to **1 .** *struct io\_uring\_buf\_reg* looks as follows:

```
struct io_uring_clone_buffers {
    __u32 src_fd;
    __u32 flags;
    __u32 src_off;
    __u32 dst_off;
    __u32 nr;
    __u32 pad[3];
};
```

- where

  *src\_fd* indicates the fd of the source ring, *flags* are modifier flags for the operation, *src\_off* indicates the offset from where to start the cloning from the source ring, *dst\_off* indicates the offset from where to start the cloning into the destination ring, and *nr* indicates the number of buffers to clone at the given offsets. *pad* must be zero filled. Kernel 6.12 added support for full range cloning, where *src\_off*, *dst\_off*, and *nr* must all be set to 0, indicating cloning of the entire table in source to destination. Kernel 6.13 added support for specifying the offsets and how many buffers to clone. Additionally, it added support for cloning into a previously registered table in the destination as well, 6.12 would fail that operation with **-EBUSY** if attempted. To replace existing nodes, or clone into an existing table, **IORING\_REGISTER\_DST\_REPLACE** must be set in the *flags* member.

- **IORING\_REGISTER\_SEND\_MSG\_RING**

  Supports sending of the equivalent of a **IORING\_OP\_MSG\_RING** request, but without having a source ring available. Takes a pointer to a *struct*io\_uring\_sqe which must be prepared with [**io\_uring\_prep\_msg\_ring**(3)](/io_uring_prep_msg_ring/3.md) before being submitted. Only supports **IORING\_MSG\_DATA** type of requests. Available since kernel 6.13.

- **IORING\_REGISTER\_RESIZE\_RINGS**

  Supports resizing the SQ and CQ rings. Takes a pointer to a *struct*io\_uring\_params as the argument, where *sq\_entries* and *cq\_entries* may be set to the desired values. Only supports a limited set of flags set in the *struct*io\_uring\_params argument, notably **IORING\_SETUP\_CQSIZE** and **IORING\_SETUP\_CLAMP** to modify the CQ ring sizing. See [**io\_uring\_resize\_rings**(3)](/io_uring_resize_rings/3.md) for details. Note that while liburing takes care of the ring unmap and mapping for a resize operation, manual users of this register syscall must perform those operations, similarly to when a new ring is created. The *struct*io\_uring\_params structure will get the necessary offsets copied back upon successful completion of this system call, which can be used to memory map the ring just like how a new ring would've been mapped. Available since kernel 6.13.

- **IORING\_REGISTER\_MEM\_REGION**

  Supports registering multiple purposes memory regions, avoiding unnecessary copying in of *struct*io\_uring\_getevents\_arg for wait operations that specify a timeout or minimum timeout. Takes a pointer to a *struct*io\_uring\_mem\_region\_reg structure, which looks as follows:

```
struct io_uring_mem_region_reg {
    __u64 region_uptr;
    __u64 flags;
    __u64 __resv[2];
};
```

- where

  *region\_uptr* must be set to the region being registered as memory regions, *flags* specifies modifier flags (must currently be **IORING\_MEM\_REGION\_REG\_WAIT\_ARG ). The pad fields must all be cleared to** **0 .** Each memory regions looks as follows:

```
struct io_uring_region_desc {
    __u64 user_addr;
    __u64 size;
    __u32 flags;
    __u32 id;
    __u64 mmap_offset;
    __u64 __resv[4];
};
```

- where

  *user\_addr* points to userspace memory mappings, *size* is the size of userspace memory. Current supported userspace memory regions looks as follows:

```
struct io_uring_reg_wait {
    struct __kernel_timespec ts;
    __u32                    min_wait_usec;
    __u32                    flags;
    __u64                    sigmask;
    __u32                    sigmask_sz;
    __u32                    pad[3];
    __u64                    pad2[2];
};
```

- where

  *ts* holds the timeout information for this region *flags* holds information about the timeout region, *sigmask* is a pointer to a signal mask, if used, and *sigmask\_sz* is the size of that signal mask. The pad fields must all be cleared to **0 .** Currently the only valid flag is **IORING\_REG\_WAIT\_TS ,** which, if set, says that the values in *ts* are valid and should be used for a timeout operation. The *user\_addr* field of *struct*io\_uring\_region\_desc must be set to an address of *struct*io\_uring\_reg\_wait members, an up to a page size can be mapped. At the size of 64 bytes per region, that allows at least 64 individual regions on a 4k page size system. The offsets of these regions are used for an [**io\_uring\_enter**(2)](/io_uring_enter/2.md) system call, with the first one being 0, second one 1, and so forth. After registration of the wait regions, [**io\_uring\_enter**(2)](/io_uring_enter/2.md) may be used with the enter flag of **IORING\_ENTER\_EXT\_ARG\_REG and an** *argp* set to the wait region offset, rather than a pointer to a *struct*io\_uring\_getevent\_arg structure. If used with **IORING\_ENTER\_GETEVENTS ,** then the wait operation will use the information in the registered wait region rather than needing a io\_uring\_getevent\_arg structure copied for each operation. For high frequency waits, this can save considerable CPU cycles. Note: once a region has been registered, it cannot get unregistered. It lives for the life of the ring. Individual wait region offset may be modified before any [**io\_uring\_enter**(2)](/io_uring_enter/2.md) system call. Available since kernel 6.13.

- **IORING\_REGISTER\_ZCRX\_IFQ**

  Registers a zero-copy receive interface queue for network receive operations. Zero-copy receive allows the kernel to place incoming network data directly into application-provided memory without copying, reducing CPU overhead for high-bandwidth network workloads. *arg* must point to a *struct io\_uring\_zcrx\_ifq\_reg* structure, and *nr\_args* must be set to 1.

```
struct io_uring_zcrx_ifq_reg {
    __u32 if_idx;
    __u32 if_rxq;
    __u32 rq_entries;
    __u32 flags;
    __u64 area_ptr;
    __u64 region_ptr;
    struct io_uring_zcrx_offsets offsets;
    __u32 zcrx_id;
    __u32 __resv2;
    __u64 __resv[3];
};
```

where *if\_idx* is the network interface index, *if\_rxq* is the receive queue index, *rq\_entries* is the number of entries in the refill queue (will be rounded up to a power of two), *flags* contains modifier flags, *area\_ptr* points to a *struct io\_uring\_zcrx\_area\_reg* describing the memory area to use, *region\_ptr* points to a *struct io\_uring\_region\_desc* describing the memory region, and upon successful return *zcrx\_id* will contain the ID of the registered zero-copy receive context. The *offsets* field is filled in by the kernel and contains the ring offsets for the refill queue.

The io\_uring ring must have been created with **IORING\_SETUP\_DEFER\_TASKRUN** and either **IORING\_SETUP\_CQE32** or **IORING\_SETUP\_CQE\_MIXED** flags set. The caller must have the **CAP\_NET\_ADMIN** capability.

Available since kernel 6.15.

- **IORING\_REGISTER\_QUERY**

  Queries io\_uring capabilities and feature support. This operation does not require an io\_uring ring and can be called with *fd* set to -1. It provides information about supported opcodes, flags, and subsystem-specific capabilities. *arg* must point to a *struct io\_uring\_query\_hdr* and *nr\_args* must be 0.

```
struct io_uring_query_hdr {
    __u64 next_entry;
    __u64 query_data;
    __u32 query_op;
    __u32 size;
    __s32 result;
    __u32 __resv[3];
};
```

Multiple queries can be chained together via *next\_entry* which points to the next *struct io\_uring\_query\_hdr* (or 0 for the last entry). *query\_data* points to a data structure appropriate for the query type. *query\_op* specifies the query type and can be one of:

- •

  **IO\_URING\_QUERY\_OPCODES** - Returns information about supported opcodes and flags in a *struct io\_uring\_query\_opcode*

- •

  **IO\_URING\_QUERY\_ZCRX** - Returns information about zero-copy receive support in a *struct io\_uring\_query\_zcrx*

- •

  **IO\_URING\_QUERY\_SCQ** - Returns information about the SQ/CQ ring layout in a *struct io\_uring\_query\_scq*

*size* should be set to the size of the data structure pointed to by *query\_data*. Upon return, *result* will be 0 on success, or a negative error code.

Available since kernel 6.15.

- **IORING\_REGISTER\_ZCRX\_CTRL**

  Performs control operations on a previously registered zero-copy receive context. *arg* must point to a *struct zcrx\_ctrl* and *nr\_args* must be 0.

```
struct zcrx_ctrl {
    __u32 zcrx_id;
    __u32 op;
    __u64 __resv[2];
    union {
        struct zcrx_ctrl_export     zc_export;
        struct zcrx_ctrl_flush_rq   zc_flush;
    };
};
```

where *zcrx\_id* is the ID of the zero-copy receive context returned from **IORING\_REGISTER\_ZCRX\_IFQ**, and *op* specifies the control operation:

- •

  **ZCRX\_CTRL\_FLUSH\_RQ** - Flushes pending buffers from the refill queue

- •

  **ZCRX\_CTRL\_EXPORT** - Exports the zero-copy receive context for use by other rings

  Available since kernel 6.15.

## RETURN VALUE

On success, [**io\_uring\_register**(2)](/io_uring_register/2.md) returns either 0 or a positive value, depending on the *opcode* used.  On error, a negative error value is returned. The caller should not rely on the *errno* variable.

## ERRORS

- **EACCES**

  The *opcode* field is not allowed due to registered restrictions.

- **EBADF**

  One or more fds in the *fd* array are invalid.

- **EBADFD**

  **IORING\_REGISTER\_ENABLE\_RINGS** or **IORING\_REGISTER\_RESTRICTIONS** was specified, but the io\_uring ring is not disabled.

- **EBUSY**

  **IORING\_REGISTER\_BUFFERS** or **IORING\_REGISTER\_FILES** or **IORING\_REGISTER\_RESTRICTIONS** was specified, but there were already buffers, files, or restrictions registered.

- **EEXIST**

  The thread performing the registration is invalid.

- **EFAULT**

  buffer is outside of the process' accessible address space, or *iov\_len* is greater than 1GiB.

- **EINVAL**

  **IORING\_REGISTER\_BUFFERS** or **IORING\_REGISTER\_FILES** was specified, but *nr\_args* is 0.

- **EINVAL**

  **IORING\_REGISTER\_BUFFERS** was specified, but *nr\_args* exceeds **UIO\_MAXIOV**

- **EINVAL**

  **IORING\_UNREGISTER\_BUFFERS** or **IORING\_UNREGISTER\_FILES** was specified, and *nr\_args* is non-zero or *arg* is non-NULL.

- **EINVAL**

  **IORING\_REGISTER\_RESTRICTIONS** was specified, but *nr\_args* exceeds the maximum allowed number of restrictions or restriction *opcode* is invalid.

- **EMFILE**

  **IORING\_REGISTER\_FILES** was specified and *nr\_args* exceeds the maximum allowed number of files in a fixed file set.

- **EMFILE**

  **IORING\_REGISTER\_FILES** was specified and adding *nr\_args* file references would exceed the maximum allowed number of files the user is allowed to have according to the **RLIMIT\_NOFILE** resource limit and the caller does not have **CAP\_SYS\_RESOURCE** capability. Note that this is a per user limit, not per process.

- **ENOMEM**

  Insufficient kernel resources are available, or the caller had a non-zero **RLIMIT\_MEMLOCK** soft resource limit, but tried to lock more memory than the limit permitted.  This limit is not enforced if the process is privileged (**CAP\_IPC\_LOCK**).

- **ENXIO**

  **IORING\_UNREGISTER\_BUFFERS** or **IORING\_UNREGISTER\_FILES** was specified, but there were no buffers or files registered.

- **ENXIO**

  Attempt to register files or buffers on an io\_uring instance that is already undergoing file or buffer registration, or is being torn down.

- **EOPNOTSUPP**

  User buffers point to file-backed memory.

- **EFAULT**

  User buffers point to file-backed memory (newer kernels).

- **ENOENT**

  **IORING\_REGISTER\_PBUF\_STATUS** was specified, but *buf\_group* did not refer to a currently valid buffer group.

- **EINVAL**

  **IORING\_REGISTER\_PBUF\_STATUS** was specified, but the valid buffer group specified by *buf\_group* did not refer to a buffer group registered via **IORING\_REGISTER\_PBUF\_RING**.

- **EINVAL**

  **IORING\_REGISTER\_NAPI** was specified, but the ring associated with *fd* has not been created with **IORING\_SETUP\_IOPOLL**.
