Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 017099e2 authored by Tuukka Tikkanen's avatar Tuukka Tikkanen Committed by Rafael J. Wysocki
Browse files

cpuidle: Rearrange code and comments in get_typical_interval()



This patch rearranges a if-return-elsif-goto-fi-return sequence into
if-return-fi-if-return-fi-goto sequence. The functionality remains the
same. Also, a lengthy comment that did not describe the functionality
in the order it occurs is split into half and top half is moved closer
to actual implementation it describes.

Signed-off-by: default avatarTuukka Tikkanen <tuukka.tikkanen@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 330647a9
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -228,14 +228,6 @@ static void get_typical_interval(struct menu_device *data)
	do_div(stddev, divisor);
	stddev = int_sqrt(stddev);
	/*
	 * If we have outliers to the upside in our distribution, discard
	 * those by setting the threshold to exclude these outliers, then
	 * calculate the average and standard deviation again. Once we get
	 * down to the bottom 3/4 of our samples, stop excluding samples.
	 *
	 * This can deal with workloads that have long pauses interspersed
	 * with sporadic activity with a bunch of short pauses.
	 *
	 * The typical interval is obtained when standard deviation is small
	 * or standard deviation is small compared to the average interval.
	 *
@@ -246,13 +238,23 @@ static void get_typical_interval(struct menu_device *data)
		if (data->expected_us > avg)
			data->predicted_us = avg;
		return;
	}

	/*
	 * If we have outliers to the upside in our distribution, discard
	 * those by setting the threshold to exclude these outliers, then
	 * calculate the average and standard deviation again. Once we get
	 * down to the bottom 3/4 of our samples, stop excluding samples.
	 *
	 * This can deal with workloads that have long pauses interspersed
	 * with sporadic activity with a bunch of short pauses.
	 */
	if ((divisor * 4) <= INTERVALS * 3)
		return;

	} else if ((divisor * 4) > INTERVALS * 3) {
		/* Exclude the max interval */
	thresh = max - 1;
	goto again;
}
}

/**
 * menu_select - selects the next idle state to enter