[PATCH v2] kernel/sched/fair: Fix the issue of virtual runtime conversion error

From: Li kunyu

Date: Wed May 27 2026 - 03:24:21 EST


The logic of the function here should be to convert the virtual runtime
into actual time by combining it with the weight of the scheduling
entity.
However, it cannot be converted by simply converting actual time into
virtual running time. A reverse conversion is required to obtain the
correct time.

Signed-off-by: Li kunyu <likunyu10@xxxxxxx>
---
v2: Use the div64_ul function to perform division operation

kernel/sched/fair.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 69361c63353a..53f3373c1735 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7033,7 +7033,9 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
resched_curr(rq);
return;
}
- delta = (se->load.weight * vdelta) / NICE_0_LOAD;
+
+ if (unlikely(se->load.weight != NICE_0_LOAD))
+ delta = div64_ul(NICE_0_LOAD * vdelta, se->load.weight);

/*
* Correct for instantaneous load of other classes.
--
2.47.3