On Fri, Jul 02, 2010 at 09:13:59AM -0500, Shinya Kuribayashi wrote: > Hi, > > On 07/01/2010 07:01 AM, David VomLehn wrote: > > Thanks! You are correct in your analysis and make a good point that > > clz should be used in interrupt handling. I think, though, that it's > > better to go ahead and supply a full-blown cpu-features-override.h > > rather than focusing on this one case. This way fls() will be optimized > > to use clz everywhere and any other optimizations that depend on constant > > cpu_has_* values will also be used. > > Your choice, either one will be fine :-) I think the cpu-features-override is a a better solution because it allows better code throughout the kernel. > By the way, Malta's clz() and irq_ffs() are very nice, and there are > two followers; MIPSSim and PowerTV. And now I'm going to make use of > them for emma2rh, too. > > I've prepared a consolidation patch like this, but have two concerns: > > 1) irq_ffs() is used to dispatch IRQs, so we'd like to give preference > to CONFIG_CPU_xxx over cpu_has_clo_clz, to optimize with CLZ. It's > somewhat different for usual fls() and ffs() cases. Or, > > 2) would it be better to check __builtin_constant_p(cpu_has_clo_clz)? > > Or, any other good alternatives? Usually it's better to control things on a feature-by-feature basis rather than rely on things like CPU model. This allows you to easily handle case where, for example, you have a different CPU that normally doesn't have a feature but a particular variant does have it. IIRC, the MIPS family has examples of this. So, I think it's better to go with the: __builtin_constant_p(cpu_has_clo_clz) && cpu_has_clo_clz used in fls(). -- David VL