liburing icon indicating copy to clipboard operation
liburing copied to clipboard

Detect supported flags?

Open nigoroll opened this issue 2 years ago • 3 comments

Similar question to #371 from 2021: Is there a better way now to detect supported flags to io_uring_queue_init_params() than to just try them? In my specific case, I get EINVAL for params.flags |= IORING_SETUP_COOP_TASKRUN with 8bbcf56cde6ca248e6f3508454b3bcef82596a7f on 5.15.0-76-generic #83~20.04.1-Ubuntu.

Edit: This is what I am using now, but it feels and looks quite dumb: https://gitlab.com/uplex/varnish/slash/-/commit/66a07c7ac1e744026789079984ee7ccab3636d2c

nigoroll avatar Jul 24 '23 16:07 nigoroll

There's unfortunately no good way to do this. We could return it via probe, so you setup a basic ring and do a probe and it'd return you the supported flags. Downside would be that on kernels that don't report it, you'd just get zeroes and would need to fall back to your existing code again.

Maybe better to add a REGISTER opcode for this, returning supported flags? You'd still need the backup code, but at least you'd know if the kernel didn't support it as the REGISTER opcode would fail.

axboe avatar Jul 25 '23 22:07 axboe

The REGISTER idea sounds good to me. Would you be interested in a contribution?

nigoroll avatar Jul 31 '23 08:07 nigoroll

In Samba I'll use something like this to detect features: https://git.samba.org/?p=metze/samba/wip.git;a=blob;f=lib/util/samba_io_uring.c;h=59e9ea0bdc7f78e065bb12c2a1cdfb4b58341f33;hb=refs/heads/master-io-uring-base#l223

And in order to detect per opcode features in the kernel I prepared this: https://git.samba.org/?p=metze/linux/wip.git;a=commitdiff;h=4dddc60699d745a4c3ae13af2523849b7c9ee621

metze-samba avatar Jul 31 '23 09:07 metze-samba