summaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle/poll_state.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-10-02 23:50:30 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-10-04 19:27:27 +0200
commit01bad1c6896db021db82042e71c2bf1f97cc026b (patch)
treeff58e0d232ffb434426a29d50f066f17554ee6c7 /drivers/cpuidle/poll_state.c
parentcpuidle: menu: Move the latency_req == 0 special case check (diff)
downloadlinux-01bad1c6896db021db82042e71c2bf1f97cc026b.tar.xz
linux-01bad1c6896db021db82042e71c2bf1f97cc026b.zip
cpuidle: poll_state: Revise loop termination condition
If need_resched() returns "false", breaking out of the loop in poll_idle() will cause a new idle state to be selected, so in fact it usually doesn't make sense to spin in it longer than the target residency of the second state. [Note that the "polling" state is used only if there is at least one "real" state defined in addition to it, so the second state is always there.] On the other hand, breaking out of it early (say in case the next state is disabled) shouldn't hurt as it is polling anyway. For this reason, make the loop in poll_idle() break if the CPU has been spinning longer than the target residency of the second state (the "polling" state can only be state[0]). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle/poll_state.c')
-rw-r--r--drivers/cpuidle/poll_state.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c
index 36ff5a1d9422..85792d371add 100644
--- a/drivers/cpuidle/poll_state.c
+++ b/drivers/cpuidle/poll_state.c
@@ -9,7 +9,6 @@
#include <linux/sched/clock.h>
#include <linux/sched/idle.h>
-#define POLL_IDLE_TIME_LIMIT (TICK_NSEC / 16)
#define POLL_IDLE_RELAX_COUNT 200
static int __cpuidle poll_idle(struct cpuidle_device *dev,
@@ -21,6 +20,7 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
local_irq_enable();
if (!current_set_polling_and_test()) {
+ u64 limit = (u64)drv->states[1].target_residency * NSEC_PER_USEC;
unsigned int loop_count = 0;
while (!need_resched()) {
@@ -29,7 +29,7 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
continue;
loop_count = 0;
- if (local_clock() - time_start > POLL_IDLE_TIME_LIMIT) {
+ if (local_clock() - time_start > limit) {
dev->poll_time_limit = true;
break;
}