From: Peter Zijlstra <peterz@infradead.org>
To: Hui Tang <tanghui20@huawei.com>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, linux-kernel@vger.kernel.org,
judy.chenhui@huawei.com, zhangqiao22@huawei.com,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched/rt: Fix possible warn when push_rt_task
Date: Mon, 3 Jul 2023 14:39:02 +0200 [thread overview]
Message-ID: <20230703123902.GI4253@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20230624092130.174409-1-tanghui20@huawei.com>
On Sat, Jun 24, 2023 at 05:21:30PM +0800, Hui Tang wrote:
> A warn may be triggered during reboot, as follows:
>
> reboot
> ->kernel_restart
> ->machine_restart
> ->smp_send_stop --- ipi handler set_cpu_online(cpu, false)
>
> balance_callback
> -> __balance_callback
> ->push_rt_task
> -> find_lock_lowest_rq --- offline cpu in vec->mask not be cleared
> -> find_lowest_rq
> -> cpupri_find
> -> cpupri_find_fitness
> -> __cpupri_find [cpumask_and(..., vec->mask)]
> -> set_task_cpu(next_task, lowest_rq->cpu) --- WARN_ON(!oneline(cpu)
>
> So add !cpu_online(lowest_rq->cpu) check before set_task_cpu().
> The fix does not completely fix the problem, since cpu_online_mask may
> be cleared after check.
This is tinkering.. at best. I'm sure there's a score of other issues,
not in the least the very same issue in deadline.c. But since this
doesn't actually fix anything, this clearly isn't the right way.
> Fixes: 4ff9083b8a9a8 ("sched/core: WARN() when migrating to an offline CPU")
> Signed-off-by: Hui Tang <tanghui20@huawei.com>
> ---
> kernel/sched/rt.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 00e0e5074115..852ef18b6a50 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2159,6 +2159,9 @@ static int push_rt_task(struct rq *rq, bool pull)
> goto retry;
> }
>
> + if (unlikely(!cpu_online(lowest_rq->cpu)))
> + goto out;
> +
> deactivate_task(rq, next_task, 0);
> set_task_cpu(next_task, lowest_rq->cpu);
> activate_task(lowest_rq, next_task, 0);
> --
> 2.17.1
>
prev parent reply other threads:[~2023-07-03 12:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-24 9:21 [PATCH] sched/rt: Fix possible warn when push_rt_task Hui Tang
2023-07-03 12:39 ` Peter Zijlstra [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=20230703123902.GI4253@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=judy.chenhui@huawei.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tanghui20@huawei.com \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=zhangqiao22@huawei.com \
/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