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

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 :)

> as such. ->in_iowait_acct nests inside of ->in_iowait, both for
> efficiency reasons, but also so that the relationship between the two
> is clear. A waiter may set ->in_wait alone and not care about the
> accounting.

> +/*
> + * 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?

Thanks,

        tglx

  reply	other threads:[~2024-02-29 17:31 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 [this message]
2024-02-29 17:45     ` Jens Axboe
  -- 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=87zfvj6uub.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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