mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-24 20:00:22 +00:00
scx_rustland: evaluate the proper vruntime delta
The forumla used to evaluate the weighted time delta is not correct, it's not considering the weight as a percentage. Fix this by using the proper formula. Moreover, take into account also the task weight when evaluating the maximum time delta to account in vruntime and make sure that we never charge a task more than slice_ns. This helps to prevent starvation of low priority tasks. Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
This commit is contained in:
parent
90e92ace2d
commit
2900b208fe
@ -355,11 +355,10 @@ impl<'a> Scheduler<'a> {
|
|||||||
) {
|
) {
|
||||||
// Add cputime delta normalized by weight to the vruntime (if delta > 0).
|
// Add cputime delta normalized by weight to the vruntime (if delta > 0).
|
||||||
if sum_exec_runtime > task_info.sum_exec_runtime {
|
if sum_exec_runtime > task_info.sum_exec_runtime {
|
||||||
let mut delta = sum_exec_runtime - task_info.sum_exec_runtime;
|
let delta = (sum_exec_runtime - task_info.sum_exec_runtime) * 100 / weight;
|
||||||
// Never account more than max_slice_ns. This helps to prevent starving a task for too
|
// Never account more than max_slice_ns. This helps to prevent starving a task for too
|
||||||
// long in the scheduler task pool.
|
// long in the scheduler task pool.
|
||||||
delta = delta.min(max_slice_ns);
|
task_info.vruntime += delta.min(max_slice_ns);
|
||||||
task_info.vruntime += delta / weight;
|
|
||||||
}
|
}
|
||||||
// Make sure vruntime is moving forward (> current minimum).
|
// Make sure vruntime is moving forward (> current minimum).
|
||||||
task_info.vruntime = task_info.vruntime.max(min_vruntime);
|
task_info.vruntime = task_info.vruntime.max(min_vruntime);
|
||||||
|
Loading…
Reference in New Issue
Block a user