[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y9ryjXdUg2ii8P71@biznet-home.integral.gnuweeb.org>
Date: Thu, 2 Feb 2023 06:15:25 +0700
From: Ammar Faizi <ammarfaizi2@...weeb.org>
To: Stefan Roesch <shr@...kernel.io>
Cc: Facebook Kernel Team <kernel-team@...com>,
Jens Axboe <axboe@...nel.dk>,
Olivier Langlois <olivier@...llion01.com>,
netdev Mailing List <netdev@...r.kernel.org>,
io-uring Mailing List <io-uring@...r.kernel.org>,
Jakub Kicinski <kuba@...nel.org>
Subject: Re: [PATCH v6 2/3] io_uring: add api to set / get napi configuration.
On Wed, Feb 01, 2023 at 02:22:53PM -0800, Stefan Roesch wrote:
> +static int io_unregister_napi(struct io_ring_ctx *ctx, void __user *arg)
> +{
> +#ifdef CONFIG_NET_RX_BUSY_POLL
> + const struct io_uring_napi curr = {
> + .busy_poll_to = ctx->napi_busy_poll_to,
> + };
> +
> + if (arg) {
> + if (copy_to_user(arg, &curr, sizeof(curr)))
> + return -EFAULT;
> + }
> +
> + WRITE_ONCE(ctx->napi_busy_poll_to, 0);
> + return 0;
> +#else
> + return -EINVAL;
> +#endif
> +}
Just to follow the common pattern when a feature is not enabled the
return value is -EOPNOTSUPP instead of -EINVAL. What do you think?
> + case IORING_UNREGISTER_NAPI:
> + ret = -EINVAL;
> + if (!arg)
> + break;
> + ret = io_unregister_napi(ctx, arg);
> + break;
This needs to be corrected. If the @arg var is NULL, you return -EINVAL.
So io_unregister_napi() will always have @arg != NULL. This @arg check
should go, allow the user to pass a NULL pointer to it.
Our previous agreement on this API is to allow the user to pass a NULL
pointer in case the user doesn't care about the old value.
Also, having a liburing test case that verifies this behavior would be
excellent.
--
Ammar Faizi
Powered by blists - more mailing lists