On 1/17/20 10:15 AM, Jeff Moyer wrote: > Jens Axboe <axboe@xxxxxxxxx> writes: > >> The application currently has no way of knowing if a given opcode is >> supported or not without having to try and issue one and see if we get >> -EINVAL or not. And even this approach is fraught with peril, as maybe >> we're getting -EINVAL due to some fields being missing, or maybe it's >> just not that easy to issue that particular command without doing some >> other leg work in terms of setup first. >> >> This adds IORING_REGISTER_PROBE, which fills in a structure with info >> on what it supported or not. This will work even with sparse opcode >> fields, which may happen in the future or even today if someone >> backports specific features to older kernels. > > This looks pretty good to me. You can call it with 0 args to get the > total number of ops, then allocate an array with that number and > re-issue the syscall. I also like that you've allowed for backporting > subsets of functionality. Right, this is similar to how most hardware commands work when you don't know what the max size would be. Since this is pretty small, I would expect applications to just use 256 as the value and get all of them. But if they want to probe and use that method, that'll work just fine. > I have one question below: > >> @@ -6632,6 +6674,12 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, >> break; >> ret = io_eventfd_unregister(ctx); >> break; >> + case IORING_REGISTER_PROBE: >> + ret = -EINVAL; >> + if (!arg || nr_args > 256) >> + break; >> + ret = io_probe(ctx, arg, nr_args); >> + break; > > Why 256? If it's just arbitrary, please add a comment. We can't have more than 256 opcodes, as it's a byte for the opcode. > Otherwise looks good! > > Reviewed-by: Jeff Moyer <jmoyer@xxxxxxxxxx> Thanks! -- Jens Axboe