Re: [PATCH v2 3/3] io_uring/napi: add static napi tracking strategy

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

 



On 9/16/24 1:20 PM, Olivier Langlois wrote:
> add the static napi tracking strategy that allows the user to manually
> manage the napi ids list to busy poll and offload the ring from
> dynamically update the list.

I like this, I suspect for many cases this is all you will need rather
than try and dynamically track multiple instances.

Away for the next week or so, so won't have time to do a proper review
until I'm back. Timing wise this doesn't matter too much as the 6.12
merge window is currently open, hence we cannot target this to anything
sooner than 6.13. So we have time to get this reviewed and queued up.

A few minor comments below.

> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
> index adc2524fd8e3..10d9030c4242 100644
> --- a/include/uapi/linux/io_uring.h
> +++ b/include/uapi/linux/io_uring.h
> @@ -728,12 +728,40 @@ struct io_uring_buf_status {
>  	__u32	resv[8];
>  };
>  
> +enum io_uring_napi_op {
> +	/* register/ungister backward compatible opcode */
> +	IO_URING_NAPI_REGISTER_OP = 0,
> +
> +	/* opcodes to update napi_list when static tracking is used */
> +	IO_URING_NAPI_STATIC_ADD_ID = 1,
> +	IO_URING_NAPI_STATIC_DEL_ID = 2
> +};
> +
> +enum io_uring_napi_tracking_strategy {
> +	/* value must be 0 for backward compatibility */
> +	IO_URING_NAPI_TRACKING_DYNAMIC = 0,
> +	IO_URING_NAPI_TRACKING_STATIC = 1,
> +	IO_URING_NAPI_TRACKING_INACTIVE = 255
> +};

I think this is a fine way to do it, retaining compatability with what
we have now on the registration side.

>  /* argument for IORING_(UN)REGISTER_NAPI */
>  struct io_uring_napi {
>  	__u32	busy_poll_to;
>  	__u8	prefer_busy_poll;
> -	__u8	pad[3];
> -	__u64	resv;
> +
> +	/* a io_uring_napi_op value */
> +	__u8	opcode;
> +	__u8	pad[2];
> +
> +	/*
> +	 * for IO_URING_NAPI_REGISTER_OP, it is a
> +	 * io_uring_napi_tracking_strategy value.
> +	 *
> +	 * for IO_URING_NAPI_STATIC_ADD_ID/IO_URING_NAPI_STATIC_DEL_ID
> +	 * it is the napi id to add/del from napi_list.
> +	 */
> +	__u32	op_param;
> +	__u32	resv;
>  };

Looks good too.

> +static void common_tracking_show_fdinfo(struct io_ring_ctx *ctx,
> +					struct seq_file *m,
> +					const char *tracking_strategy)
> +{
> +	seq_puts(m, "NAPI:\tenabled\n");
> +	seq_printf(m, "napi tracking:\t%s\n", tracking_strategy);
> +	seq_printf(m, "napi_busy_poll_dt:\t%llu\n", ctx->napi_busy_poll_dt);
> +	if (ctx->napi_prefer_busy_poll)
> +		seq_puts(m, "napi_prefer_busy_poll:\ttrue\n");
> +	else
> +		seq_puts(m, "napi_prefer_busy_poll:\tfalse\n");
> +}
> +
> +static void napi_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
> +{
> +	switch (READ_ONCE(ctx->napi_track_mode)) {
> +	case IO_URING_NAPI_TRACKING_INACTIVE:
> +		seq_puts(m, "NAPI:\tdisabled\n");
> +		break;
> +	case IO_URING_NAPI_TRACKING_DYNAMIC:
> +		common_tracking_show_fdinfo(ctx, m, "dynamic");
> +		break;
> +	case IO_URING_NAPI_TRACKING_STATIC:
> +		common_tracking_show_fdinfo(ctx, m, "static");
> +		break;
> +	}
> +}

Maybe add an "unknown" default entry here, just in case it ever changes
and someone forgets to update the fdinfo code.

> +static inline bool __io_napi_do_busy_loop(struct io_ring_ctx *ctx,
> +					  void *loop_end_arg)
> +{
> +	if (READ_ONCE(ctx->napi_track_mode) == IO_URING_NAPI_TRACKING_STATIC)
> +		return static_tracking_do_busy_loop(ctx, loop_end_arg);
> +	else
> +		return dynamic_tracking_do_busy_loop(ctx, loop_end_arg);
> +}
> +

Minor style nit:

	if (READ_ONCE(ctx->napi_track_mode) == IO_URING_NAPI_TRACKING_STATIC)
		return static_tracking_do_busy_loop(ctx, loop_end_arg);
	return dynamic_tracking_do_busy_loop(ctx, loop_end_arg);

would do.

-- 
Jens Axboe




[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