Commit ae779300 authored by Mel Gorman's avatar Mel Gorman Committed by Rafael J. Wysocki

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: default avatarMel Gorman <mgorman@suse.de>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent dd38c9d3
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
* The default values do not overflow. * The default values do not overflow.
*/ */
#define BUCKETS 12 #define BUCKETS 12
#define INTERVALS 8 #define INTERVAL_SHIFT 3
#define INTERVALS (1UL << INTERVAL_SHIFT)
#define RESOLUTION 1024 #define RESOLUTION 1024
#define DECAY 8 #define DECAY 8
#define MAX_INTERESTING 50000 #define MAX_INTERESTING 50000
...@@ -227,6 +228,9 @@ static void get_typical_interval(struct menu_device *data) ...@@ -227,6 +228,9 @@ static void get_typical_interval(struct menu_device *data)
max = value; max = value;
} }
} }
if (divisor == INTERVALS)
avg >>= INTERVAL_SHIFT;
else
do_div(avg, divisor); do_div(avg, divisor);
/* Then try to determine standard deviation */ /* Then try to determine standard deviation */
...@@ -238,7 +242,11 @@ static void get_typical_interval(struct menu_device *data) ...@@ -238,7 +242,11 @@ static void get_typical_interval(struct menu_device *data)
stddev += diff * diff; stddev += diff * diff;
} }
} }
if (divisor == INTERVALS)
stddev >>= INTERVAL_SHIFT;
else
do_div(stddev, divisor); do_div(stddev, divisor);
/* /*
* The typical interval is obtained when standard deviation is small * The typical interval is obtained when standard deviation is small
* or standard deviation is small compared to the average interval. * or standard deviation is small compared to the average interval.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment