Repository navigation
IoUring: Pass IORING_ENTER_NO_IOWAIT to report accurate CPU usage (#16739) - #16924
Merged
Merged
Conversation
…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
enabled auto-merge (squash)
June 9, 2026 00:29
normanmaurer
disabled auto-merge
June 9, 2026 11:58
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
iowaitby the kernel. On a server doing no real work, this makes monitoring tools (iostat,top,%iowaitmetrics) report close to 100% iowait, which:This was reported in #16655, where a user with 3 idle connected clients sees:
Modifications
Linux 6.15 added
IORING_ENTER_NO_IOWAIT, advertised via theIORING_FEAT_NO_IOWAITfeature bit, which opts out of this accounting (and of the iowait CPU-freq boost) while waiting on CQEs.IORING_ENTER_NO_IOWAIT(1 << 7) andIORING_FEAT_NO_IOWAIT(1 << 17) as constants inNative, following the same hard-coded pattern already used forIORING_ENTER_REGISTERED_RING/IORING_FEAT_RECVSEND_BUNDLE.IoUringstatic init, checkringBuffer.features() & IORING_FEAT_NO_IOWAIT(same mechanism used forIORING_FEAT_RECVSEND_BUNDLEright above) to detect support.SubmissionQueue.tryRegisterRingFd(), ORIORING_ENTER_NO_IOWAITintoenterFlagswhen supported, so everyio_uring_enter(2)call carries it.IoUring.featureString()asENTER_NO_IOWAIT_SUPPORTED=....On kernels < 6.15 the feature bit is absent, the flag is not set, and behavior is unchanged.
Result
Verification
./mvnw --projects transport-native-io_uring --also-make -DskipTests install— BUILD SUCCESS.IoUringSocketEchoTest— 7/7 pass.IoUring.featureString()printsENTER_NO_IOWAIT_SUPPORTED=trueon the 7.x test kernel, confirming the feature bit is detected.References
io_uring_enter(2): https://man7.org/linux/man-pages/man2/io_uring_enter.2.htmlFixes #16655
(cherry picked from commit 3fb6987)