public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@redhat.com
Subject: Re: [PATCH 2/2] sched/core: split iowait state into two states
Date: Thu, 29 Feb 2024 10:45:40 -0700	[thread overview]
Message-ID: <c842c819-7035-45b1-8098-55a2d24a7d47@kernel.dk> (raw)
In-Reply-To: <87zfvj6uub.ffs@tglx>

On 2/29/24 10:31 AM, Thomas Gleixner wrote:
> On Wed, Feb 28 2024 at 12:16, Jens Axboe wrote:
>> iowait is a bogus metric, but it's helpful in the sense that it allows
>> short waits to not enter sleep states that have a higher exit latency
>> than we would've picked for iowait'ing tasks. However, it's harmless in
>> that lots of applications and monitoring assumes that iowait is busy
>> time, or otherwise use it as a health metric. Particularly for async
>> IO it's entirely nonsensical.
>>
>> Split the iowait part into two parts - one that tracks whether we need
>> boosting for short waits, and one that says we need to account the
>> task
> 
> We :)

I appreciate the commit message police :-)

I'll rewrite it.

>> +/*
>> + * Returns a token which is comprised of the two bits of iowait wait state -
>> + * one is whether we're making ourselves as in iowait for cpufreq reasons,
>> + * and the other is if the task should be accounted as such.
>> + */
>>  int io_schedule_prepare(void)
>>  {
>> -	int old_iowait = current->in_iowait;
>> +	int old_wait_flags = 0;
>> +
>> +	if (current->in_iowait)
>> +		old_wait_flags |= TASK_IOWAIT;
>> +	if (current->in_iowait_acct)
>> +		old_wait_flags |= TASK_IOWAIT_ACCT;
>>  
>>  	current->in_iowait = 1;
>> +	current->in_iowait_acct = 1;
>>  	blk_flush_plug(current->plug, true);
>> -	return old_iowait;
>> +	return old_wait_flags;
>>  }
>>  
>> -void io_schedule_finish(int token)
>> +void io_schedule_finish(int old_wait_flags)
>>  {
>> -	current->in_iowait = token;
>> +	if (!(old_wait_flags & TASK_IOWAIT))
>> +		current->in_iowait = 0;
>> +	if (!(old_wait_flags & TASK_IOWAIT_ACCT))
>> +		current->in_iowait_acct = 0;
> 
> Why? TASK_IOWAIT_ACCT requires TASK_IOWAIT, right? So if TASK_IOWAIT was
> not set then TASK_IOWAIT_ACCT must have been clear too, no?

It does, IOWAIT_ACCT always nests inside IOWAIT. I guess it would be
more explanatory as:

	/*
	 * If TASK_IOWAIT isn't set, then TASK_IOWAIT_ACCT cannot have
	 * been set either as it nests inside TASK_IOWAIT.
	 */
	if (!(old_wait_flags & TASK_IOWAIT))
		current->in_iowait = 0;
	else if (!(old_wait_flags & TASK_IOWAIT_ACCT))
		current->in_iowait_acct = 0;

?

-- 
Jens Axboe


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

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 19:16 [PATCHSET v3 0/2] Split iowait into two states Jens Axboe
2024-02-28 19:16 ` [PATCH 1/2] sched/core: switch struct rq->nr_iowait to a normal int Jens Axboe
2024-02-29 16:53   ` Thomas Gleixner
2024-02-29 17:19     ` Jens Axboe
2024-02-29 17:42       ` Thomas Gleixner
2024-02-29 17:49         ` Jens Axboe
2024-02-29 19:52           ` Thomas Gleixner
2024-02-29 22:30             ` Jens Axboe
2024-03-01  0:02               ` Thomas Gleixner
2024-02-28 19:16 ` [PATCH 2/2] sched/core: split iowait state into two states Jens Axboe
2024-02-29 17:31   ` Thomas Gleixner
2024-02-29 17:45     ` Jens Axboe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-02-27 21:06 [PATCHSET v2 0/2] Split iowait " Jens Axboe
2024-02-27 21:06 ` [PATCH 2/2] sched/core: split iowait state " Jens Axboe

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=c842c819-7035-45b1-8098-55a2d24a7d47@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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