summaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2014-08-06 14:19:18 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-08-06 21:17:44 +0200
commitae77930060338226a4377d3b93580c43b5ec82ae (patch)
tree161b93ae479de6e0cea6007e9b01819287cc82fc /drivers/cpuidle
parentdd38c9d35ba8e40011b36659cae2719aefd11904 (diff)
downloadlinux-ae77930060338226a4377d3b93580c43b5ec82ae.tar.bz2
cpuidle: menu: Use shifts when calculating averages where possible
We use do_div even though the divisor will usually be a power-of-two unless there are unusual outliers. Use shifts where possible Signed-off-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/governors/menu.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index c3732fa74f82..c36e1ea7ef08 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -31,7 +31,8 @@
* The default values do not overflow.
*/
#define BUCKETS 12
-#define INTERVALS 8
+#define INTERVAL_SHIFT 3
+#define INTERVALS (1UL << INTERVAL_SHIFT)
#define RESOLUTION 1024
#define DECAY 8
#define MAX_INTERESTING 50000
@@ -227,7 +228,10 @@ again:
max = value;
}
}
- do_div(avg, divisor);
+ if (divisor == INTERVALS)
+ avg >>= INTERVAL_SHIFT;
+ else
+ do_div(avg, divisor);
/* Then try to determine standard deviation */
stddev = 0;
@@ -238,7 +242,11 @@ again:
stddev += diff * diff;
}
}
- do_div(stddev, divisor);
+ if (divisor == INTERVALS)
+ stddev >>= INTERVAL_SHIFT;
+ else
+ do_div(stddev, divisor);
+
/*
* The typical interval is obtained when standard deviation is small
* or standard deviation is small compared to the average interval.