]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpuidle: menu: Tweak threshold use in get_typical_interval()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 6 Feb 2025 14:25:18 +0000 (15:25 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 25 Feb 2025 11:00:28 +0000 (12:00 +0100)
To prepare get_typical_interval() for subsequent changes, rearrange
the use of the data point threshold in it a bit and initialize that
threshold to UINT_MAX which is more consistent with its data type.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Tested-by: Christian Loehle <christian.loehle@arm.com>
Tested-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Link: https://patch.msgid.link/8490144.T7Z3S40VBb@rjwysocki.net
drivers/cpuidle/governors/menu.c

index ec472af38de6a8d6d64d38ee9cfc7bb3fe864737..680ff20e5528f458838eeb684942f04e0e20e157 100644 (file)
@@ -116,7 +116,7 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev);
  */
 static unsigned int get_typical_interval(struct menu_device *data)
 {
-       unsigned int max, divisor, thresh = INT_MAX;
+       unsigned int max, divisor, thresh = UINT_MAX;
        u64 avg, variance, avg_sq;
        int i;
 
@@ -129,8 +129,8 @@ again:
        for (i = 0; i < INTERVALS; i++) {
                unsigned int value = data->intervals[i];
 
-               /* Discard data points above the threshold. */
-               if (value > thresh)
+               /* Discard data points above or at the threshold. */
+               if (value >= thresh)
                        continue;
 
                divisor++;
@@ -186,7 +186,7 @@ again:
        if ((divisor * 4) <= INTERVALS * 3)
                return UINT_MAX;
 
-       thresh = max - 1;
+       thresh = max;
        goto again;
 }