All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yong Zhang <yong.zhang0@gmail.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Oleg Nesterov <oleg@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>, Li Zefan <lizf@cn.fujitsu.com>,
	Miao Xie <miaox@cn.fujitsu.com>
Subject: Re: [PATCH 1/2] cpuset: fix cpuset_cpus_allowed_fallback() don't update tsk->rt.nr_cpus_allowed
Date: Mon, 16 May 2011 21:37:48 +0800	[thread overview]
Message-ID: <20110516133748.GB2058@zhy> (raw)
In-Reply-To: <1305306135.2466.173.camel@twins>

On Fri, May 13, 2011 at 07:02:15PM +0200, Peter Zijlstra wrote:
> On Fri, 2011-05-13 at 14:42 +0800, Yong Zhang wrote:
> > > - rcu_cpu_kthread_should_stop() call set_cpus_allowed_ptr() again
> > > periodically.
> > >  then, it can reset cpumask if cpuset_cpus_allowed_fallback() change it.
> > >  my debug print obseve following cpumask change occur at boot time.
> > >     1) kthread_bind: bind cpu1
> > >     2) cpuset_cpus_allowed_fallback: bind possible cpu
> > >     3) rcu_cpu_kthread_should_stop: rebind cpu1
> > > - while tsk->rt.nr_cpus_allowed == 1, sched load balancer never be crash.
> > 
> > Seems rcu_spawn_one_cpu_kthread() call wake_up_process() directly,
> > which is under hotplug event CPU_UP_PREPARE. Maybe it should be
> > under CPU_ONLINE. 
> 
> IIRC I talked to Paul about this a while back and ONLINE is too late,
> however STARTING should work. At the time he couldn't quite get that to
> work, but the above situation is indeed the root cause of our problems.
> 
> We shouldn't try to run a cpu affine thread before the cpu in question
> is actually able to run stuff.

But I'm afraid this patch still doesn't help. 
If I understand your patch correctly, you just put the wake up to CPU_STARTING,
but it's still before CPU_ONLINE.
Please check my mail to Paul's in this thread group.

Thanks,
Yong

> 
> I did me a little hackery and with the below patch my kernel still
> boots...
> 
> Would that sort your issue?
> 
> ---
>  kernel/rcutree.c        |   44 ++++++++++++++++++++++++++++++++++++++------
>  kernel/rcutree_plugin.h |    1 -
>  2 files changed, 38 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> index 5616b17..e0218ed 100644
> --- a/kernel/rcutree.c
> +++ b/kernel/rcutree.c
> @@ -1656,7 +1656,6 @@ static int __cpuinit rcu_spawn_one_cpu_kthread(int cpu)
>  	per_cpu(rcu_cpu_kthread_cpu, cpu) = cpu;
>  	WARN_ON_ONCE(per_cpu(rcu_cpu_kthread_task, cpu) != NULL);
>  	per_cpu(rcu_cpu_kthread_task, cpu) = t;
> -	wake_up_process(t);
>  	sp.sched_priority = RCU_KTHREAD_PRIO;
>  	sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
>  	return 0;
> @@ -1764,13 +1763,33 @@ static int __cpuinit rcu_spawn_one_node_kthread(struct rcu_state *rsp,
>  		raw_spin_lock_irqsave(&rnp->lock, flags);
>  		rnp->node_kthread_task = t;
>  		raw_spin_unlock_irqrestore(&rnp->lock, flags);
> -		wake_up_process(t);
>  		sp.sched_priority = 99;
>  		sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
>  	}
>  	return rcu_spawn_one_boost_kthread(rsp, rnp, rnp_index);
>  }
>  
> +static void __cpuinit rcu_wake_cpu_kthread(int cpu)
> +{
> +	struct task_struct *p = per_cpu(rcu_cpu_kthread_task, cpu);
> +
> +	if (p)
> +		wake_up_process(p);
> +}
> +
> +static void __cpuinit rcu_wake_node_kthread(struct rcu_node *rnp)
> +{
> +	if (!rnp)
> +		return;
> +
> +	if (rnp->node_kthread_task)
> +		wake_up_process(rnp->node_kthread_task);
> +#ifdef CONFIG_RCU_BOOST
> +	if (rnp->boost_kthread_task)
> +		wake_up_process(rnp->boost_kthread_task);
> +#endif
> +}
> +
>  /*
>   * Spawn all kthreads -- called as soon as the scheduler is running.
>   */
> @@ -1783,19 +1802,24 @@ static int __init rcu_spawn_kthreads(void)
>  	for_each_possible_cpu(cpu) {
>  		init_waitqueue_head(&per_cpu(rcu_cpu_wq, cpu));
>  		per_cpu(rcu_cpu_has_work, cpu) = 0;
> -		if (cpu_online(cpu))
> +		if (cpu_online(cpu)) {
>  			(void)rcu_spawn_one_cpu_kthread(cpu);
> +			rcu_wake_cpu_kthread(cpu);
> +		}
>  	}
>  	rnp = rcu_get_root(rcu_state);
>  	init_waitqueue_head(&rnp->node_wq);
>  	rcu_init_boost_waitqueue(rnp);
>  	(void)rcu_spawn_one_node_kthread(rcu_state, rnp);
> -	if (NUM_RCU_NODES > 1)
> +	rcu_wake_node_kthread(rnp);
> +	if (NUM_RCU_NODES > 1) {
>  		rcu_for_each_leaf_node(rcu_state, rnp) {
>  			init_waitqueue_head(&rnp->node_wq);
>  			rcu_init_boost_waitqueue(rnp);
>  			(void)rcu_spawn_one_node_kthread(rcu_state, rnp);
> +			rcu_wake_node_kthread(rnp);
>  		}
> +	}
>  	return 0;
>  }
>  early_initcall(rcu_spawn_kthreads);
> @@ -2206,7 +2230,7 @@ static void __cpuinit rcu_online_cpu(int cpu)
>  	rcu_preempt_init_percpu_data(cpu);
>  }
>  
> -static void __cpuinit rcu_online_kthreads(int cpu)
> +static void __cpuinit rcu_prepare_kthreads(int cpu)
>  {
>  	struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu);
>  	struct rcu_node *rnp = rdp->mynode;
> @@ -2233,7 +2257,15 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
>  	case CPU_UP_PREPARE:
>  	case CPU_UP_PREPARE_FROZEN:
>  		rcu_online_cpu(cpu);
> -		rcu_online_kthreads(cpu);
> +		rcu_prepare_kthreads(cpu);
> +		break;
> +	case CPU_STARTING:
> +		rcu_wake_cpu_kthread(cpu);
> +		do {
> +			struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu);
> +		       	if (rdp)
> +				rcu_wake_node_kthread(rdp->mynode);
> +		} while (0);
>  		break;
>  	case CPU_ONLINE:
>  	case CPU_DOWN_FAILED:
> diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> index ed339702..961a316 100644
> --- a/kernel/rcutree_plugin.h
> +++ b/kernel/rcutree_plugin.h
> @@ -1306,7 +1306,6 @@ static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
>  	raw_spin_lock_irqsave(&rnp->lock, flags);
>  	rnp->boost_kthread_task = t;
>  	raw_spin_unlock_irqrestore(&rnp->lock, flags);
> -	wake_up_process(t);
>  	sp.sched_priority = RCU_KTHREAD_PRIO;
>  	sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
>  	return 0;

  parent reply	other threads:[~2011-05-16 13:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-28 14:20 [RFC PATCH] cpuset: fix cpuset_cpus_allowed_fallback() don't update tsk->rt.nr_cpus_allowed KOSAKI Motohiro
2011-04-28 16:11 ` Oleg Nesterov
2011-05-02 10:42   ` KOSAKI Motohiro
2011-05-02 10:55     ` [PATCH 1/2] " KOSAKI Motohiro
2011-05-11 16:05       ` Peter Zijlstra
2011-05-13  5:48         ` KOSAKI Motohiro
2011-05-13  6:42           ` Yong Zhang
2011-05-13  7:33             ` KOSAKI Motohiro
2011-05-13  7:43               ` Yong Zhang
2011-05-13  9:34                 ` KOSAKI Motohiro
2011-05-13 17:02             ` Peter Zijlstra
2011-05-14 11:17               ` KOSAKI Motohiro
2011-05-16 13:37               ` Yong Zhang [this message]
2011-05-19  8:45                 ` Peter Zijlstra
2011-05-19  8:54                   ` Yong Zhang
2011-05-15 18:55             ` Paul E. McKenney
2011-05-16 13:26               ` Yong Zhang
2011-05-19  6:06                 ` [PATCH v2 1/2] rcu: don't bind offline cpu KOSAKI Motohiro
2011-05-19  6:08                   ` [PATCH v2 2/2] cpuset: fix cpuset_cpus_allowed_fallback() don't update tsk->rt.nr_cpus_allowed KOSAKI Motohiro
2011-05-28 16:35                     ` [tip:sched/urgent] cpuset: Fix cpuset_cpus_allowed_fallback(), " tip-bot for KOSAKI Motohiro
2011-06-20 10:20                       ` Peter Zijlstra
2011-06-21  9:54                         ` KOSAKI Motohiro
2011-05-19  8:34                   ` [PATCH v2 1/2] rcu: don't bind offline cpu Peter Zijlstra
2011-05-19  8:50                     ` KOSAKI Motohiro
2011-05-19  9:41                       ` Peter Zijlstra
2011-05-19 10:12                         ` KOSAKI Motohiro
2011-05-19 11:41                           ` Peter Zijlstra
2011-05-20 22:46                         ` Paul E. McKenney
2011-05-19  8:55                     ` Peter Zijlstra
2011-05-02 10:56     ` [PATCH 2/2] sched, cpuset: introduce do_set_cpus_allowed() helper function KOSAKI Motohiro
2011-05-02 12:58     ` [RFC PATCH] cpuset: fix cpuset_cpus_allowed_fallback() don't update tsk->rt.nr_cpus_allowed Paul E. McKenney

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=20110516133748.GB2058@zhy \
    --to=yong.zhang0@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=miaox@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.