From: Peter Zijlstra <peterz@infradead.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de
Subject: Re: [PATCH 2/4] sched/core: change rq->nr_iowait type to atomic_long_t on 64-bit
Date: Wed, 24 Apr 2024 11:56:35 +0200 [thread overview]
Message-ID: <20240424095635.GU40213@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20240416121526.67022-3-axboe@kernel.dk>
On Tue, Apr 16, 2024 at 06:11:19AM -0600, Jens Axboe wrote:
> In preparation for storing two separate iowait states in there, bump the
> size from a 32-bit to a 64-bit size, for 64-bit kernels.
>
> Note that on 32-bit, the number of tasks are limited to 0x8000, which
> fits just fine in even half of the existiing 32-bit atomic_t. For 64-bit,
> no such limit exists, hence play it safe and make it a 64-bit atomic.
We still have the tid limit, no? Anyway...
>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
> kernel/sched/core.c | 14 +++++++++++++-
> kernel/sched/sched.h | 4 ++++
> 2 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 977bb08a33d2..6a6c985220b1 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3723,17 +3723,29 @@ static inline cpumask_t *alloc_user_cpus_ptr(int node)
>
> static void task_iowait_inc(struct task_struct *p)
> {
> +#ifdef CONFIG_64BIT
> + atomic_long_inc(&task_rq(p)->nr_iowait);
> +#else
> atomic_inc(&task_rq(p)->nr_iowait);
> +#endif
> }
>
> static void task_iowait_dec(struct task_struct *p)
> {
> +#ifdef CONFIG_64BIT
> + atomic_long_dec(&task_rq(p)->nr_iowait);
> +#else
> atomic_dec(&task_rq(p)->nr_iowait);
> +#endif
> }
>
> int rq_iowait(struct rq *rq)
> {
> +#ifdef CONFIG_64BIT
> + return atomic_long_read(&rq->nr_iowait);
> +#else
> return atomic_read(&rq->nr_iowait);
> +#endif
> }
>
> static void
> @@ -10065,7 +10077,7 @@ void __init sched_init(void)
> #endif
> #endif /* CONFIG_SMP */
> hrtick_rq_init(rq);
> - atomic_set(&rq->nr_iowait, 0);
> + atomic_long_set(&rq->nr_iowait, 0);
>
This one site lacks the ifdeffery, which seems superfluous anyway, since
long is already 32bit / 64bit like you want. Hmm?
> #ifdef CONFIG_SCHED_CORE
> rq->core = rq;
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 387f67ddf18a..c2802d066615 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -1049,7 +1049,11 @@ struct rq {
> u64 clock_idle_copy;
> #endif
>
> +#ifdef CONFIG_64BIT
> + atomic_long_t nr_iowait;
> +#else
> atomic_t nr_iowait;
> +#endif
>
> #ifdef CONFIG_SCHED_DEBUG
> u64 last_seen_need_resched_ns;
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-04-24 9:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 12:11 [PATCHSET v4 0/4] Split iowait into two states Jens Axboe
2024-04-16 12:11 ` [PATCH 1/4] sched/core: add helpers for iowait handling Jens Axboe
2024-04-16 12:11 ` [PATCH 2/4] sched/core: change rq->nr_iowait type to atomic_long_t on 64-bit Jens Axboe
2024-04-24 9:56 ` Peter Zijlstra [this message]
2024-04-16 12:11 ` [PATCH 3/4] sched/core: have io_schedule_prepare() return a long Jens Axboe
2024-04-16 12:11 ` [PATCH 4/4] sched/core: split iowait state into two states Jens Axboe
2024-04-16 14:10 ` Christian Loehle
2024-04-16 14:25 ` Christian Loehle
2024-04-24 10:01 ` Peter Zijlstra
2024-04-24 10:08 ` Christian Loehle
2024-04-25 10:16 ` Peter Zijlstra
2024-04-25 10:39 ` Christian Loehle
2024-04-25 14:20 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2024-08-17 20:45 [PATCHSET v5 0/4] Split iowait " Jens Axboe
2024-08-17 20:45 ` [PATCH 2/4] sched/core: change rq->nr_iowait type to atomic_long_t on 64-bit Jens Axboe
2024-08-19 6:30 ` Zhang Qiao
2024-08-19 14:43 ` 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=20240424095635.GU40213@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.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