View Javadoc
1   /*
2    * Copyright 2024 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel.uring;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.channel.ChannelOption;
20  import io.netty.channel.unix.Buffer;
21  import io.netty.channel.unix.Limits;
22  import io.netty.util.internal.MathUtil;
23  import io.netty.util.internal.PlatformDependent;
24  import io.netty.util.internal.SystemPropertyUtil;
25  import io.netty.util.internal.logging.InternalLogger;
26  import io.netty.util.internal.logging.InternalLoggerFactory;
27  
28  import java.nio.ByteBuffer;
29  
30  public final class IoUring {
31  
32      private static final Throwable UNAVAILABILITY_CAUSE;
33      private static final boolean IORING_CQE_F_SOCK_NONEMPTY_SUPPORTED;
34      private static final boolean IORING_SPLICE_SUPPORTED;
35      private static final boolean IORING_SEND_ZC_SUPPORTED;
36      private static final boolean IORING_SENDMSG_ZC_SUPPORTED;
37      private static final boolean IORING_ACCEPT_NO_WAIT_SUPPORTED;
38      private static final boolean IORING_ACCEPT_MULTISHOT_SUPPORTED;
39      private static final boolean IORING_RECV_MULTISHOT_SUPPORTED;
40      private static final boolean IORING_RECVSEND_BUNDLE_SUPPORTED;
41      private static final boolean IORING_POLL_ADD_MULTISHOT_SUPPORTED;
42      private static final boolean IORING_REGISTER_IOWQ_MAX_WORKERS_SUPPORTED;
43      private static final boolean IORING_SETUP_SUBMIT_ALL_SUPPORTED;
44      private static final boolean IORING_SETUP_CQE_MIXED_SUPPORTED;
45      private static final boolean IORING_SETUP_CQ_SIZE_SUPPORTED;
46      private static final boolean IORING_SETUP_SINGLE_ISSUER_SUPPORTED;
47      private static final boolean IORING_SETUP_DEFER_TASKRUN_SUPPORTED;
48      private static final boolean IORING_SETUP_NO_SQARRAY_SUPPORTED;
49      private static final boolean IORING_REGISTER_BUFFER_RING_SUPPORTED;
50      private static final boolean IORING_REGISTER_BUFFER_RING_INC_SUPPORTED;
51      private static final boolean IORING_ENTER_NO_IOWAIT_SUPPORTED;
52      private static final boolean IORING_ACCEPT_MULTISHOT_ENABLED;
53      private static final boolean IORING_RECV_MULTISHOT_ENABLED;
54      private static final boolean IORING_RECVSEND_BUNDLE_ENABLED;
55      private static final boolean IORING_POLL_ADD_MULTISHOT_ENABLED;
56      private static final boolean IORING_ENTER_NO_IOWAIT_ENABLED;
57      static final int NUM_ELEMENTS_IOVEC;
58      static final int DEFAULT_RING_SIZE;
59      static final int DEFAULT_CQ_SIZE;
60      static final int DEFAULT_PENDING_OPS_INITIAL_CAPACITY;
61      static final int DISABLE_SETUP_CQ_SIZE = -1;
62  
63      private static final InternalLogger logger;
64  
65      static {
66          logger = InternalLoggerFactory.getInstance(IoUring.class);
67          Throwable cause = null;
68          boolean socketNonEmptySupported = false;
69          boolean spliceSupported = false;
70          boolean sendZcSupported = false;
71          boolean sendmsgZcSupported = false;
72          boolean acceptSupportNoWait = false;
73          boolean acceptMultishotSupported = false;
74          boolean recvsendBundleSupported = false;
75          boolean recvMultishotSupported = false;
76          boolean pollAddMultishotSupported = false;
77          boolean registerIowqWorkersSupported = false;
78          boolean submitAllSupported = false;
79          boolean cqeMixedSupported = false;
80          boolean setUpCqSizeSupported = false;
81          boolean singleIssuerSupported = false;
82          boolean deferTaskrunSupported = false;
83          boolean noSqarraySupported = false;
84          boolean registerBufferRingSupported = false;
85          boolean registerBufferRingIncSupported = false;
86          boolean enterNoIoWaitSupported = false;
87          int numElementsIoVec = 10;
88          int pendingOpsInitialCapacity;
89  
90          String kernelVersion = "[unknown]";
91          try {
92              if (SystemPropertyUtil.getBoolean("io.netty.transport.noNative", false)) {
93                  cause = new UnsupportedOperationException(
94                          "Native transport was explicit disabled with -Dio.netty.transport.noNative=true");
95              } else {
96                  kernelVersion = Native.kernelVersion();
97                  Native.checkKernelVersion(kernelVersion);
98                  if (PlatformDependent.javaVersion() >= 9) {
99                      RingBuffer ringBuffer = null;
100                     try {
101                         ringBuffer = Native.createRingBuffer(1, 0);
102                         if ((ringBuffer.features() & Native.IORING_FEAT_SUBMIT_STABLE) == 0) {
103                             // This should only happen on kernels < 5.4 which we don't support anyway.
104                             throw new UnsupportedOperationException("IORING_FEAT_SUBMIT_STABLE not supported!");
105                         }
106                         // IOV_MAX should be 1024 and an IOV is 16 bytes which means that by default we reserve around
107                         // 160kb.
108                         numElementsIoVec = SystemPropertyUtil.getInt(
109                                 "io.netty.iouring.numElementsIoVec", 10 * Limits.IOV_MAX);
110                         Native.IoUringProbe ioUringProbe = Native.ioUringProbe(ringBuffer.fd());
111                         Native.checkAllIOSupported(ioUringProbe);
112                         socketNonEmptySupported = Native.isCqeFSockNonEmptySupported(ioUringProbe);
113                         spliceSupported = Native.isSpliceSupported(ioUringProbe);
114                         recvsendBundleSupported = (ringBuffer.features() & Native.IORING_FEAT_RECVSEND_BUNDLE) != 0;
115                         enterNoIoWaitSupported = (ringBuffer.features() & Native.IORING_FEAT_NO_IOWAIT) != 0;
116                         sendZcSupported = Native.isSendZcSupported(ioUringProbe);
117                         sendmsgZcSupported =  Native.isSendmsgZcSupported(ioUringProbe);
118                         // IORING_FEAT_RECVSEND_BUNDLE was added in the same release.
119                         acceptSupportNoWait = recvsendBundleSupported;
120 
121                         acceptMultishotSupported = Native.isAcceptMultishotSupported(ioUringProbe);
122                         recvMultishotSupported = Native.isRecvMultishotSupported();
123                         pollAddMultishotSupported = Native.isPollAddMultiShotSupported(ioUringProbe);
124                         registerIowqWorkersSupported = Native.isRegisterIoWqWorkerSupported(ringBuffer.fd());
125                         submitAllSupported = Native.ioUringSetupSupportsFlags(Native.IORING_SETUP_SUBMIT_ALL);
126                         cqeMixedSupported = Native.ioUringSetupSupportsFlags(Native.IORING_SETUP_CQE_MIXED);
127                         setUpCqSizeSupported = Native.ioUringSetupSupportsFlags(Native.IORING_SETUP_CQSIZE);
128                         singleIssuerSupported = Native.ioUringSetupSupportsFlags(Native.IORING_SETUP_SINGLE_ISSUER);
129                         // IORING_SETUP_DEFER_TASKRUN requires to also set IORING_SETUP_SINGLE_ISSUER.
130                         // See https://manpages.debian.org/unstable/liburing-dev/io_uring_setup.2.en.html
131                         deferTaskrunSupported = Native.ioUringSetupSupportsFlags(
132                                 Native.IORING_SETUP_SINGLE_ISSUER | Native.IORING_SETUP_DEFER_TASKRUN);
133                         noSqarraySupported = Native.ioUringSetupSupportsFlags(Native.IORING_SETUP_NO_SQARRAY);
134                         registerBufferRingSupported = Native.isRegisterBufferRingSupported(ringBuffer.fd(), 0);
135                         registerBufferRingIncSupported = Native.isRegisterBufferRingSupported(ringBuffer.fd(),
136                                 Native.IOU_PBUF_RING_INC);
137                     } finally {
138                         if (ringBuffer != null) {
139                             try {
140                                 ringBuffer.close();
141                             } catch (Exception ignore) {
142                                 // ignore
143                             }
144                         }
145                     }
146                 } else {
147                     cause = new UnsupportedOperationException("Java 9+ is required");
148                 }
149             }
150         } catch (Throwable t) {
151             cause = t;
152         }
153         // Assign static finals first so printFeatures() (no-arg) can read them.
154         UNAVAILABILITY_CAUSE = cause;
155         IORING_CQE_F_SOCK_NONEMPTY_SUPPORTED = socketNonEmptySupported;
156         IORING_SPLICE_SUPPORTED = spliceSupported;
157         IORING_SEND_ZC_SUPPORTED = sendZcSupported;
158         IORING_SENDMSG_ZC_SUPPORTED = sendmsgZcSupported;
159         IORING_ACCEPT_NO_WAIT_SUPPORTED = acceptSupportNoWait;
160         IORING_ACCEPT_MULTISHOT_SUPPORTED = acceptMultishotSupported;
161         IORING_RECV_MULTISHOT_SUPPORTED = recvMultishotSupported;
162         IORING_RECVSEND_BUNDLE_SUPPORTED = recvsendBundleSupported;
163         IORING_POLL_ADD_MULTISHOT_SUPPORTED = pollAddMultishotSupported;
164         IORING_REGISTER_IOWQ_MAX_WORKERS_SUPPORTED = registerIowqWorkersSupported;
165         IORING_SETUP_SUBMIT_ALL_SUPPORTED = submitAllSupported;
166         IORING_SETUP_CQE_MIXED_SUPPORTED = cqeMixedSupported;
167         IORING_SETUP_CQ_SIZE_SUPPORTED = setUpCqSizeSupported;
168         IORING_SETUP_SINGLE_ISSUER_SUPPORTED = singleIssuerSupported;
169         IORING_SETUP_DEFER_TASKRUN_SUPPORTED = deferTaskrunSupported;
170         IORING_SETUP_NO_SQARRAY_SUPPORTED = noSqarraySupported;
171         IORING_REGISTER_BUFFER_RING_SUPPORTED = registerBufferRingSupported;
172         IORING_REGISTER_BUFFER_RING_INC_SUPPORTED = registerBufferRingIncSupported;
173         IORING_ENTER_NO_IOWAIT_SUPPORTED = enterNoIoWaitSupported;
174 
175         IORING_ACCEPT_MULTISHOT_ENABLED = IORING_ACCEPT_MULTISHOT_SUPPORTED && SystemPropertyUtil.getBoolean(
176                 "io.netty.iouring.acceptMultiShotEnabled", true);
177         IORING_RECV_MULTISHOT_ENABLED = IORING_RECV_MULTISHOT_SUPPORTED && SystemPropertyUtil.getBoolean(
178                 "io.netty.iouring.recvMultiShotEnabled", true);
179         // Explicit disable RECVSEND_BUNDLE as there is a know kernel bug that will be fixed in the future:
180         // See https://lore.kernel.org/io-uring/[email protected]/
181         //      T/#ma949ad361d376247a16db73e741cb1043e56e6a4
182         IORING_RECVSEND_BUNDLE_ENABLED = IORING_RECVSEND_BUNDLE_SUPPORTED && SystemPropertyUtil.getBoolean(
183                 "io.netty.iouring.recvsendBundleEnabled", false);
184         IORING_POLL_ADD_MULTISHOT_ENABLED = IORING_POLL_ADD_MULTISHOT_SUPPORTED && SystemPropertyUtil.getBoolean(
185                "io.netty.iouring.pollAddMultishotEnabled", true);
186         IORING_ENTER_NO_IOWAIT_ENABLED = IORING_ENTER_NO_IOWAIT_SUPPORTED && SystemPropertyUtil.getBoolean(
187                 "io.netty.iouring.enterNoIoWaitEnabled", false);
188         NUM_ELEMENTS_IOVEC = numElementsIoVec;
189 
190         DEFAULT_RING_SIZE =  Math.max(16, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 128));
191         pendingOpsInitialCapacity = SystemPropertyUtil.getInt(
192                 "io.netty.iouring.pendingOpsInitialCapacity", DEFAULT_RING_SIZE);
193         if (pendingOpsInitialCapacity <= 0) {
194             int configuredCapacity = pendingOpsInitialCapacity;
195             pendingOpsInitialCapacity = MathUtil.safeFindNextPositivePowerOfTwo(DEFAULT_RING_SIZE);
196             logger.warn("Invalid value {} for -Dio.netty.iouring.pendingOpsInitialCapacity; using {} instead.",
197                     configuredCapacity, pendingOpsInitialCapacity);
198         } else if (Integer.bitCount(pendingOpsInitialCapacity) != 1) {
199             int configuredCapacity = pendingOpsInitialCapacity;
200             pendingOpsInitialCapacity = MathUtil.safeFindNextPositivePowerOfTwo(pendingOpsInitialCapacity);
201             logger.warn("Rounding -Dio.netty.iouring.pendingOpsInitialCapacity from {} up to {}.",
202                     configuredCapacity, pendingOpsInitialCapacity);
203         }
204         DEFAULT_PENDING_OPS_INITIAL_CAPACITY = pendingOpsInitialCapacity;
205         if (IORING_SETUP_CQ_SIZE_SUPPORTED) {
206             DEFAULT_CQ_SIZE = Math.max(DEFAULT_RING_SIZE,
207                     SystemPropertyUtil.getInt("io.netty.iouring.cqSize", 4096));
208         } else {
209             DEFAULT_CQ_SIZE = DISABLE_SETUP_CQ_SIZE;
210         }
211         // Now that all static fields are assigned, emit the debug log using the shared printFeatures()
212         if (cause != null) {
213             if (logger.isTraceEnabled()) {
214                 logger.debug("IoUring support is not available using kernel {}", kernelVersion, cause);
215             } else if (logger.isDebugEnabled()) {
216                 logger.debug("IoUring support is not available using kernel {}: {}", kernelVersion, cause.getMessage());
217             }
218         } else {
219             if (logger.isDebugEnabled()) {
220                 logger.debug("IoUring support is available using kernel {}: {}", kernelVersion, supportedFeatures());
221             }
222         }
223     }
224 
225     public static boolean isAvailable() {
226         return UNAVAILABILITY_CAUSE == null;
227     }
228 
229     /**
230      * Returns {@code true} if the io_uring native transport is both {@linkplain #isAvailable() available} and supports
231      * {@linkplain ChannelOption#TCP_FASTOPEN_CONNECT client-side TCP FastOpen}.
232      *
233      * @return {@code true} if it's possible to use client-side TCP FastOpen via io_uring, otherwise {@code false}.
234      */
235     public static boolean isTcpFastOpenClientSideAvailable() {
236         return isAvailable() && Native.IS_SUPPORTING_TCP_FASTOPEN_CLIENT;
237     }
238 
239     /**
240      * Returns {@code true} if the io_uring native transport is both {@linkplain #isAvailable() available} and supports
241      * {@linkplain ChannelOption#TCP_FASTOPEN server-side TCP FastOpen}.
242      *
243      * @return {@code true} if it's possible to use server-side TCP FastOpen via io_uring, otherwise {@code false}.
244      */
245     public static boolean isTcpFastOpenServerSideAvailable() {
246         return isAvailable() && Native.IS_SUPPORTING_TCP_FASTOPEN_SERVER;
247     }
248 
249     static boolean isCqeFSockNonEmptySupported() {
250         return IORING_CQE_F_SOCK_NONEMPTY_SUPPORTED;
251     }
252 
253     /**
254      * Returns if SPLICE is supported or not.
255      *
256      * @return {@code true} if supported, {@code false} otherwise.
257      */
258     public static boolean isSpliceSupported() {
259         return IORING_SPLICE_SUPPORTED;
260     }
261 
262     /**
263      * Returns if {@code IORING_OP_SEND_ZC} is supported.
264      *
265      * @return {@code true} if {@code IORING_OP_SEND_ZC} is supported, {@code false} otherwise.
266      */
267     static boolean isSendZcSupported() {
268         return IORING_SEND_ZC_SUPPORTED;
269     }
270 
271     /**
272      * Returns if {@code IORING_OP_SENDMSG_ZC} is supported.
273      *
274      * @return {@code true} if {@code IORING_OP_SENDMSG_ZC} is supported, {@code false} otherwise.
275      */
276     static boolean isSendmsgZcSupported() {
277         return IORING_SENDMSG_ZC_SUPPORTED;
278     }
279 
280     static boolean isAcceptNoWaitSupported() {
281         return IORING_ACCEPT_NO_WAIT_SUPPORTED;
282     }
283 
284     static boolean isAcceptMultishotSupported() {
285         return IORING_ACCEPT_MULTISHOT_SUPPORTED;
286     }
287 
288     static boolean isRecvMultishotSupported() {
289         return IORING_RECV_MULTISHOT_SUPPORTED;
290     }
291 
292     static boolean isRecvsendBundleSupported() {
293         return IORING_RECVSEND_BUNDLE_SUPPORTED;
294     }
295 
296     static boolean isPollAddMultishotSupported() {
297         return IORING_POLL_ADD_MULTISHOT_SUPPORTED;
298     }
299 
300     static boolean isRegisterIowqMaxWorkersSupported() {
301         return IORING_REGISTER_IOWQ_MAX_WORKERS_SUPPORTED;
302     }
303 
304     static boolean isSetupCqeSizeSupported() {
305         return IORING_SETUP_CQ_SIZE_SUPPORTED;
306     }
307 
308     static boolean isSetupSubmitAllSupported() {
309         return IORING_SETUP_SUBMIT_ALL_SUPPORTED;
310     }
311 
312     static boolean isSetupCqeMixedSupported() {
313         return IORING_SETUP_CQE_MIXED_SUPPORTED;
314     }
315 
316     static boolean isSetupSingleIssuerSupported() {
317         return IORING_SETUP_SINGLE_ISSUER_SUPPORTED;
318     }
319 
320     static boolean isSetupDeferTaskrunSupported() {
321         return IORING_SETUP_DEFER_TASKRUN_SUPPORTED;
322     }
323 
324     static boolean isIoringSetupNoSqarraySupported() {
325         return IORING_SETUP_NO_SQARRAY_SUPPORTED;
326     }
327     /**
328      * Returns if it is supported to use a buffer ring.
329      *
330      * @return {@code true} if supported, {@code false} otherwise.
331      */
332     public static boolean isRegisterBufferRingSupported() {
333         return IORING_REGISTER_BUFFER_RING_SUPPORTED;
334     }
335 
336     /**
337      * Returns if it is supported to use an incremental buffer ring.
338      *
339      * @return {@code true} if supported, {@code false} otherwise.
340      */
341     public static boolean isRegisterBufferRingIncSupported() {
342         return IORING_REGISTER_BUFFER_RING_INC_SUPPORTED;
343     }
344 
345     static boolean isIoringEnterNoIoWaitSupported() {
346         return IORING_ENTER_NO_IOWAIT_SUPPORTED;
347     }
348 
349     /**
350      * Returns if {@code IORING_ENTER_NO_IOWAIT} is used or not. When enabled (and supported by the kernel),
351      * idle io_uring_enter(2) waits are not accounted as iowait, which makes server-side CPU metrics more
352      * accurate but also suppresses the cpufreq governor's iowait boost.
353      *
354      * @return {@code true} if enabled, {@code false} otherwise.
355      */
356     public static boolean isIoringEnterNoIoWaitEnabled() {
357         return IORING_ENTER_NO_IOWAIT_ENABLED;
358     }
359 
360     /**
361      * Returns if multi-shot ACCEPT is used or not.
362      *
363      * @return {@code true} if enabled, {@code false} otherwise.
364      */
365     public static boolean isAcceptMultishotEnabled() {
366         return IORING_ACCEPT_MULTISHOT_ENABLED;
367     }
368 
369     /**
370      * Returns if multi-shot RECV is used or not.
371      *
372      * @return {@code true} if enabled, {@code false} otherwise.
373      */
374     public static boolean isRecvMultishotEnabled() {
375         return IORING_RECV_MULTISHOT_ENABLED;
376     }
377 
378     /**
379      * Returns if RECVSEND bundles are used or not.
380      *
381      * @return {@code true} if enabled, {@code false} otherwise.
382      */
383     public static boolean isRecvsendBundleEnabled() {
384         return IORING_RECVSEND_BUNDLE_ENABLED;
385     }
386 
387     /**
388      * Returns if multi-shot POLL_ADD is used or not.
389      *
390      * @return {@code true} if enabled, {@code false} otherwise.
391      */
392     public static boolean isPollAddMultishotEnabled() {
393         return IORING_POLL_ADD_MULTISHOT_ENABLED;
394     }
395 
396     public static void ensureAvailability() {
397         if (UNAVAILABILITY_CAUSE != null) {
398             throw (Error) new UnsatisfiedLinkError(
399                     "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
400         }
401     }
402 
403     static long memoryAddress(ByteBuf buffer) {
404         if (buffer.hasMemoryAddress()) {
405             return buffer.memoryAddress();
406         }
407         // Use internalNioBuffer to reduce object creation.
408         // It is important to add the position as the returned ByteBuffer might be shared by multiple ByteBuf
409         // instances and so has an address that starts before the start of the ByteBuf itself.
410         ByteBuffer byteBuffer = buffer.internalNioBuffer(0, buffer.capacity());
411         return Buffer.memoryAddress(byteBuffer) + byteBuffer.position();
412     }
413 
414     public static Throwable unavailabilityCause() {
415         return UNAVAILABILITY_CAUSE;
416     }
417 
418     private static String supportedFeatures() {
419         if (!isAvailable()) {
420             return "";
421         }
422         return "CQE_F_SOCK_NONEMPTY_SUPPORTED=" + IORING_CQE_F_SOCK_NONEMPTY_SUPPORTED
423                 + ", SPLICE_SUPPORTED=" + IORING_SPLICE_SUPPORTED
424                 + ", ACCEPT_NO_WAIT_SUPPORTED=" + IORING_ACCEPT_NO_WAIT_SUPPORTED
425                 + ", ACCEPT_MULTISHOT_SUPPORTED=" + IORING_ACCEPT_MULTISHOT_SUPPORTED
426                 + ", POLL_ADD_MULTISHOT_SUPPORTED=" + IORING_POLL_ADD_MULTISHOT_SUPPORTED
427                 + ", RECV_MULTISHOT_SUPPORTED=" + IORING_RECV_MULTISHOT_SUPPORTED
428                 + ", IORING_RECVSEND_BUNDLE_SUPPORTED=" + IORING_RECVSEND_BUNDLE_SUPPORTED
429                 + ", REGISTER_IOWQ_MAX_WORKERS_SUPPORTED=" + IORING_REGISTER_IOWQ_MAX_WORKERS_SUPPORTED
430                 + ", SETUP_SUBMIT_ALL_SUPPORTED=" + IORING_SETUP_SUBMIT_ALL_SUPPORTED
431                 + ", SETUP_CQE_MIXED_SUPPORTED=" + IORING_SETUP_CQE_MIXED_SUPPORTED
432                 + ", SETUP_CQ_SIZE_SUPPORTED=" + IORING_SETUP_CQ_SIZE_SUPPORTED
433                 + ", SETUP_SINGLE_ISSUER_SUPPORTED=" + IORING_SETUP_SINGLE_ISSUER_SUPPORTED
434                 + ", SETUP_DEFER_TASKRUN_SUPPORTED=" + IORING_SETUP_DEFER_TASKRUN_SUPPORTED
435                 + ", SETUP_NO_SQARRAY_SUPPORTED=" + IORING_SETUP_NO_SQARRAY_SUPPORTED
436                 + ", REGISTER_BUFFER_RING_SUPPORTED=" + IORING_REGISTER_BUFFER_RING_SUPPORTED
437                 + ", REGISTER_BUFFER_RING_INC_SUPPORTED=" + IORING_REGISTER_BUFFER_RING_INC_SUPPORTED
438                 + ", SEND_ZC_SUPPORTED=" + IORING_SEND_ZC_SUPPORTED
439                 + ", SENDMSG_ZC_SUPPORTED=" + IORING_SENDMSG_ZC_SUPPORTED
440                 + ", ENTER_NO_IOWAIT_SUPPORTED=" + IORING_ENTER_NO_IOWAIT_SUPPORTED;
441     }
442 
443     /**
444      * Returns a string representation of the io_uring support and feature set. This mirrors the
445      * debug logging output that reports each individual feature's availability.
446      */
447     public static String featureString() {
448         if (!isAvailable()) {
449             Throwable t = unavailabilityCause();
450             return "IoUring unavailable: " + (t == null ? "unknown cause" : t.toString());
451         }
452         return "IoUring features: " + supportedFeatures();
453     }
454 
455     @Override
456     public String toString() {
457         return featureString();
458     }
459 
460     private IoUring() {
461     }
462 }