Skip to content

Commit c6ae271

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) <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 [ Ajay: Modified to apply on v6.12 ] Signed-off-by: Ajay Kaher <ajay.kaher@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 52aa889 commit c6ae271

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

1218912189
static inline bool update_newidle_cost(struct sched_domain *sd, u64 cost)
1219012190
{
12191+
unsigned long next_decay = sd->last_decay_max_lb_cost + HZ;
12192+
unsigned long now = jiffies;
12193+
1219112194
if (cost > sd->max_newidle_lb_cost) {
1219212195
/*
1219312196
* Track max cost of a domain to make sure to not delay the
1219412197
* next wakeup on the CPU.
1219512198
*/
1219612199
sd->max_newidle_lb_cost = cost;
12197-
sd->last_decay_max_lb_cost = jiffies;
12198-
} else if (time_after(jiffies, sd->last_decay_max_lb_cost + HZ)) {
12200+
sd->last_decay_max_lb_cost = now;
12201+
12202+
} else if (time_after(now, next_decay)) {
1219912203
/*
1220012204
* Decay the newidle max times by ~1% per second to ensure that
1220112205
* it is not outdated and the current max cost is actually
1220212206
* shorter.
1220312207
*/
1220412208
sd->max_newidle_lb_cost = (sd->max_newidle_lb_cost * 253) / 256;
12205-
sd->last_decay_max_lb_cost = jiffies;
12206-
12209+
sd->last_decay_max_lb_cost = now;
1220712210
return true;
1220812211
}
1220912212

0 commit comments

Comments
 (0)