From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755651AbZHYShx (ORCPT ); Tue, 25 Aug 2009 14:37:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755535AbZHYShw (ORCPT ); Tue, 25 Aug 2009 14:37:52 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:34781 "EHLO e36.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755532AbZHYShv (ORCPT ); Tue, 25 Aug 2009 14:37:51 -0400 Subject: Re: [PATCH -tip] Create rcutree plugins to handle hotplug CPU for multi-level trees From: Josh Triplett To: paulmck@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, dvhltc@us.ibm.com, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org In-Reply-To: <20090825182204.GA26736@linux.vnet.ibm.com> References: <20090825182204.GA26736@linux.vnet.ibm.com> Content-Type: text/plain Date: Tue, 25 Aug 2009 11:38:03 -0700 Message-Id: <1251225483.2706.4.camel@josh-work.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2009-08-25 at 11:22 -0700, Paul E. McKenney wrote: > When offlining CPUs from a multi-level tree, there is the possibility > of offlining the last CPU from a given node when there are preempted > RCU read-side critical sections that started life on one of the CPUs on > that node. In this case, the corresponding tasks will be enqueued via > the task_struct's rcu_node_entry list_head onto one of the rcu_node's > blocked_tasks[] lists. These tasks need to be moved somewhere else > so that they will prevent the current grace period from ending. > That somewhere is the root rcu_node. > > With this patch, TREE_PREEMPT_RCU passes moderate rcutorture testing > with aggressive CPU-hotplugging (no delay between inserting/removing > randomly selected CPU). > > Signed-off-by: Paul E. McKenney Looks good. One comment below. > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -1208,7 +1208,7 @@ struct task_struct { > #ifdef CONFIG_TREE_PREEMPT_RCU > int rcu_read_lock_nesting; > char rcu_read_unlock_special; > - int rcu_blocked_cpu; > + void *rcu_blocked_node; This should use struct rcu_node *, not void *. That would eliminate several casts in the changes below. You can forward-declare struct rcu_node if you want to avoid including RCU headers in sched.h. > --- a/kernel/rcutree_plugin.h > +++ b/kernel/rcutree_plugin.h > @@ -92,7 +92,7 @@ static void rcu_preempt_qs(int cpu) > rnp = rdp->mynode; > spin_lock(&rnp->lock); > t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED; > - t->rcu_blocked_cpu = cpu; > + t->rcu_blocked_node = (void *)rnp; Regardless of whether you change the type in the structure, you never need to cast a pointer to type void *; any non-function pointer will become void * without complaint. > @@ -170,12 +170,21 @@ static void rcu_read_unlock_special(struct task_struct *t) > if (special & RCU_READ_UNLOCK_BLOCKED) { > t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_BLOCKED; > > - /* Remove this task from the list it blocked on. */ > - rnp = rcu_preempt_state.rda[t->rcu_blocked_cpu]->mynode; > - spin_lock(&rnp->lock); > + /* > + * Remove this task from the list it blocked on. The > + * task can migrate while we acquire the lock, but at > + * most one time. So at most two passes through loop. > + */ > + for (;;) { > + rnp = (struct rcu_node *)t->rcu_blocked_node; > + spin_lock(&rnp->lock); > + if (rnp == (struct rcu_node *)t->rcu_blocked_node) > + break; > + spin_unlock(&rnp->lock); > + } Both of the casts of t->rcu_blocked_node can go away here, given the type change in the structure. - Josh Triplett