Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Linux

The ~200 Line Linux Kernel Patch That Does Wonders 603

An anonymous reader writes "There is a relatively miniscule patch to the Linux kernel scheduler being queued up for Linux 2.6.38 that is proving to have dramatic results for those multi-tasking on the desktop. Phoronix is reporting the ~200 line Linux kernel patch that does wonders with before and after videos demonstrating the much-improved responsiveness and interactivity of the Linux desktop. While compiling the Linux kernel with 64 parallel jobs, 1080p video playback was still smooth, windows could be moved fluidly, and there was not nearly as much of a slowdown compared to when this patch was applied. Linus Torvalds has shared his thoughts on this patch: So I think this is firmly one of those 'real improvement' patches. Good job. Group scheduling goes from 'useful for some specific server loads' to 'that's a killer feature.'"
This discussion has been archived. No new comments can be posted.

The ~200 Line Linux Kernel Patch That Does Wonders

Comments Filter:
  • by fuzzyfuzzyfungus ( 1223518 ) on Tuesday November 16, 2010 @10:04AM (#34241292) Journal
    They aren't compiling the kernel to see how long it will take(which, as you say, is rarely of all that much interest, few people do it and a fast build-box isn't going to break the budget of a serious project), they are using a multithreaded kernel compilation as an easy way to generate lots of non-interactive system load to see how much that degrades the performance, actual and perceived, of the various interactive tasks of interest to the desktop user.

    This isn't about improving performance of any one specific program; but about making a reasonably heavily-loaded system much more pleasant to use. Compiling the kernel is just a trivial way to generate a large amount of non-interactive CPU load and a bit of disk thrashing...
  • Re:Distros? (Score:5, Informative)

    by Ltap ( 1572175 ) on Tuesday November 16, 2010 @10:08AM (#34241328) Homepage
    Arch Linux: Already in core.

    I exaggerate, but it's not far from the truth - the kernel releases are imported into the testing repository as soon as they come out.
  • by rwa2 ( 4391 ) * on Tuesday November 16, 2010 @10:14AM (#34241388) Homepage Journal

    They mention the "Con Kolvias" scheduler in TFA, but they don't seem to want to refer to it by its real name:

    http://en.wikipedia.org/wiki/Brain_Fuck_Scheduler [wikipedia.org]

    It doesn't scale well past 16 cores, which is why Linus doesn't want to include it in the main kernel. But it's included in custom kernels for mobile devices, such as CyanogenMOD for my Android phone.

  • by 91degrees ( 207121 ) on Tuesday November 16, 2010 @10:19AM (#34241426) Journal
    Typically when you get this sort of speedup, it's by rewriting a tiny piece of code that gets called a lot. Sometimes you can get this sort of thing from a single variable, or for doing something odd like making a variable static.
  • typo (Score:2, Informative)

    by gatzby3jr ( 809590 ) on Tuesday November 16, 2010 @10:19AM (#34241434) Homepage

    While compiling the Linux kernel with 64 parallel jobs, 1080p video playback was still smooth, windows could be moved fluidly, and there was not nearly as much of a slowdown compared to when this patch was applied.

    shouldn't that read "and there was not nearly as much of a slowdown compared to when this patch wasn't applied"?

  • Re:Distros? (Score:3, Informative)

    by Kjella ( 173770 ) on Tuesday November 16, 2010 @10:21AM (#34241464) Homepage

    If you don't care about having it in a release, then the kernel team already has a PPA with all the releases + rcs + daily builds. I would think the next *buntu release (11.04) will have 2.6.37, so you probably won't see this in an official release until october next year...

  • Re:Distros? (Score:4, Informative)

    by marcello_dl ( 667940 ) on Tuesday November 16, 2010 @10:22AM (#34241472) Homepage Journal

    Or whenever YOU choose to install the patched kernel. Freedom at work.

  • by icebraining ( 1313345 ) on Tuesday November 16, 2010 @10:24AM (#34241482) Homepage

    Ubuntu.

    And it'll probably be in Natty Narwhal, which is to be released in April 2011. https://wiki.ubuntu.com/KernelTeam/Specs/KernelNattyVersionAndFlavours [ubuntu.com]

  • by tenchikaibyaku ( 1847212 ) on Tuesday November 16, 2010 @10:26AM (#34241514)
    This is not the scheduler that the grandparent would be referring to though. BFS has been around for about a year, and has as far as I know never actually been pushed for inclusion.

    The previous scheduler that Con wrote was rejected in favor of CFS which is currently in use by the kernel. CFS is at least partly based on ideas from Con, and he was also credited for them.
  • by digitalhermit ( 113459 ) on Tuesday November 16, 2010 @10:45AM (#34241718) Homepage

    I know exactly what the problem is. Try passing different elevator options to the kernel at boot time. It helps with clock skew on virtual environments.

  • by mcvos ( 645701 ) on Tuesday November 16, 2010 @10:57AM (#34241860)

    From what I gather (which isn't a lot, mind you), it's not so much optimizing the execution of an algorithm, but changing what the algorithm actually does. In this case: smarter scheduling.

  • by morgan_greywolf ( 835522 ) on Tuesday November 16, 2010 @10:59AM (#34241894) Homepage Journal

    Yep. For those that haven't tried it without the patch, a multithreaded kernel compile will typically peg a modern multicore CPU at 100% and will even give you drunken mouse syndrome. Just being able to scroll around a browser window while doing a lengthy make -j64 is impressive. Being able to watch 1080p video smoothly is ... astounding. Especially when you consider the minimum CPU requirement for 1080p H.264 playback is a 3 GHz single core or a 2 GHz dual core.

     

  • by ArsenneLupin ( 766289 ) on Tuesday November 16, 2010 @11:11AM (#34242002)
    Maybe this could be improved upon by grouping process by process group (setpgrp), and have the window manager set the pgrp (a different one) for each new app it launches?

    Or better: use a combined key of both tty and pgrp , so that we already see a benefit right now for the compilation example, and benefits later for all other cases (when window manager will start doing this, if they don't already)

    This will still leave the "firefox with many facebook tabs open slows down webmail within firefox" case though, but maybe that case could be solved by taking a baseball bat to Mark Zuckerberg's head :-)

  • by Anonymous Coward on Tuesday November 16, 2010 @11:11AM (#34242008)

    512MB, wow! I wouldn't have guessed something like KDE could even be run on that little. I have 2 GB, and I see the above "endless swapping" problem about once every month or two running KDE 4.5. However, note that you can delay the time between seeing it if you restart KDE every week or so. It leaks memory over time, but restarting it "resets" its memory use, so if I remember to do that, I'll basically never see the swapping problem.

  • by PseudonymousBraveguy ( 1857734 ) on Tuesday November 16, 2010 @11:19AM (#34242100)

    No, you went wrong by confusing "improving the decisions of the scheduler, so that the user experience is improved" with "making the scheduler run faster."

  • Re:teh snappy!!!! (Score:4, Informative)

    by walshy007 ( 906710 ) on Tuesday November 16, 2010 @11:26AM (#34242208)

    Or rather, that there are different priorities.

    The problem was with finer grained scheduling you wound up sacrificing server performance for desktop responsiveness. Linux does not want to sacrifice performance really.

    To be fair I've been using linux on my desktop for over ten years now and even without this patch mostly fail to see an issue.

  • gentle linux restart (Score:1, Informative)

    by Anonymous Coward on Tuesday November 16, 2010 @11:34AM (#34242320)

    alt+sysreq REISUB

    R: keyboard in raw mode
    E: end signal to processes
    I: kill signal
    S: synch filesytems
    U: emergency umount filesystems
    B: reboot

  • Re:Distros? (Score:3, Informative)

    by kangsterizer ( 1698322 ) on Tuesday November 16, 2010 @11:41AM (#34242432)

    What's cool is that Arch is actually pretty stable and works well, yet it's pretty bleeding edge (although to be honest this kernel will be in testing, not stable. probably in stable 2 weeks after 2.6.37 is released)

  • by ArsenneLupin ( 766289 ) on Tuesday November 16, 2010 @11:54AM (#34242640)
    Even a pty has a tty name associated with it, and which tags all processes run from it, and that is all that is needed in this case.

    So no, it doesn't have to be a physical RS232 serial line like in the seventies :-)

  • Re:or, plan B: (Score:1, Informative)

    by Anonymous Coward on Tuesday November 16, 2010 @12:06PM (#34242830)

    Well for many netbook users upgrading ram isn't an option or it is a limited option. I would agree though that swapping to SSD isn't a great idea, really quick way to kill that SSD. though i don't know if swapping to NFS would be a real option on a netbook either where you are usually limited to wifi or 10/100 ethernet. I don't think many netbooks can go gigabit.

    Not a big linux user here, but how does linux cope with running with NO swap space? I know it can be done on windows and once you hit that brick wall you just have to start closing down apps.

  • by Anonymous Coward on Tuesday November 16, 2010 @12:06PM (#34242844)

    See this bug which has made the last 3-4 releases of Ubuntu necessary to reboot daily like Windows ME:

    https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.22/+bug/131094 [launchpad.net]

  • by TheRaven64 ( 641858 ) on Tuesday November 16, 2010 @12:07PM (#34242850) Journal
    Linux has had I/O scheduling for a long time, which ought to address this. In practice, I/O scheduling is actually very hard to get right for nontrivial use cases, so your milage may vary. The real problem is identifying the programs that are 'important' (for some value of important). Windows has (had?) a simple heuristic, where the program with the currently active window got a scheduling boost, but this was problematic when you were running Word in the foreground and Windows Media Player in the background - Word's background spell check would get priority over WMP's video decoder. FreeBSD's ULE scheduler tries to prioritise processes that spend a lot of time blocking for I/O, but again this doesn't help with things like H.264 playback which use lots of CPU, lots of I/O, and really don't want to drop frames.
  • by stiggle ( 649614 ) on Tuesday November 16, 2010 @12:07PM (#34242858)

    Its explained in the BFS FAQ http://ck.kolivas.org/patches/bfs/bfs-faq.txt [kolivas.org]

    Why "Brain Fuck"?

    Because it throws out everything about what we know is good about how to design a modern scheduler in scalability.
    Because it's so ridiculously simple.
    Because it performs so ridiculously well on what it's good at despite being that simple.
    Because it's designed in such a way that mainline would never be interested in adopting it, which is how I like it.
    Because it will make people sit up and take notice of where the problems are in the current design.
    Because it throws out the philosophy that one scheduler fits all and shows that you can do a -lot- better with a scheduler designed for a particular purpose. I don't want to use a steamroller to crack nuts.
    Because it actually means that more CPUs means better latencies.
    Because I must be fucked in the head to be working on this again.
    I'll think of some more becauses later.

  • Re:teh snappy!!!! (Score:5, Informative)

    by TheRaven64 ( 641858 ) on Tuesday November 16, 2010 @12:10PM (#34242926) Journal

    But the fact that Windows and OS X and many other lesser OS have fixed this problem years ago could also be used to show that Open Source is not quite as up on the times as you would like to think.

    Seriously? OS X has absolutely terrible scheduling. A process that causes some swapping will cause beachballs everywhere and can freeze the windowserver for several seconds (well, the mouse keeps moving, but nothing else does). Hell, I have a FreeBSD VM on my Mac that responds better under load than stuff outside of it does.

  • Re:or, plan B: (Score:3, Informative)

    by mcelrath ( 8027 ) on Tuesday November 16, 2010 @12:34PM (#34243346) Homepage

    I believe the parent is talking about the iowait bug #12309 [kernel.org], which, maddeningly, has nothing to do with swap, or filesystem type. You can turn off the swap entirely and still trigger the bug. Of course there are use cases where heavy swapping brings the system down, so there is a perceived improvement by most people when turning off the swap.

  • by Anonymous Coward on Tuesday November 16, 2010 @12:34PM (#34243362)

    > You do a *hard reboot* to recover? Why not just wait a few minutes, or better yet, kill X, firefox or any other process hogging an insane amount of memory and then wait a few minutes before restarting it.

    Because the system becomes all but unresponsive. You can't interact with it enough to kill the processes - that might take half an hour or more. Moving the mouse to another window takes 10 minutes (literally). You can't use an alt-ctrl-F1 style text terminal either because the login times out before you can log in. There is no way to kill the process as you suggest.

    > Don't blame Linux for when your system isn't up to spec.

    I have two gigabytes in my laptop. I cannot upgrade it further.

    If I was the only person with this problem I'd chalk it up to something odd about my system, but there are many others, even other Linux users I know locally who see the same issue. Also note that defects have been filed against this problem by lots of people. It is a real problem. Dismissing it does a disservice to the possible desktop acceptance of Linux.

  • by Anonymous Coward on Tuesday November 16, 2010 @12:41PM (#34243474)

    If you meant to say 1200 bps modems

    Well, if we're going to be really pedantic old-timers, we called it "1200 baud" in those days. ;)

  • Comment removed (Score:2, Informative)

    by account_deleted ( 4530225 ) on Tuesday November 16, 2010 @12:52PM (#34243678)
    Comment removed based on user account deletion
  • by GooberToo ( 74388 ) on Tuesday November 16, 2010 @12:55PM (#34243722)

    BFS makes the classic trade offs which Linus and almost all others absolutely agree is a bad decision for core inclusion. BFS trades performance for latency. Basically you get really good interactive performance in exchange for massively losses in over all throughput and efficiency. Furthermore, BFS sits on a horribly slippery slope in that the level of *inefficiency* scales wonderfully with core count. Basically, the more cores you add, the more time BFS spends BF*cking around.

    Basically BFS only makes sense on single or dual core systems which will primarily be used as a desktop. After that, it better be a dedicated desktop system because compared to the stock kernel, performance is going to royally suck, despite latency being fairly good. But then again, BFS was never really designed to address scalability - its always focused on latency and a superior interactive desktop experience. By most measures it works, but at a heavy cost.

  • Re:windows (Score:4, Informative)

    by WhiteDragon ( 4556 ) on Tuesday November 16, 2010 @01:00PM (#34243786) Homepage Journal

    Was I the only one thinking about Amigas and Alphastations?

    Amigas had so much offloading that you could pull the CPU out and still move the mouse pointer.

  • by Fred Or Alive ( 738779 ) on Tuesday November 16, 2010 @01:08PM (#34243906)

    For instance, it'll be nice to be able to "alt-tab" from one browser tab to another browser tab (so much so that sometimes I open new browser windows just to be able to alt-tab between them).

    Ctrl-Tab.

  • by eln ( 21727 ) on Tuesday November 16, 2010 @01:29PM (#34244272)
    Not all of us had money to keep upgrading our equipment. I was running on a 2400 baud modem until 1995. Of course, I installed Linux on my home box in those days by downloading Slackware to a ton of 3.5" floppy disks at the computer lab at the local university and bringing them all home. If one of the floppies was corrupted, I had to wait until the next day to go back and re-download and copy it.

    I also had to walk 10 miles, in the snow. Uphill both ways.
  • by Beelzebud ( 1361137 ) on Tuesday November 16, 2010 @01:33PM (#34244344)
    I have Arch Linux running on an old single core Athlon based machine, and about two months ago I compiled the Arch kernel to use BFS, because I had heard it was good for the type of machine I was using. My experience pretty much agrees with what you're saying here. I wish I would have read something this honest about it before I bothered to set it all up and compile the kernel.

    At first glance it really seems to improve system responsiveness in regards to user input. However this comes with a gigantic trade off. As an example: If I had a standard definition xvid file playing, the video would literally pause while the system loaded other programs like Firefox, Nautilus, etc. To me that is unacceptable. User input is nice, but if it's choking the entire rest of the system, it isn't something I want to use. The standard scheduler that comes with the kernel might not be perfect, but it will continue playing video while it opens up other apps.
  • by Z00L00K ( 682162 ) on Tuesday November 16, 2010 @01:57PM (#34244728) Homepage Journal

    To continue:

    Baud != bps.

    Baud is modulation changes per second, and in each modulation change there may be a representation of one or more bits which means that the modem may be 1200 baud but you got 9600 bps out of it due to the modulation (phase and amplitude of tone)

    And the old Telebit Trailblazer modems with PEP protocol - they were fantastic in crappy conditions. Multi-carrier technology so that even if there were interference at least a few got through anyway and the only effect was that the bandwidth was quenched. Things to do datacom over barbed wire with! :)

  • by TheLink ( 130905 ) on Tuesday November 16, 2010 @02:17PM (#34245080) Journal
    Nope. Not the same thing, unless you only have two tabs opened.

    alt+tab deals with windows in terms of "most recently used".

    ctrl+tab goes to the next tab in "position". ctrl+shift+tab goes to the previous tab in "position". They don't do "most recently used tab".
  • Re:teh snappy!!!! (Score:3, Informative)

    by TheRaven64 ( 641858 ) on Tuesday November 16, 2010 @02:19PM (#34245110) Journal

    That's pretty bad. On OS X, you used to be able to kill the system by mmap()ing a large file and touching one byte on each page in turn (I had a nice 10-line C program that would kill the system like this). With 10.5, it's a lot better. The system freezes for a few seconds but then it just becomes really slow, rather than dead.

    OS X handles out of memory conditions a lot more gracefully than Linux. When Linux runs out of memory, it kills random processes until it can continue. When OS X almost runs out, it suspends processes and pops up a dialog telling you to close some. The resume button in this dialog doesn't work (yay Apple QA), but you can kill -CONT processes to resume them from the terminal. This is typically enough to kill the errant process that's decided that it needs 10GB of RAM and resume everything else. Basically, apps continue to work until they try to allocate more than a tiny bit more memory from the OS, then they're paused (unless they're on a small list of apps that are excluded from this because they're required to recover, for example the window server).

    OS X doesn't do a terrible job, but to claim that they've solved this problem is a massive overstatement.

  • by wiredlogic ( 135348 ) on Tuesday November 16, 2010 @02:24PM (#34245190)

    If you cut back on the eye candy most distros have in their default desktop environments you'll wipe away any sluggishness. Switching to a simple window manager that doesn't use pixmaps for everything will significantly improve X's performance.

  • Re:teh snappy!!!! (Score:3, Informative)

    by Jah-Wren Ryel ( 80510 ) on Tuesday November 16, 2010 @02:44PM (#34245494)

    (well, the mouse keeps moving, but nothing else does).

    When that happens - MacOS, Linux or Windows, its usually because the mouse driver is interrupt driven and the mouse cursor is drawn by the video card. So the scheduler generally isn't even involved - the mouse generates an interrupt (pausing whatever task is currently scheduled on the cpu), the interrupt handler reads the mouse coordinates and hands them off to the video card, returning the cpu back to the regularly scheduled process and the video card redraws the location of the mouse on the screen.

  • by ZERO1ZERO ( 948669 ) on Tuesday November 16, 2010 @04:25PM (#34247116)
    Tools -- Options --- classic mode (turn off the stupid 'sidebar'), disable thumbs.db creation.

    Windows is so annoying with the sidebar thing if you click a video and then try to delete it it won't let you delete it because it's caching the preview for the sidebar.

  • Re:or, plan B: (Score:5, Informative)

    by jones_supa ( 887896 ) on Tuesday November 16, 2010 @05:47PM (#34248490)

    Turn off swap, if you can. The cost of memory is now less than the cost of the stress and lost uptime due to swap-paralysis.

    Actually even with no swap you will jam Linux when you run out of memory. Things like system libraries get thrown out of memory cache, but are soon needed again and read from the disk. This kind of circus can go on for half a hour until the actual OOM killer gets into the game.

  • by Zero__Kelvin ( 151819 ) on Tuesday November 16, 2010 @08:45PM (#34250302) Homepage

    "You'd think so, but:

    "Initially a Phoronix reader tipped us off this morning of this latest patch. "Please check this out, my desktop will never be the same again, it makes a *lot* of difference for desktop usage (all things smooth, scrolling etc.)...It feels as good as Con Kolivas's patches.

    Emphasis mine. Fuck Linus ..."

    You either missed it, or are conveniently "failing to mention it", but the idea was Linus' to begin with, and he wasn't expected such great results. There are reasons why Con's patches weren't used and this one is used. I'm not about to debate it here, as it has been beaten to death already, and with logic like "fuck Linus" you clearly have me outclassed in any such debate.

  • by LingNoi ( 1066278 ) on Wednesday November 17, 2010 @04:03AM (#34252158)

    It's been fairly well documented but you still seem to ignore the reality of what happened.

    http://kerneltrap.org/node/14008 [kerneltrap.org]

    Read all that then tell me that Linus has an ego here. It seems to me that Linus is the only level headed guy and you're just trying to distort what really happened.

    - He choose CFS over SD because SD behaviour was inconstant among users' computers
    - Con would argue with people sending him problems rather then accept them as problems with his code
    - Linus didn't want code in the kernel that would only work well for certain users
    - Linus didn't want code maintained by someone that was so hostile to others' critique
    - Linus states that he believes the desktop is an important platform

A morsel of genuine history is a thing so rare as to be always valuable. -- Thomas Jefferson

Working...