[tip: sched/core] sched/fair: Use full weight to __calc_delta()
From: tip-bot2 for Peter Zijlstra
Date: Tue Feb 24 2026 - 04:19:01 EST
The following commit has been merged into the sched/core branch of tip:
Commit-ID: db4551e2ba346663b7b16f0b5d36d308b615c50e
Gitweb: https://git.kernel.org/tip/db4551e2ba346663b7b16f0b5d36d308b615c50e
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
AuthorDate: Wed, 11 Feb 2026 17:07:58 +01:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Mon, 23 Feb 2026 18:04:10 +01:00
sched/fair: Use full weight to __calc_delta()
Since we now use the full weight for avg_vruntime(), also make
__calc_delta() use the full value.
Since weight is effectively NICE_0_LOAD, this is 20 bits on 64bit.
This leaves 44 bits for delta_exec, which is ~16k seconds, way longer
than any one tick would ever be, so no worry about overflow.
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Reviewed-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Tested-by: Shubhang Kaushik <shubhang@xxxxxxxxxxxxxxxxxxxxxx>
Link: https://patch.msgid.link/20260219080625.183283814%40infradead.org
---
kernel/sched/fair.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2b98054..23315c2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -225,6 +225,7 @@ void __init sched_init_granularity(void)
update_sysctl();
}
+#ifndef CONFIG_64BIT
#define WMULT_CONST (~0U)
#define WMULT_SHIFT 32
@@ -283,6 +284,12 @@ static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight
return mul_u64_u32_shr(delta_exec, fact, shift);
}
+#else
+static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight *lw)
+{
+ return (delta_exec * weight) / lw->weight;
+}
+#endif
/*
* delta /= w