mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-16 01:04:08 +08:00
cpuidle: enter_state: Don't needlessly calculate diff time
Currently, ktime_us_delta() is invoked unconditionally to compute the idle residency of the CPU, but it only makes sense to do that if a valid idle state has been entered, so move the ktime_us_delta() invocation after the entered_state >= 0 check. While at it, merge two comment blocks in there into one and drop a space between type casting of diff. This patch has no functional changes. Signed-off-by: Fieah Lim <kw@fieahl.im> [ rjw: Changelog cleanup, comment format fix ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
6a5f95b5a4
commit
7037b43e00
@ -247,17 +247,17 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
|
|||||||
if (!cpuidle_state_is_coupled(drv, index))
|
if (!cpuidle_state_is_coupled(drv, index))
|
||||||
local_irq_enable();
|
local_irq_enable();
|
||||||
|
|
||||||
diff = ktime_us_delta(time_end, time_start);
|
|
||||||
if (diff > INT_MAX)
|
|
||||||
diff = INT_MAX;
|
|
||||||
|
|
||||||
dev->last_residency = (int) diff;
|
|
||||||
|
|
||||||
if (entered_state >= 0) {
|
if (entered_state >= 0) {
|
||||||
/* Update cpuidle counters */
|
/*
|
||||||
/* This can be moved to within driver enter routine
|
* Update cpuidle counters
|
||||||
|
* This can be moved to within driver enter routine,
|
||||||
* but that results in multiple copies of same code.
|
* but that results in multiple copies of same code.
|
||||||
*/
|
*/
|
||||||
|
diff = ktime_us_delta(time_end, time_start);
|
||||||
|
if (diff > INT_MAX)
|
||||||
|
diff = INT_MAX;
|
||||||
|
|
||||||
|
dev->last_residency = (int)diff;
|
||||||
dev->states_usage[entered_state].time += dev->last_residency;
|
dev->states_usage[entered_state].time += dev->last_residency;
|
||||||
dev->states_usage[entered_state].usage++;
|
dev->states_usage[entered_state].usage++;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user