linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Jing-Ting Wu <jing-ting.wu@mediatek.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Waiman Long <longman@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Mel Gorman <mgorman@suse.de>,
	wsd_upstream@mediatek.com
Subject: Re: BUG: HANG_DETECT waiting for migration_cpu_stop() complete
Date: Thu, 22 Sep 2022 20:02:27 +0800	[thread overview]
Message-ID: <20220922120227.1311-1-hdanton@sina.com> (raw)
In-Reply-To: <93f4ce9486ec4b856ba0f3bfe956fc9b2d3cb4cf.camel@mediatek.com>

On 22 Sep 2022 13:40:47 +0800 Jing-Ting Wu <jing-ting.wu@mediatek.com> wrote
> 
> 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. 

Thanks for your test. Any other effects observed?

> 
> 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) {
> 	  ...
		/*
		 * The task moved before the stopper got to run. We're holding
		 * ->pi_lock, so the allowed mask is stable - if it got
		 * somewhere allowed, we're done.
		 */
> 	  If (cpumask_test_cpu(task_cpu(p), p-> cpus_ ptr)) { 
>         	p->migration_pending = NULL;
>       		 complete = true;
>       		 goto out;
> 	}
> ...
> }

Given p->migration_pending reset in case of job done, the warning you saw
is benign without other negative effects observed.

It should be fixed (example by simply cutting it) if you have a reproducer
on top of the mainline tree.

Hillf


      reply	other threads:[~2022-09-22 12:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <88b2910181bda955ac46011b695c53f7da39ac47.camel@mediatek.com>
2022-09-07  0:07 ` Hillf Danton
2022-09-22  5:40   ` Jing-Ting Wu
2022-09-22 12:02     ` Hillf Danton [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=20220922120227.1311-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=jing-ting.wu@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=mgorman@suse.de \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.org \
    --cc=wsd_upstream@mediatek.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