Skip to content

IoUring: Pass IORING_ENTER_NO_IOWAIT to report accurate CPU usage (#16739) - #16924

Merged
normanmaurer merged 1 commit into
netty:5.0from
chrisvest:5.0-iouring-iowait
Jun 9, 2026
Merged

normanmaurer merged 1 commit into
netty:5.0from
chrisvest:5.0-iouring-iowait

Conversation

@chrisvest

@chrisvest chrisvest commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

Motivation

When a Netty server uses the io_uring transport, the event loop threads that are idly waiting on CQEs are accounted as being in iowait by the kernel. On a server doing no real work, this makes monitoring tools (iostat, top, %iowait metrics) report close to 100% iowait, which:

  • Makes it impossible to tell real CPU pressure from an idle io_uring wait on the server.
  • Triggers the CPU frequency governor's iowait boost unnecessarily, which wastes power.

This was reported in #16655, where a user with 3 idle connected clients sees:

%user %nice %system %iowait %steal %idle
0.00  0.00  0.51    98.97   0.51   0.00

Modifications

Linux 6.15 added IORING_ENTER_NO_IOWAIT, advertised via the IORING_FEAT_NO_IOWAIT feature bit, which opts out of this accounting (and of the iowait CPU-freq boost) while waiting on CQEs.

  • Expose IORING_ENTER_NO_IOWAIT (1 << 7) and IORING_FEAT_NO_IOWAIT (1 << 17) as constants in Native, following the same hard-coded pattern already used for IORING_ENTER_REGISTERED_RING / IORING_FEAT_RECVSEND_BUNDLE.
  • In IoUring static init, check ringBuffer.features() & IORING_FEAT_NO_IOWAIT (same mechanism used for
    IORING_FEAT_RECVSEND_BUNDLE right above) to detect support.
  • In SubmissionQueue.tryRegisterRingFd(), OR IORING_ENTER_NO_IOWAIT into enterFlags when supported, so every io_uring_enter(2) call carries it.
  • Report the new capability in IoUring.featureString() as ENTER_NO_IOWAIT_SUPPORTED=....

On kernels < 6.15 the feature bit is absent, the flag is not set, and behavior is unchanged.

Result

  • On kernel ≥ 6.15, io_uring event loop threads waiting on completions are no longer counted as iowait. Server CPU/iowait monitoring now reflects reality.
  • No behavior change on older kernels.

Verification

  • Built on Linux 7.0.3 (Arch) with OpenJDK 21 via ./mvnw --projects transport-native-io_uring --also-make -DskipTests install — BUILD SUCCESS.
  • IoUringSocketEchoTest — 7/7 pass.
  • IoUring.featureString() prints ENTER_NO_IOWAIT_SUPPORTED=true on the 7.x test kernel, confirming the feature bit is detected.

References

Fixes #16655

(cherry picked from commit 3fb6987)

…tty#16739)

### Motivation

When a Netty server uses the io_uring transport, the event loop threads
that are idly waiting on CQEs are accounted as being in `iowait` by the
kernel. On a server doing no real work, this makes monitoring tools
(`iostat`, `top`, `%iowait` metrics) report close to 100% iowait, which:

- Makes it impossible to tell real CPU pressure from an idle io_uring
wait on the server.
- Triggers the CPU frequency governor's iowait boost unnecessarily,
which wastes power.

This was reported in netty#16655, where a user with 3 idle connected clients
sees:

```
%user %nice %system %iowait %steal %idle
0.00  0.00  0.51    98.97   0.51   0.00
```

### Modifications

Linux 6.15 added `IORING_ENTER_NO_IOWAIT`, advertised via the
`IORING_FEAT_NO_IOWAIT` feature bit, which opts out of this accounting
(and of the iowait CPU-freq boost) while waiting on CQEs.

- Expose `IORING_ENTER_NO_IOWAIT` (`1 << 7`) and `IORING_FEAT_NO_IOWAIT`
(`1 << 17`) as constants in `Native`, following the same hard-coded
pattern already used for `IORING_ENTER_REGISTERED_RING` /
`IORING_FEAT_RECVSEND_BUNDLE`.
- In `IoUring` static init, check `ringBuffer.features() &
IORING_FEAT_NO_IOWAIT` (same mechanism used for
`IORING_FEAT_RECVSEND_BUNDLE` right above) to detect support.
- In `SubmissionQueue.tryRegisterRingFd()`, OR `IORING_ENTER_NO_IOWAIT`
into `enterFlags` when supported, so every `io_uring_enter(2)` call
carries it.
- Report the new capability in `IoUring.featureString()` as
`ENTER_NO_IOWAIT_SUPPORTED=...`.

On kernels < 6.15 the feature bit is absent, the flag is not set, and
behavior is unchanged.

### Result

- On kernel ≥ 6.15, io_uring event loop threads waiting on completions
are no longer counted as iowait. Server CPU/iowait monitoring now
reflects reality.
- No behavior change on older kernels.

### Verification

- Built on Linux 7.0.3 (Arch) with OpenJDK 21 via `./mvnw --projects
transport-native-io_uring --also-make -DskipTests install` — BUILD
SUCCESS.
- `IoUringSocketEchoTest` — 7/7 pass.
- `IoUring.featureString()` prints `ENTER_NO_IOWAIT_SUPPORTED=true` on
the 7.x test kernel, confirming the feature bit is detected.

### References

- Kernel commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=07754bfd9aee59063f8549f6e4d455eae636ecc7
- `io_uring_enter(2)`:
https://man7.org/linux/man-pages/man2/io_uring_enter.2.html
- axboe/liburing#943

Fixes netty#16655

(cherry picked from commit 3fb6987)
@chrisvest chrisvest added this to the 5.0.0.Final milestone Jun 9, 2026
@chrisvest
chrisvest enabled auto-merge (squash) June 9, 2026 00:29
@normanmaurer
normanmaurer disabled auto-merge June 9, 2026 11:58
@normanmaurer
normanmaurer merged commit a98360a into netty:5.0 Jun 9, 2026
11 of 13 checks passed
@chrisvest
chrisvest deleted the 5.0-iouring-iowait branch June 9, 2026 16:52
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants