Skip to content

Commit d4ffb9c

Browse files
Peter Zijlstragregkh
authored andcommitted
sched/fair: Small cleanup to update_newidle_cost()
commit 08d473d upstream. Simplify code by adding a few variables. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Dietmar Eggemann <[email protected]> Tested-by: Dietmar Eggemann <[email protected]> Tested-by: Chris Mason <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c7ca7e0 commit d4ffb9c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

kernel/sched/fair.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12124,22 +12124,25 @@ void update_max_interval(void)
1212412124

1212512125
static inline bool update_newidle_cost(struct sched_domain *sd, u64 cost)
1212612126
{
12127+
unsigned long next_decay = sd->last_decay_max_lb_cost + HZ;
12128+
unsigned long now = jiffies;
12129+
1212712130
if (cost > sd->max_newidle_lb_cost) {
1212812131
/*
1212912132
* Track max cost of a domain to make sure to not delay the
1213012133
* next wakeup on the CPU.
1213112134
*/
1213212135
sd->max_newidle_lb_cost = cost;
12133-
sd->last_decay_max_lb_cost = jiffies;
12134-
} else if (time_after(jiffies, sd->last_decay_max_lb_cost + HZ)) {
12136+
sd->last_decay_max_lb_cost = now;
12137+
12138+
} else if (time_after(now, next_decay)) {
1213512139
/*
1213612140
* Decay the newidle max times by ~1% per second to ensure that
1213712141
* it is not outdated and the current max cost is actually
1213812142
* shorter.
1213912143
*/
1214012144
sd->max_newidle_lb_cost = (sd->max_newidle_lb_cost * 253) / 256;
12141-
sd->last_decay_max_lb_cost = jiffies;
12142-
12145+
sd->last_decay_max_lb_cost = now;
1214312146
return true;
1214412147
}
1214512148

0 commit comments

Comments
 (0)