Repository navigation
Expand file tree
/
Copy pathfix_util_avg_jump.patch
More file actions
56 lines (52 loc) · 2.11 KB
/
Copy pathfix_util_avg_jump.patch
File metadata and controls
56 lines (52 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 8fbd03042d00267651bb1f1ce74844ff5b29d9f4 Mon Sep 17 00:00:00 2001
From: Tingjia-0v0 <tjcao980311@gmail.com>
Date: Fri, 10 Apr 2026 14:56:14 -0500
Subject: [PATCH] fix_util_avg_jump
---
kernel/sched/pelt.h | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h
index f921302dc40f..0134883b0676 100644
--- a/kernel/sched/pelt.h
+++ b/kernel/sched/pelt.h
@@ -139,20 +139,31 @@ static inline void update_idle_rq_clock_pelt(struct rq *rq)
{
u32 divider = ((LOAD_AVG_MAX - 1024) << SCHED_CAPACITY_SHIFT) - LOAD_AVG_MAX;
u32 util_sum = rq->cfs.avg.util_sum;
+ unsigned long compute_ratio;
+ u32 threshold;
+ u64 gap;
util_sum += rq->avg_rt.util_sum;
util_sum += rq->avg_dl.util_sum;
/*
- * Reflecting stolen time makes sense only if the idle
- * phase would be present at max capacity. As soon as the
- * utilization of a rq has reached the maximum value, it is
- * considered as an always running rq without idle time to
- * steal. This potential idle time is considered as lost in
- * this case. We keep track of this lost idle time compare to
- * rq's clock_task.
+ * Preserve a proportional part of the clock_task/clock_pelt gap once
+ * the rq utilization exceeds the amount already implied by the current
+ * compute ratio. This smooths the lost_idle_time update for partially
+ * busy rq's while still preserving the full gap at saturation.
*/
- if (util_sum >= divider)
- rq->lost_idle_time += rq_clock_task(rq) - rq->clock_pelt;
+ compute_ratio = arch_scale_cpu_capacity(cpu_of(rq));
+ compute_ratio = cap_scale(compute_ratio, arch_scale_freq_capacity(cpu_of(rq)));
+ threshold = mult_frac(divider, compute_ratio, SCHED_CAPACITY_SCALE);
+ gap = rq_clock_task(rq) - rq->clock_pelt;
+
+ if (util_sum > threshold && threshold < divider) {
+ u32 preserve_num = min_t(u32, util_sum, divider) - threshold;
+ u32 preserve_den = divider - threshold;
+
+ rq->lost_idle_time += mult_frac(gap, preserve_num, preserve_den);
+ } else if (util_sum >= divider) {
+ rq->lost_idle_time += gap;
+ }
_update_idle_rq_clock_pelt(rq);
}
--
2.43.0