Os Sched Completely Fair
DodaTech
1 min read
In this tutorial, you'll learn about How to Fix Completely Fair Scheduler vruntime Errors. We cover key concepts, practical examples, and best practices.
Fix completely fair scheduler vruntime errors when time slices managed by vruntime not wall clock.
Quick Fix
Wrong
# Two processes: P1 runs 10ms, goes to sleep. P2 runs while P1 sleeps.
# P1 wakes: CFS gives it smaller time slice because vruntime is behind.
# But: mistaken understanding. CFS uses min_vruntime to keep fairness.
Misunderstanding vruntime. vruntime tracks actual run time. Sleep time doesn't accumulate vruntime.
Right
# CFS tracks vruntime = actual CPU time consumed
# When process sleeps, its vruntime is frozen (not accumulated)
# On wake, vruntime is set to min_vruntime (not left behind)
# So wake-up tasks get priority boost (they get immediate time slice)
# This is why interactive tasks are responsive - their vruntime is reset to min
import os
# Check scheduling stats:
with open(f'/proc/{os.getpid()}/sched') as f:
for line in f:
if 'vruntime' in line or 'se.sum_exec_runtime' in line:
print(line.strip())
vruntime = actual CPU time. Sleep doesn't accumulate vruntime. Wake-up resets to min_vruntime.
Prevention
vruntime tracks actual CPU time consumed. Sleeping processes don't accumulate vruntime.
DodaTech Tools
Doda Browser's algorithm visualizer steps through DSA operations line by line. DodaZIP archives implementation patterns for team sharing. Durga Antivirus Pro detects memory corruption patterns in algorithm implementations.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro