Re: [PATCH v6 2/3] io_uring: add api to set / get napi configuration.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux