@@ -48,10 +48,12 @@ public final class IoUring { |
48 | 48 | private static final boolean IORING_SETUP_NO_SQARRAY_SUPPORTED; |
49 | 49 | private static final boolean IORING_REGISTER_BUFFER_RING_SUPPORTED; |
50 | 50 | private static final boolean IORING_REGISTER_BUFFER_RING_INC_SUPPORTED; |
| 51 | + private static final boolean IORING_ENTER_NO_IOWAIT_SUPPORTED; |
51 | 52 | private static final boolean IORING_ACCEPT_MULTISHOT_ENABLED; |
52 | 53 | private static final boolean IORING_RECV_MULTISHOT_ENABLED; |
53 | 54 | private static final boolean IORING_RECVSEND_BUNDLE_ENABLED; |
54 | 55 | private static final boolean IORING_POLL_ADD_MULTISHOT_ENABLED; |
| 56 | + private static final boolean IORING_ENTER_NO_IOWAIT_ENABLED; |
55 | 57 | static final int NUM_ELEMENTS_IOVEC; |
56 | 58 | static final int DEFAULT_RING_SIZE; |
57 | 59 | static final int DEFAULT_CQ_SIZE; |
@@ -81,6 +83,7 @@ public final class IoUring { |
81 | 83 | boolean noSqarraySupported = false; |
82 | 84 | boolean registerBufferRingSupported = false; |
83 | 85 | boolean registerBufferRingIncSupported = false; |
| 86 | + boolean enterNoIoWaitSupported = false; |
84 | 87 | int numElementsIoVec = 10; |
85 | 88 | int pendingOpsInitialCapacity; |
86 | 89 |
|
@@ -108,8 +111,9 @@ public final class IoUring { |
108 | 111 | socketNonEmptySupported = Native.isCqeFSockNonEmptySupported(ioUringProbe); |
109 | 112 | spliceSupported = Native.isSpliceSupported(ioUringProbe); |
110 | 113 | recvsendBundleSupported = (ringBuffer.features() & Native.IORING_FEAT_RECVSEND_BUNDLE) != 0; |
| 114 | + enterNoIoWaitSupported = (ringBuffer.features() & Native.IORING_FEAT_NO_IOWAIT) != 0; |
111 | 115 | sendZcSupported = Native.isSendZcSupported(ioUringProbe); |
112 | | - sendmsgZcSupported = Native.isSendmsgZcSupported(ioUringProbe); |
| 116 | + sendmsgZcSupported = Native.isSendmsgZcSupported(ioUringProbe); |
113 | 117 | // IORING_FEAT_RECVSEND_BUNDLE was added in the same release. |
114 | 118 | acceptSupportNoWait = recvsendBundleSupported; |
115 | 119 |
|
@@ -162,6 +166,7 @@ public final class IoUring { |
162 | 166 | IORING_SETUP_NO_SQARRAY_SUPPORTED = noSqarraySupported; |
163 | 167 | IORING_REGISTER_BUFFER_RING_SUPPORTED = registerBufferRingSupported; |
164 | 168 | IORING_REGISTER_BUFFER_RING_INC_SUPPORTED = registerBufferRingIncSupported; |
| 169 | + IORING_ENTER_NO_IOWAIT_SUPPORTED = enterNoIoWaitSupported; |
165 | 170 |
|
166 | 171 | IORING_ACCEPT_MULTISHOT_ENABLED = IORING_ACCEPT_MULTISHOT_SUPPORTED && SystemPropertyUtil.getBoolean( |
167 | 172 | "io.netty.iouring.acceptMultiShotEnabled", true); |
@@ -173,10 +178,12 @@ public final class IoUring { |
173 | 178 | IORING_RECVSEND_BUNDLE_ENABLED = IORING_RECVSEND_BUNDLE_SUPPORTED && SystemPropertyUtil.getBoolean( |
174 | 179 | "io.netty.iouring.recvsendBundleEnabled", false); |
175 | 180 | IORING_POLL_ADD_MULTISHOT_ENABLED = IORING_POLL_ADD_MULTISHOT_SUPPORTED && SystemPropertyUtil.getBoolean( |
176 | | - "io.netty.iouring.pollAddMultishotEnabled", true); |
| 181 | + "io.netty.iouring.pollAddMultishotEnabled", true); |
| 182 | + IORING_ENTER_NO_IOWAIT_ENABLED = IORING_ENTER_NO_IOWAIT_SUPPORTED && SystemPropertyUtil.getBoolean( |
| 183 | + "io.netty.iouring.enterNoIoWaitEnabled", false); |
177 | 184 | NUM_ELEMENTS_IOVEC = numElementsIoVec; |
178 | 185 |
|
179 | | - DEFAULT_RING_SIZE = Math.max(16, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 128)); |
| 186 | + DEFAULT_RING_SIZE = Math.max(16, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 128)); |
180 | 187 | pendingOpsInitialCapacity = SystemPropertyUtil.getInt( |
181 | 188 | "io.netty.iouring.pendingOpsInitialCapacity", DEFAULT_RING_SIZE); |
182 | 189 | if (pendingOpsInitialCapacity <= 0) { |
@@ -313,6 +320,7 @@ static boolean isSetupDeferTaskrunSupported() { |
313 | 320 | static boolean isIoringSetupNoSqarraySupported() { |
314 | 321 | return IORING_SETUP_NO_SQARRAY_SUPPORTED; |
315 | 322 | } |
| 323 | + |
316 | 324 | /** |
317 | 325 | * Returns if it is supported to use a buffer ring. |
318 | 326 | * |
@@ -331,6 +339,21 @@ public static boolean isRegisterBufferRingIncSupported() { |
331 | 339 | return IORING_REGISTER_BUFFER_RING_INC_SUPPORTED; |
332 | 340 | } |
333 | 341 |
|
| 342 | + static boolean isIoringEnterNoIoWaitSupported() { |
| 343 | + return IORING_ENTER_NO_IOWAIT_SUPPORTED; |
| 344 | + } |
| 345 | + |
| 346 | + /** |
| 347 | + * Returns if {@code IORING_ENTER_NO_IOWAIT} is used or not. When enabled (and supported by the kernel), |
| 348 | + * idle io_uring_enter(2) waits are not accounted as iowait, which makes server-side CPU metrics more |
| 349 | + * accurate but also suppresses the cpufreq governor's iowait boost. |
| 350 | + * |
| 351 | + * @return {@code true} if enabled, {@code false} otherwise. |
| 352 | + */ |
| 353 | + public static boolean isIoringEnterNoIoWaitEnabled() { |
| 354 | + return IORING_ENTER_NO_IOWAIT_ENABLED; |
| 355 | + } |
| 356 | + |
334 | 357 | /** |
335 | 358 | * Returns if multi-shot ACCEPT is used or not. |
336 | 359 | * |
@@ -410,7 +433,8 @@ private static String supportedFeatures() { |
410 | 433 | + ", REGISTER_BUFFER_RING_SUPPORTED=" + IORING_REGISTER_BUFFER_RING_SUPPORTED |
411 | 434 | + ", REGISTER_BUFFER_RING_INC_SUPPORTED=" + IORING_REGISTER_BUFFER_RING_INC_SUPPORTED |
412 | 435 | + ", SEND_ZC_SUPPORTED=" + IORING_SEND_ZC_SUPPORTED |
413 | | - + ", SENDMSG_ZC_SUPPORTED=" + IORING_SENDMSG_ZC_SUPPORTED; |
| 436 | + + ", SENDMSG_ZC_SUPPORTED=" + IORING_SENDMSG_ZC_SUPPORTED |
| 437 | + + ", ENTER_NO_IOWAIT_SUPPORTED=" + IORING_ENTER_NO_IOWAIT_SUPPORTED; |
414 | 438 | } |
415 | 439 |
|
416 | 440 | /** |
|