From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754159AbcAOX47 (ORCPT ); Fri, 15 Jan 2016 18:56:59 -0500 Received: from v094114.home.net.pl ([79.96.170.134]:47710 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753828AbcAOX4e (ORCPT ); Fri, 15 Jan 2016 18:56:34 -0500 From: "Rafael J. Wysocki" To: Peter Zijlstra Cc: Linux PM list , Linux Kernel Mailing List , Ingo Molnar , Daniel Lezcano , Sudeep Holla Subject: [PATCH 2/2] cpuidle: menu: Avoid pointless checks in menu_select() Date: Sat, 16 Jan 2016 00:56:34 +0100 Message-ID: <7876665.vgkxSAt2aO@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.4.0; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1621492.NI2xz9vt7M@vostro.rjw.lan> References: <1621492.NI2xz9vt7M@vostro.rjw.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Subject: [PATCH] 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 --- drivers/cpuidle/governors/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-pm/drivers/cpuidle/governors/menu.c =================================================================== --- linux-pm.orig/drivers/cpuidle/governors/menu.c +++ linux-pm/drivers/cpuidle/governors/menu.c @@ -342,7 +342,7 @@ static int menu_select(struct cpuidle_dr * 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];