Linux scheduler bug got you down? Here's a fast fix

Bugs in the Linux scheduler can cause performance degradation in heavily multithreaded loads, but a do-it-yourself fix is available

Linux scheduler bug got you down? Here's a fast fix

The Linux kernel scheduler has deficiencies that prevent a multicore system from making proper use of all cores for heavily multithreaded loads, according to a lecture and paper delivered earlier this month at the EuroSys '16 conference in London,

If you're running applications that might be affected and would rather not wait for a fix from the kernel team, a patch is available in a script provided by a third party.

The paper, titled "The Linux Scheduler: a Decade of Wasted Cores," was authored by a sextet of researchers from the University of British Columbia and four other institutions. It describes four bugs in the kernel scheduler that cause some CPU cores to remain idle even when runnable threads are waiting to be dispatched to a core.

"Resulting performance degradations are in the range 13-24% for typical Linux workloads," the researchers say, "and reach 138× in some corner cases."

linux scheduler bug

CPU activity in a Linux system affected by the scheduler bug. The graph on the left shows two cores not receiving a fair allotment of threads due to the bug. The graph on the right shows the CPU after applying the fix suggested by the researchers.

The bug does not affect desktop users. As noted in a discussion thread on Hacker News, the issue involves complexities that arise when using the Linux scheduler on multiprocessor systems. The algorithm used by the scheduler to balance the load across cores fails in certain circumstances -- for instance, when a thread that was previously asleep is awakened on an overloaded core, while other cores are not in use.

The paper describes one test with apps written in the R language that hints at how the problem might arise when doing math and statistical work in multicore Linux environments.

Such bugs don't always announce their presence with a crash or a hang, but rather via degraded performance, so they aren't always obvious, the researchers say.

The patches suggested by the researchers don't appear to have been submitted yet to the Linux kernel maintainers. But those running heavy multicore loads on Ubuntu can apply the patches immediately with a script available on GitHub. The script obtains the dependencies needed to build the kernel, applies the needed patches, and gives the option to either install the kernel then and there or build it into a .deb package for use elsewhere.

Copyright © 2016 IDG Communications, Inc.

How to choose a low-code development platform