diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-03-27 17:58:45 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-03-29 07:06:08 -0400 |
commit | 4dc2375c1a4e88ed2701f6961e0e4f9a7696ad3c (patch) | |
tree | 926f002833a8fc9afe9aaae3bc71114c43f9b0b7 /drivers/cpuidle | |
parent | 64bdff698092aa6be28c3b248f887022eec77902 (diff) |
cpuidle: poll_state: Avoid invoking local_clock() too often
Rik reports that he sees an increase in CPU use in one benchmark
due to commit 612f1a22f067 "cpuidle: poll_state: Add time limit to
poll_idle()" that caused poll_idle() to call local_clock() in every
iteration of the loop. Utilization increase generally means more
non-idle time with respect to total CPU time (on the average) which
implies reduced CPU frequency.
Doug reports that limiting the rate of local_clock() invocations
in there causes much less power to be drawn during a CPU-intensive
parallel workload (with idle states 1 and 2 disabled to enforce more
state 0 residency).
These two reports together suggest that executing local_clock() on
multiple CPUs in parallel at a high rate may cause chips to get hot
and trigger thermal/power limits on them to kick in, so reduce the
rate of local_clock() invocations in poll_idle() to avoid that issue.
Fixes: 612f1a22f067 "cpuidle: poll_state: Add time limit to poll_idle()"
Reported-by: Rik van Riel <riel@surriel.com>
Reported-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Rik van Riel <riel@surriel.com>
Reviewed-by: Rik van Riel <riel@surriel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r-- | drivers/cpuidle/poll_state.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c index 68cdc506524b..3f86d23c592e 100644 --- a/drivers/cpuidle/poll_state.c +++ b/drivers/cpuidle/poll_state.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/sched/idle.h> | 10 | #include <linux/sched/idle.h> |
11 | 11 | ||
12 | #define POLL_IDLE_TIME_LIMIT (TICK_NSEC / 16) | 12 | #define POLL_IDLE_TIME_LIMIT (TICK_NSEC / 16) |
13 | #define POLL_IDLE_RELAX_COUNT 200 | ||
13 | 14 | ||
14 | static int __cpuidle poll_idle(struct cpuidle_device *dev, | 15 | static int __cpuidle poll_idle(struct cpuidle_device *dev, |
15 | struct cpuidle_driver *drv, int index) | 16 | struct cpuidle_driver *drv, int index) |
@@ -18,9 +19,14 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev, | |||
18 | 19 | ||
19 | local_irq_enable(); | 20 | local_irq_enable(); |
20 | if (!current_set_polling_and_test()) { | 21 | if (!current_set_polling_and_test()) { |
22 | unsigned int loop_count = 0; | ||
23 | |||
21 | while (!need_resched()) { | 24 | while (!need_resched()) { |
22 | cpu_relax(); | 25 | cpu_relax(); |
26 | if (loop_count++ < POLL_IDLE_RELAX_COUNT) | ||
27 | continue; | ||
23 | 28 | ||
29 | loop_count = 0; | ||
24 | if (local_clock() - time_start > POLL_IDLE_TIME_LIMIT) | 30 | if (local_clock() - time_start > POLL_IDLE_TIME_LIMIT) |
25 | break; | 31 | break; |
26 | } | 32 | } |