Prev: Keyboard Jammed error patch 2.4.35-pre4
Next: init: DEBUG_BLOCK_EXT_DEVT requires explicit root= param
From: Ingo Molnar on 22 Aug 2008 00:50 * Paul E. McKenney <paulmck(a)linux.vnet.ibm.com> wrote: > +#define MAX_RCU_LEVELS 3 > +#if NR_CPUS <= CONFIG_RCU_FANOUT > +#define NUM_RCU_LEVELS 1 > +#define NUM_RCU_LEVEL_1 1 > +#define NUM_RCU_LEVEL_2 NR_CPUS > +#define NUM_RCU_LEVEL_3 0 > +#define NUM_RCU_LEVEL_4 0 > +#define NUM_RCU_NODES NUM_RCU_LEVEL_1 > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > +#define NUM_RCU_LEVELS 2 > +#define NUM_RCU_LEVEL_1 1 > +#define NUM_RCU_LEVEL_2 \ > + (((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT)) > +#define NUM_RCU_LEVEL_3 NR_CPUS > +#define NUM_RCU_LEVEL_4 0 > +#define NUM_RCU_NODES \ > + ((NUM_RCU_LEVEL_1) + (NUM_RCU_LEVEL_2)) > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > +#define NUM_RCU_LEVELS 3 > +#define RCU_FANOUT_SQ ((CONFIG_RCU_FANOUT) * (CONFIG_RCU_FANOUT)) > +#define NUM_RCU_LEVEL_1 1 > +#define NUM_RCU_LEVEL_2 \ > + (((NR_CPUS) + (RCU_FANOUT_SQ) - 1) / (RCU_FANOUT_SQ)) > +#define NUM_RCU_LEVEL_3 \ > + ((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT) > +#define NUM_RCU_LEVEL_4 NR_CPUS > +#define NUM_RCU_NODES \ > + ((NUM_RCU_LEVEL_1) + \ > + (NUM_RCU_LEVEL_2) + \ > + (NUM_RCU_LEVEL_3)) > +#else > +#error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" > +#endif just a quick stylistic suggestion: if feasible then such sizing ugliness should be hidden in a Kconfig file. (if Kconfig is capable enough for this that is) Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Paul E. McKenney on 22 Aug 2008 09:50 On Fri, Aug 22, 2008 at 06:37:15AM +0200, Ingo Molnar wrote: > > * Paul E. McKenney <paulmck(a)linux.vnet.ibm.com> wrote: > > > +#define MAX_RCU_LEVELS 3 > > +#if NR_CPUS <= CONFIG_RCU_FANOUT > > +#define NUM_RCU_LEVELS 1 > > +#define NUM_RCU_LEVEL_1 1 > > +#define NUM_RCU_LEVEL_2 NR_CPUS > > +#define NUM_RCU_LEVEL_3 0 > > +#define NUM_RCU_LEVEL_4 0 > > +#define NUM_RCU_NODES NUM_RCU_LEVEL_1 > > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > > +#define NUM_RCU_LEVELS 2 > > +#define NUM_RCU_LEVEL_1 1 > > +#define NUM_RCU_LEVEL_2 \ > > + (((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT)) > > +#define NUM_RCU_LEVEL_3 NR_CPUS > > +#define NUM_RCU_LEVEL_4 0 > > +#define NUM_RCU_NODES \ > > + ((NUM_RCU_LEVEL_1) + (NUM_RCU_LEVEL_2)) > > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > > +#define NUM_RCU_LEVELS 3 > > +#define RCU_FANOUT_SQ ((CONFIG_RCU_FANOUT) * (CONFIG_RCU_FANOUT)) > > +#define NUM_RCU_LEVEL_1 1 > > +#define NUM_RCU_LEVEL_2 \ > > + (((NR_CPUS) + (RCU_FANOUT_SQ) - 1) / (RCU_FANOUT_SQ)) > > +#define NUM_RCU_LEVEL_3 \ > > + ((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT) > > +#define NUM_RCU_LEVEL_4 NR_CPUS > > +#define NUM_RCU_NODES \ > > + ((NUM_RCU_LEVEL_1) + \ > > + (NUM_RCU_LEVEL_2) + \ > > + (NUM_RCU_LEVEL_3)) > > +#else > > +#error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" > > +#endif > > just a quick stylistic suggestion: if feasible then such sizing ugliness > should be hidden in a Kconfig file. (if Kconfig is capable enough for > this that is) I have no idea if Kconfig can do it, but I will check. Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Paul E. McKenney on 22 Aug 2008 13:30 On Fri, Aug 22, 2008 at 06:47:20AM -0700, Paul E. McKenney wrote: > On Fri, Aug 22, 2008 at 06:37:15AM +0200, Ingo Molnar wrote: > > > > * Paul E. McKenney <paulmck(a)linux.vnet.ibm.com> wrote: > > > > > +#define MAX_RCU_LEVELS 3 > > > +#if NR_CPUS <= CONFIG_RCU_FANOUT > > > +#define NUM_RCU_LEVELS 1 > > > +#define NUM_RCU_LEVEL_1 1 > > > +#define NUM_RCU_LEVEL_2 NR_CPUS > > > +#define NUM_RCU_LEVEL_3 0 > > > +#define NUM_RCU_LEVEL_4 0 > > > +#define NUM_RCU_NODES NUM_RCU_LEVEL_1 > > > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > > > +#define NUM_RCU_LEVELS 2 > > > +#define NUM_RCU_LEVEL_1 1 > > > +#define NUM_RCU_LEVEL_2 \ > > > + (((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT)) > > > +#define NUM_RCU_LEVEL_3 NR_CPUS > > > +#define NUM_RCU_LEVEL_4 0 > > > +#define NUM_RCU_NODES \ > > > + ((NUM_RCU_LEVEL_1) + (NUM_RCU_LEVEL_2)) > > > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > > > +#define NUM_RCU_LEVELS 3 > > > +#define RCU_FANOUT_SQ ((CONFIG_RCU_FANOUT) * (CONFIG_RCU_FANOUT)) > > > +#define NUM_RCU_LEVEL_1 1 > > > +#define NUM_RCU_LEVEL_2 \ > > > + (((NR_CPUS) + (RCU_FANOUT_SQ) - 1) / (RCU_FANOUT_SQ)) > > > +#define NUM_RCU_LEVEL_3 \ > > > + ((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT) > > > +#define NUM_RCU_LEVEL_4 NR_CPUS > > > +#define NUM_RCU_NODES \ > > > + ((NUM_RCU_LEVEL_1) + \ > > > + (NUM_RCU_LEVEL_2) + \ > > > + (NUM_RCU_LEVEL_3)) > > > +#else > > > +#error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" > > > +#endif > > > > just a quick stylistic suggestion: if feasible then such sizing ugliness > > should be hidden in a Kconfig file. (if Kconfig is capable enough for > > this that is) > > I have no idea if Kconfig can do it, but I will check. OK, Kconfig does not currently support arithmetic, based on zconf.y: expr: symbol { $$ = expr_alloc_symbol($1); } | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } ; All we currently get is basic comparison and logical operators. It would not be all -that- hard to add general arithmetic (famous last words), but when I tried mapping out what the sizing code would look like in such an augmented Kconfig, it was even uglier than the above. So I took a hard look at the current mess, and prettied it as shown below. Is this a sufficient improvement? Another alternative I am considering is moving this to a separate include file. Thoughts? Thanx, Paul #define MAX_RCU_LEVELS 3 #define RCU_FANOUT (CONFIG_RCU_FANOUT) #define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT) #define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT) #if (NR_CPUS) <= RCU_FANOUT # define NUM_RCU_LVLS 1 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 (NR_CPUS) # define NUM_RCU_LVL_2 0 # define NUM_RCU_LVL_3 0 #elif (NR_CPUS) <= RCU_FANOUT_SQ # define NUM_RCU_LVLS 2 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT - 1) / RCU_FANOUT) # define NUM_RCU_LVL_2 (NR_CPUS) # define NUM_RCU_LVL_3 0 #elif (NR_CPUS) <= RCU_FANOUT_CUBE # define NUM_RCU_LVLS 3 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT_SQ - 1) / RCU_FANOUT_SQ) # define NUM_RCU_LVL_2 (((NR_CPUS) + (RCU_FANOUT) - 1) / (RCU_FANOUT)) # define NUM_RCU_LVL_3 NR_CPUS #else # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" #endif /* #if (NR_CPUS) <= RCU_FANOUT */ #define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3) #define NUM_RCU_NODES (RCU_SUM - NR_CPUS) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Josh Triplett on 22 Aug 2008 14:20 On Fri, 2008-08-22 at 10:22 -0700, Paul E. McKenney wrote: > On Fri, Aug 22, 2008 at 06:47:20AM -0700, Paul E. McKenney wrote: > > On Fri, Aug 22, 2008 at 06:37:15AM +0200, Ingo Molnar wrote: > > > > > > * Paul E. McKenney <paulmck(a)linux.vnet.ibm.com> wrote: > > > > > > > +#define MAX_RCU_LEVELS 3 > > > > +#if NR_CPUS <= CONFIG_RCU_FANOUT > > > > +#define NUM_RCU_LEVELS 1 > > > > +#define NUM_RCU_LEVEL_1 1 > > > > +#define NUM_RCU_LEVEL_2 NR_CPUS > > > > +#define NUM_RCU_LEVEL_3 0 > > > > +#define NUM_RCU_LEVEL_4 0 > > > > +#define NUM_RCU_NODES NUM_RCU_LEVEL_1 > > > > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > > > > +#define NUM_RCU_LEVELS 2 > > > > +#define NUM_RCU_LEVEL_1 1 > > > > +#define NUM_RCU_LEVEL_2 \ > > > > + (((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT)) > > > > +#define NUM_RCU_LEVEL_3 NR_CPUS > > > > +#define NUM_RCU_LEVEL_4 0 > > > > +#define NUM_RCU_NODES \ > > > > + ((NUM_RCU_LEVEL_1) + (NUM_RCU_LEVEL_2)) > > > > +#elif NR_CPUS <= CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT * CONFIG_RCU_FANOUT > > > > +#define NUM_RCU_LEVELS 3 > > > > +#define RCU_FANOUT_SQ ((CONFIG_RCU_FANOUT) * (CONFIG_RCU_FANOUT)) > > > > +#define NUM_RCU_LEVEL_1 1 > > > > +#define NUM_RCU_LEVEL_2 \ > > > > + (((NR_CPUS) + (RCU_FANOUT_SQ) - 1) / (RCU_FANOUT_SQ)) > > > > +#define NUM_RCU_LEVEL_3 \ > > > > + ((NR_CPUS) + (CONFIG_RCU_FANOUT) - 1) / (CONFIG_RCU_FANOUT) > > > > +#define NUM_RCU_LEVEL_4 NR_CPUS > > > > +#define NUM_RCU_NODES \ > > > > + ((NUM_RCU_LEVEL_1) + \ > > > > + (NUM_RCU_LEVEL_2) + \ > > > > + (NUM_RCU_LEVEL_3)) > > > > +#else > > > > +#error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" > > > > +#endif > > > > > > just a quick stylistic suggestion: if feasible then such sizing ugliness > > > should be hidden in a Kconfig file. (if Kconfig is capable enough for > > > this that is) > > > > I have no idea if Kconfig can do it, but I will check. > > OK, Kconfig does not currently support arithmetic, based on zconf.y: > > expr: symbol { $$ = expr_alloc_symbol($1); } > | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } > | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } > | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } > | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } > | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } > | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } > ; > > All we currently get is basic comparison and logical operators. It would > not be all -that- hard to add general arithmetic (famous last words), > but when I tried mapping out what the sizing code would look like in > such an augmented Kconfig, it was even uglier than the above. Makes sense. > So I took a hard look at the current mess, and prettied it as shown below. > Is this a sufficient improvement? Looks significantly improved. > Another alternative I am considering is moving this to a separate > include file. I personally don't think that would help. The revised version seems fine. > #define MAX_RCU_LEVELS 3 > #define RCU_FANOUT (CONFIG_RCU_FANOUT) > #define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT) > #define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT) > > #if (NR_CPUS) <= RCU_FANOUT > # define NUM_RCU_LVLS 1 > # define NUM_RCU_LVL_0 1 > # define NUM_RCU_LVL_1 (NR_CPUS) > # define NUM_RCU_LVL_2 0 > # define NUM_RCU_LVL_3 0 > #elif (NR_CPUS) <= RCU_FANOUT_SQ > # define NUM_RCU_LVLS 2 > # define NUM_RCU_LVL_0 1 > # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT - 1) / RCU_FANOUT) > # define NUM_RCU_LVL_2 (NR_CPUS) > # define NUM_RCU_LVL_3 0 > #elif (NR_CPUS) <= RCU_FANOUT_CUBE > # define NUM_RCU_LVLS 3 > # define NUM_RCU_LVL_0 1 > # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT_SQ - 1) / RCU_FANOUT_SQ) > # define NUM_RCU_LVL_2 (((NR_CPUS) + (RCU_FANOUT) - 1) / (RCU_FANOUT)) > # define NUM_RCU_LVL_3 NR_CPUS > #else > # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" > #endif /* #if (NR_CPUS) <= RCU_FANOUT */ > > #define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3) > #define NUM_RCU_NODES (RCU_SUM - NR_CPUS) - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Ingo Molnar on 23 Aug 2008 12:20 * Paul E. McKenney <paulmck(a)linux.vnet.ibm.com> wrote: > Is this a sufficient improvement? yeah - looks much better. This was the block that meets the eye for the first time in the patch so it stuck out. just one more small pet peeve of mine: please use vertical alignment too to improve readability. Instead of: > #define MAX_RCU_LEVELS 3 > #define RCU_FANOUT (CONFIG_RCU_FANOUT) > #define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT) > #define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT) this looks a bit more structured IMO: > #define MAX_RCU_LEVELS 3 > #define RCU_FANOUT (CONFIG_RCU_FANOUT) > #define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT) > #define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT) maybe even this: > #if (NR_CPUS) <= RCU_FANOUT > # define NUM_RCU_LVLS 1 > # define NUM_RCU_LVL_0 1 > # define NUM_RCU_LVL_1 (NR_CPUS) > # define NUM_RCU_LVL_2 0 > # define NUM_RCU_LVL_3 0 > #elif (NR_CPUS) <= RCU_FANOUT_SQ > # define NUM_RCU_LVLS 2 > # define NUM_RCU_LVL_0 1 > # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT - 1) / RCU_FANOUT) > # define NUM_RCU_LVL_2 (NR_CPUS) > # define NUM_RCU_LVL_3 0 > #elif (NR_CPUS) <= RCU_FANOUT_CUBE > # define NUM_RCU_LVLS 3 > # define NUM_RCU_LVL_0 1 > # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT_SQ - 1) / RCU_FANOUT_SQ) > # define NUM_RCU_LVL_2 (((NR_CPUS) + (RCU_FANOUT) - 1) / (RCU_FANOUT)) > # define NUM_RCU_LVL_3 NR_CPUS > #else > # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" > #endif /* #if (NR_CPUS) <= RCU_FANOUT */ but no strong feelings on that one. (maybe inserting a space at the right places helps too, no need for a full tab) Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Next
|
Last
Pages: 1 2 3 4 Prev: Keyboard Jammed error patch 2.4.35-pre4 Next: init: DEBUG_BLOCK_EXT_DEVT requires explicit root= param |