Skip to content

Commit 08d473d

Browse files
author
Peter Zijlstra
committed
sched/fair: Small cleanup to update_newidle_cost()
Simplify code by adding a few variables. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Tested-by: Chris Mason <clm@meta.com> Link: https://patch.msgid.link/20251107161739.655208666@infradead.org
1 parent e78e70d commit 08d473d

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
@@ -12226,22 +12226,25 @@ void update_max_interval(void)
1222612226

1222712227
static inline bool update_newidle_cost(struct sched_domain *sd, u64 cost)
1222812228
{
12229+
unsigned long next_decay = sd->last_decay_max_lb_cost + HZ;
12230+
unsigned long now = jiffies;
12231+
1222912232
if (cost > sd->max_newidle_lb_cost) {
1223012233
/*
1223112234
* Track max cost of a domain to make sure to not delay the
1223212235
* next wakeup on the CPU.
1223312236
*/
1223412237
sd->max_newidle_lb_cost = cost;
12235-
sd->last_decay_max_lb_cost = jiffies;
12236-
} else if (time_after(jiffies, sd->last_decay_max_lb_cost + HZ)) {
12238+
sd->last_decay_max_lb_cost = now;
12239+
12240+
} else if (time_after(now, next_decay)) {
1223712241
/*
1223812242
* Decay the newidle max times by ~1% per second to ensure that
1223912243
* it is not outdated and the current max cost is actually
1224012244
* shorter.
1224112245
*/
1224212246
sd->max_newidle_lb_cost = (sd->max_newidle_lb_cost * 253) / 256;
12243-
sd->last_decay_max_lb_cost = jiffies;
12244-
12247+
sd->last_decay_max_lb_cost = now;
1224512248
return true;
1224612249
}
1224712250

0 commit comments

Comments
 (0)