From: Rafael J. Wysocki Date: Fri, 15 Jan 2016 23:56:34 +0000 (+0100) Subject: cpuidle: menu: Avoid pointless checks in menu_select() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5bb1729cbdfbe974ad6385be94b14afbac97e19f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git cpuidle: menu: Avoid pointless checks in menu_select() If menu_select() cannot find a suitable state to return, it will return the state index stored in data->last_state_idx. This means that it is pointless to look at the states whose indices are less than or equal to data->last_state_idx in the main loop, so don't do that. Given that those checks are done on every idle state selection, this change can save quite a bit of completely unnecessary overhead. Signed-off-by: Rafael J. Wysocki Acked-by: Ingo Molnar Tested-by: Sudeep Holla --- diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index be0bae0b41e9..0742b3296673 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -342,7 +342,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) * Find the idle state with the lowest power while satisfying * our constraints. */ - for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { + for (i = data->last_state_idx + 1; i < drv->state_count; i++) { struct cpuidle_state *s = &drv->states[i]; struct cpuidle_state_usage *su = &dev->states_usage[i];