From: Valentin Schneider <valentin.schneider@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, vincent.guittot@linaro.org, tglx@linutronix.de,
linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bristot@redhat.com, swood@redhat.com
Subject: Re: [PATCH 1/2] sched: Fix balance_callback()
Date: Fri, 11 Sep 2020 13:17:02 +0100 [thread overview]
Message-ID: <jhjsgbo5wzl.mognet@arm.com> (raw)
In-Reply-To: <20200911082536.470013100@infradead.org>
On 11/09/20 09:17, Peter Zijlstra wrote:
> The intent of balance_callback() has always been to delay executing
> balancing operations until the end of the current rq->lock section.
> This is because balance operations must often drop rq->lock, and that
> isn't safe in general.
>
> However, as noted by Scott, there were a few holes in that scheme;
> balance_callback() was called after rq->lock was dropped, which means
> another CPU can interleave and touch the callback list.
>
So that can be say __schedule() tail racing with some setprio; what's the
worst that can (currently) happen here? Something like say two consecutive
enqueuing of push_rt_tasks() to the callback list?
> Rework code to call the balance callbacks before dropping rq->lock
> where possible, and otherwise splice the balance list onto a local
> stack.
>
> This guarantees that the balance list must be empty when we take
> rq->lock. IOW, we'll only ever run our own balance callbacks.
>
Makes sense to me.
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
> Reported-by: Scott Wood <swood@redhat.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
[...]
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -1220,6 +1220,8 @@ static inline void rq_pin_lock(struct rq
> #ifdef CONFIG_SCHED_DEBUG
> rq->clock_update_flags &= (RQCF_REQ_SKIP|RQCF_ACT_SKIP);
> rf->clock_update_flags = 0;
> +
> + SCHED_WARN_ON(rq->balance_callback);
Clever!
> #endif
> }
>
next prev parent reply other threads:[~2020-09-11 12:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 8:17 [PATCH 0/2] sched: migrate_disable() preparations Peter Zijlstra
2020-09-11 8:17 ` [PATCH 1/2] sched: Fix balance_callback() Peter Zijlstra
2020-09-11 12:17 ` Valentin Schneider [this message]
2020-09-11 12:25 ` peterz
2020-09-11 13:27 ` Valentin Schneider
2020-09-11 8:17 ` [PATCH 2/2] sched/hotplug: Ensure only per-cpu kthreads run during hotplug Peter Zijlstra
2020-09-11 12:17 ` Valentin Schneider
2020-09-11 12:29 ` peterz
2020-09-11 13:48 ` Valentin Schneider
2020-09-16 10:18 ` Sebastian Andrzej Siewior
2020-09-16 12:10 ` peterz
2020-09-16 13:58 ` Sebastian Andrzej Siewior
2020-09-16 14:07 ` peterz
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=jhjsgbo5wzl.mognet@arm.com \
--to=valentin.schneider@arm.com \
--cc=bristot@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=swood@redhat.com \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.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