On 01/31/2013 06:21 AM, Namhyung Kim wrote: >> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c >> index e1f6860..3594e0c 100644 >> --- a/drivers/cpuidle/cpuidle.c >> +++ b/drivers/cpuidle/cpuidle.c >> @@ -23,6 +23,7 @@ >> #include "cpuidle.h" >> >> DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); >> +static DEFINE_PER_CPU(unsigned int, cpu_state); > > What about making it 'int' as cpuidle_get_state() returns int type?
index should never get negative because it is an index. In case it does (which should not) we end up with a large value which is considered as a really deep state and the CPU will be ignored as long as possible. >> @@ -40,13 +41,23 @@ void disable_cpuidle(void) … >> static inline int cpuidle_enter(struct cpuidle_device *dev, >> struct cpuidle_driver *drv, int index) >> { >> struct cpuidle_state *target_state = &drv->states[index]; >> - return target_state->enter(dev, drv, index); >> + int ret; >> + >> + per_cpu(cpu_state, smp_processor_id()) = index + 1; >> + ret = target_state->enter(dev, drv, index); >> + per_cpu(cpu_state, smp_processor_id()) = 0; > > Maybe we can use local variable 'cpu' for this duplicated > smp_processor_id() call as it's never executed on another cpu in > between? This should be really cheap unless CONFIG_DEBUG_PREEMPT is on but okay, will change. > Thanks, > Namhyung Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/