Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1310541

[PATCH 2/2] cpuidle: menu: Avoid pointless checks in menu_select()

From "Rafael J. Wysocki" <rjw@rjwysocki.net>
Newsgroups linux.kernel
Subject [PATCH 2/2] cpuidle: menu: Avoid pointless checks in menu_select()
Date 2016-01-16 01:00 +0100
Message-ID <qRmrF-4Gw-33@gated-at.bofh.it> (permalink)
References <qRmrE-4Gw-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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 <rafael.j.wysocki@intel.com>
---
 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];
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] cpuidle optimizations (on top of linux-next) "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-01-16 01:00 +0100
  [PATCH 2/2] cpuidle: menu: Avoid pointless checks in menu_select() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-01-16 01:00 +0100
    [Resend][PATCH 2/2] cpuidle: menu: Avoid pointless checks in menu_select() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-01-19 00:00 +0100
  Re: [PATCH 0/2] cpuidle optimizations (on top of linux-next) Sudeep Holla <sudeep.holla@arm.com> - 2016-01-18 14:50 +0100
    Re: [PATCH 0/2] cpuidle optimizations (on top of linux-next) Ingo Molnar <mingo@kernel.org> - 2016-01-19 08:30 +0100
      Re: [PATCH 0/2] cpuidle optimizations (on top of linux-next) "Rafael J. Wysocki" <rafael@kernel.org> - 2016-01-19 14:20 +0100
        Re: [PATCH 0/2] cpuidle optimizations (on top of linux-next) Ingo Molnar <mingo@kernel.org> - 2016-01-19 14:30 +0100
          Re: [PATCH 0/2] cpuidle optimizations (on top of linux-next) "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-01-19 15:00 +0100

csiph-web