he wrote the 100K patch in 62 hours
Linux: The Completely Fair Scheduler
April 18, 2007 – 5:51am
Submitted by Jeremy on April 18, 2007 – 5:51am.
Linux news
Ingo Molnar [interview] released a new patchset titled the “Modular Scheduler Core and Completely Fair Scheduler”. He explained, “this project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.” The patchset introduces Scheduling Classes, “an extensible hierarchy of scheduler modules. These modules encapsulate scheduling policy details and are handled by the scheduler core without the core code assuming about them too much.” It also includes sched_fair.c with an implementation of the CFS desktop scheduler, “a replacement for the vanilla scheduler’s SCHED_OTHER interactivity code,” about which Ingo noted, “I’d like to give credit to Con Kolivas [interview] for the general approach here: he has proven via RSDL/SD that ‘fair scheduling’ is possible and that it results in better desktop scheduling. Kudos Con!”
Regarding the actual implementation, Ingo explained, “CFS’s design is quite radical: it does not use runqueues, it uses a time-ordered rbtree to build a ‘timeline’ of future task execution, and thus has no ‘array switch’ artifacts (by which both the vanilla scheduler and RSDL/SD are affected). CFS uses nanosecond granularity accounting and does not rely on any jiffies or other HZ detail. Thus the CFS scheduler has no notion of ‘timeslices’ and has no heuristics whatsoever. There is only one central tunable, /proc/sys/kernel/sched_granularity_ns, which can be used to tune the scheduler from ‘desktop’ (low latencies) to ’server’ (good batching) workloads.” He went on to note, “due to its design, the CFS scheduler is not prone to any of the ‘attacks’ that exist today against the heuristics of the stock scheduler”.
During the followup discussion, Ingo explained that he wrote the 100K patch in 62 hours. In response to concerns that his efforts had not been discussed first on the Linux Kernel Mailing List, Ingo explained, “I prefer such early releases to lkml _alot_ more than any private review process. I released the CFS code about 6 hours after i thought ‘okay, this looks pretty good” and i spent those final 6 hours on testing it (making sure it doesnt blow up on your box, etc.), in the final 2 hours i showed it to two folks i could reach on IRC (Arjan and Thomas) and on various finishing touches.” He went on to add, “the ‘design consultation’ phase you are talking about is _NOW_! ” Later in the discussion that touched on egos, Linux creator Linus Torvalds noted, “one of the most motivating things there *is* in open source is ‘personal pride’,” going on to add, “it’s a really good thing, and it means that if somebody shows that your code is flawed in some way (by, for example, making a patch that people claim gets better behaviour or numbers), any *good* programmer that actually cares about his code will obviously suddenly be very motivated to out-do the out-doer!”