public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu: move some code from macro to function
@ 2010-03-28  3:12 Lai Jiangshan
  2010-03-28  4:15 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Lai Jiangshan @ 2010-03-28  3:12 UTC (permalink / raw)
  To: Paul E. McKenney, Ingo Molnar, LKML


cleanup: move some code from macro to function

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 3ec8160..112edb5 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1849,6 +1849,14 @@ static void __init rcu_init_one(struct rcu_state *rsp)
 			INIT_LIST_HEAD(&rnp->blocked_tasks[3]);
 		}
 	}
+
+	rnp = rsp->level[NUM_RCU_LVLS - 1];
+	for_each_possible_cpu(i) {
+		if (i > rnp->grphi)
+			rnp++;
+		rsp->rda[i]->mynode = rnp;
+		rcu_boot_init_percpu_data(i, rsp);
+	}
 }
 
 /*
@@ -1859,19 +1867,11 @@ static void __init rcu_init_one(struct rcu_state *rsp)
 #define RCU_INIT_FLAVOR(rsp, rcu_data) \
 do { \
 	int i; \
-	int j; \
-	struct rcu_node *rnp; \
 	\
-	rcu_init_one(rsp); \
-	rnp = (rsp)->level[NUM_RCU_LVLS - 1]; \
-	j = 0; \
 	for_each_possible_cpu(i) { \
-		if (i > rnp[j].grphi) \
-			j++; \
-		per_cpu(rcu_data, i).mynode = &rnp[j]; \
 		(rsp)->rda[i] = &per_cpu(rcu_data, i); \
-		rcu_boot_init_percpu_data(i, rsp); \
 	} \
+	rcu_init_one(rsp); \
 } while (0)
 
 void __init rcu_init(void)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rcu: move some code from macro to function
  2010-03-28  3:12 [PATCH] rcu: move some code from macro to function Lai Jiangshan
@ 2010-03-28  4:15 ` Paul E. McKenney
  2010-03-29  1:03   ` Lai Jiangshan
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2010-03-28  4:15 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: Ingo Molnar, LKML

On Sun, Mar 28, 2010 at 11:12:30AM +0800, Lai Jiangshan wrote:
> 
> cleanup: move some code from macro to function

Nice!

I have queued this for RCU 2.6.35, with the following commit message:

	Shrink the RCU_INIT_FLAVOR() macro by moving all but the
	initialization of the ->rda[] array to rcu_init_one().
	The call to rcu_init_one() can then be moved to the end
	of the RCU_INIT_FLAVOR() macro, which is required because
	rcu_boot_init_percpu_data(), which is now called from
	rcu_init_one(), depends on the initialization of the ->rda[]
	array.

Seem reasonable?

							Thanx, Paul

> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> index 3ec8160..112edb5 100644
> --- a/kernel/rcutree.c
> +++ b/kernel/rcutree.c
> @@ -1849,6 +1849,14 @@ static void __init rcu_init_one(struct rcu_state *rsp)
>  			INIT_LIST_HEAD(&rnp->blocked_tasks[3]);
>  		}
>  	}
> +
> +	rnp = rsp->level[NUM_RCU_LVLS - 1];
> +	for_each_possible_cpu(i) {
> +		if (i > rnp->grphi)
> +			rnp++;
> +		rsp->rda[i]->mynode = rnp;
> +		rcu_boot_init_percpu_data(i, rsp);
> +	}
>  }
> 
>  /*
> @@ -1859,19 +1867,11 @@ static void __init rcu_init_one(struct rcu_state *rsp)
>  #define RCU_INIT_FLAVOR(rsp, rcu_data) \
>  do { \
>  	int i; \
> -	int j; \
> -	struct rcu_node *rnp; \
>  	\
> -	rcu_init_one(rsp); \
> -	rnp = (rsp)->level[NUM_RCU_LVLS - 1]; \
> -	j = 0; \
>  	for_each_possible_cpu(i) { \
> -		if (i > rnp[j].grphi) \
> -			j++; \
> -		per_cpu(rcu_data, i).mynode = &rnp[j]; \
>  		(rsp)->rda[i] = &per_cpu(rcu_data, i); \
> -		rcu_boot_init_percpu_data(i, rsp); \
>  	} \
> +	rcu_init_one(rsp); \
>  } while (0)
> 
>  void __init rcu_init(void)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rcu: move some code from macro to function
  2010-03-28  4:15 ` Paul E. McKenney
@ 2010-03-29  1:03   ` Lai Jiangshan
  0 siblings, 0 replies; 3+ messages in thread
From: Lai Jiangshan @ 2010-03-29  1:03 UTC (permalink / raw)
  To: paulmck; +Cc: Ingo Molnar, LKML

Paul E. McKenney wrote:
> On Sun, Mar 28, 2010 at 11:12:30AM +0800, Lai Jiangshan wrote:
>> cleanup: move some code from macro to function
> 
> Nice!
> 
> I have queued this for RCU 2.6.35, with the following commit message:
> 
> 	Shrink the RCU_INIT_FLAVOR() macro by moving all but the
> 	initialization of the ->rda[] array to rcu_init_one().
> 	The call to rcu_init_one() can then be moved to the end
> 	of the RCU_INIT_FLAVOR() macro, which is required because
> 	rcu_boot_init_percpu_data(), which is now called from
> 	rcu_init_one(), depends on the initialization of the ->rda[]
> 	array.
> 
> Seem reasonable?
> 
> 							Thanx, Paul
> 

OK
Thanks, Lai

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-29  1:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-28  3:12 [PATCH] rcu: move some code from macro to function Lai Jiangshan
2010-03-28  4:15 ` Paul E. McKenney
2010-03-29  1:03   ` Lai Jiangshan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox