io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Wei <dw@davidwei.uk>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Cc: Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [RFC PATCH v1] io_uring: only account cqring wait time as iowait if enabled for a ring
Date: Fri, 23 Feb 2024 09:17:52 -0800	[thread overview]
Message-ID: <7f179dd2-cba3-4383-ae41-848cd7e4eb3b@davidwei.uk> (raw)
In-Reply-To: <71ce7853-a1b9-4475-ab2a-0d751d156e1b@kernel.dk>

On 2024-02-23 06:31, Jens Axboe wrote:
> On 2/22/24 10:40 PM, David Wei wrote:
>> diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
>> index bd7071aeec5d..57318fc01379 100644
>> --- a/include/linux/io_uring_types.h
>> +++ b/include/linux/io_uring_types.h
>> @@ -425,6 +425,9 @@ struct io_ring_ctx {
>>  	DECLARE_HASHTABLE(napi_ht, 4);
>>  #endif
>>  
>> +	/* iowait accounting */
>> +	bool				iowait_enabled;
>> +
> 
> Since this is just a single bit, you should put it in the top section
> where we have other single bits for hot / read-mostly data. This avoids
> needing something many cache lines away for the hotter wait path, and it
> avoids growing the struct as there's still plenty of space there for
> this.

Got it, moved it to the cacheline aligned hot/read-only struct.
$current_year is when I learnt about C bitfields.

> 
>> diff --git a/io_uring/register.c b/io_uring/register.c
>> index 99c37775f974..7cbc08544c4c 100644
>> --- a/io_uring/register.c
>> +++ b/io_uring/register.c
>> @@ -387,6 +387,12 @@ static __cold int io_register_iowq_max_workers(struct io_ring_ctx *ctx,
>>  	return ret;
>>  }
>>  
>> +static int io_register_iowait(struct io_ring_ctx *ctx)
>> +{
>> +	ctx->iowait_enabled = true;
>> +	return 0;
>> +}
>> +
>>  static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
>>  			       void __user *arg, unsigned nr_args)
>>  	__releases(ctx->uring_lock)
>> @@ -563,6 +569,12 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
>>  			break;
>>  		ret = io_unregister_napi(ctx, arg);
>>  		break;
>> +	case IORING_REGISTER_IOWAIT:
>> +		ret = -EINVAL;
>> +		if (arg || nr_args)
>> +			break;
>> +		ret = io_register_iowait(ctx);
>> +		break;
> 
> 
> This only allows you to set it, not clear it. I think we want to make it
> pass in the value, and pass back the previous. Something ala:
> 
> static int io_register_iowait(struct io_ring_ctx *ctx, int val)
> {
> 	int was_enabled = ctx->iowait_enabled;
> 
> 	if (val)
> 		ctx->iowait_enabled = 1;
> 	else
> 		ctx->iowait_enabled = 0;
> 	return was_enabled;
> }
> 
> and then:
> 
> 	case IORING_REGISTER_IOWAIT:
> 		ret = -EINVAL;
> 		if (arg)
> 			break;
> 		ret = io_register_iowait(ctx, nr_args);
> 		break;
> 

When I first thought about this I wondered how to pass a value like int
val through arg which is a void*. That's a clever use of nr_args.

> I'd also add a:
> 
> Fixes: 8a796565cec3 ("io_uring: Use io_schedule* in cqring wait")
> 
> and mark it for stable, so we at least attempt to make it something that
> can be depended on.

Sorry, what does "mark it for stable" mean?

> 

      reply	other threads:[~2024-02-23 17:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23  5:40 [RFC PATCH v1] io_uring: only account cqring wait time as iowait if enabled for a ring David Wei
2024-02-23 14:31 ` Jens Axboe
2024-02-23 17:17   ` David Wei [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f179dd2-cba3-4383-ae41-848cd7e4eb3b@davidwei.uk \
    --to=dw@davidwei.uk \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).