[PATCH] kernel/sched/fair: Fix to not require calculation for the weight nice0

From: Li kunyu

Date: Thu May 28 2026 - 22:39:30 EST


Typically, the default priority for client tasks is nice0, and reducing
the conversion of virtual runtime to real time for nice0 tasks can
significantly reduce unnecessary computations.

Signed-off-by: Li kunyu <likunyu10@xxxxxxx>
---
kernel/sched/fair.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 69361c63353a..74d1c77a8bcf 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7033,7 +7033,10 @@ 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 = (se->load.weight * vdelta) / NICE_0_LOAD;
+ else
+ delta = vdelta;

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