Merge pull request #336 from sched-ext/rustland-max-time-slice-limit

scx_rustland: never use a time slice that exceeds the default value
This commit is contained in:
Andrea Righi 2024-06-06 18:34:10 +02:00 committed by GitHub
commit def1ad2947
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -534,7 +534,8 @@ impl<'a> Scheduler<'a> {
// Moreover, ensure that the time slice is never less than 0.25 ms to prevent
// excessive penalty from assigning time slices that are too short and reduce
// context switch overhead.
let slice_ns = (task.vruntime - self.min_vruntime).max(NSEC_PER_MSEC / 4);
let slice_ns =
(task.vruntime - self.min_vruntime).clamp(NSEC_PER_MSEC / 4, self.slice_ns);
// Update global minimum vruntime.
self.min_vruntime = task.vruntime;