lkml.org 
[lkml]   [2022]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: BUG: HANG_DETECT waiting for migration_cpu_stop() complete
From
Date
On Wed, 2022-09-07 at 08:07 +0800, Hillf Danton wrote:
> On 5 Sep 2022 10:47:36 +0800 Jing-Ting Wu <jing-ting.wu@mediatek.com>
> wrote
> >
> > We meet the HANG_DETECT happened in T SW version with kernel-5.15.
> > Many tasks have been blocked for a long time.
> >
> > Root cause:
> > migration_cpu_stop() is not complete due to
> > is_migration_disabled(p) is
> > true, complete is false and complete_all() never get executed.
> > It let other task wait the rwsem.
>
> See if handing task over to stopper again in case of migration
> disabled
> could survive your tests.
>
> Hillf
>
> --- linux-5.15/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2322,9 +2322,7 @@ static int migration_cpu_stop(void *data
> * holding rq->lock, if p->on_rq == 0 it cannot get enqueued
> because
> * we're holding p->pi_lock.
> */
> - if (task_rq(p) == rq) {
> - if (is_migration_disabled(p))
> - goto out;
> + if (task_rq(p) == rq && !is_migration_disabled(p)) {
>
> if (pending) {
> p->migration_pending = NULL;

Because Peter have some concern for patch by Waiman.
We add Hillf's patch to our stability test.
But there are side effects after patched.
The warning appear once < two weeks.

Backtrace as follows:
[name:panic&]WARNING: CPU: 6 PID: 32583 at affine_move_task
pc : affine_move_task
lr : __set_cpus_allowed_ptr_locked
Call trace:
affine_move_task
__set_cpus_allowed_ptr_locked
migrate_enable
__cgroup_bpf_run_filter_skb
ip_finish_output
ip_output


The root cause is when is_migration_disabled(p) is true,the patched
version will set p->migration_pending to NULL by migration_cpu_stop.
And in affine_move_task will raise a WARN_ON_ONCE(!pending).

Kernel-5.15/kernel/sched/core.c:
static int affine_move_task(struct rq *rq, struct task_struct *p,
struct rq_flags *rf, int dest_cpu, unsigned int flags) {
...
If (WARN_ON_ONCE(!pending)) {
Task_rq_unlock(rq,p,fr);
return -EINVAL;
}
...
}

But the tasks have not been migrated to the new affinity CPU, so there
should be pending tasks to be processed, so p->migration_pending should
not be NULL.



Without patch:
When is_migration_disabled is true, then goto out and not set p-
>migration_pending to NULL.

static int migration_cpu_stop(void *data) {
...
If (task_rq(p) == rq) {
if (is_migration_disabled(p))
goto out;
}
...
}


With patch:
When is_migration_disabled is true and pending is true, goto else if
flow. Because p->cpus_ptr not updated when migrate_disable, so this
condition is always true and p->migration_pending will set to NULL.

static int migration_cpu_stop(void *data) {
...
If (task_rq(p) == rq && !is_migration_disabled(p) ) {
...
} else if (pending) {
...
If (cpumask_test_cpu(task_cpu(p), p-> cpus_ ptr)) {
p->migration_pending = NULL;
complete = true;
goto out;
}
...
}






Best regards,
Jing-Ting Wu


\
 
 \ /
  Last update: 2022-09-22 07:41    [W:0.027 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site