Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

  1. #1
    Join Date
    Aug 2007
    Beans
    5

    HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Hi all,

    There has been quite a bit of hype about potential 3D and desktop performance with the new Completely Fair Scheduler (CFS), which will be incorporated in kernel version 2.6.23. Word has it that CFS will not be added to Ubuntu Gutsy and some users have expressed disappointment about this decision (http://ubuntuforums.org/showthread.p...&highlight=cfs). I wanted try out this scheduler on my Ubuntu Feisty box, but I didn't find much information on how to go about it. One recent post (http://distrogue.blogspot.com/2007/0...rnel-2623.html) describes how to upgrade to the 2.6.23-rc2 kernel for Ubuntu, but I had serious problems compiling the Nvidia video driver with that kernel and I just want the new scheduler, not all the other changes with 2.6.23 (it's still an unstable kernel, after all).

    Fortunately, Ingo Molnar (CFS's developer) has released a patch file for the 2.6.20 tree. This is a brief HOWTO for compiling the CFS into the current stable Feisty kernel: 2.6.20-16.29. This guide assumes that you have installed and are running the aforementioned kernel (since I copy the config file from it below). If not, you'll need to apt-get install two packages: linux-image-2.6.20-16-generic linux-headers-2.6.20-16-generic. NOTE: I have compiled many kernels over the years (particularly on Gentoo), but it's possible that the instructions below may have inaccuracies and I welcome corrective feedback.

    If you don't want to compile the kernel yourself (which is what is described below), you can download the .deb files that I built. These were compiled against the 2.6.20-16.29 source for Ubuntu Feisty, and the kernel configuration was the same as the current generic kernel (with kernel debugging turned off), so they should be as usable as the existing stock Feisty kernel.

    DISCLAIMER: I accept no liability for the files provided below. They work great on my machine, but I haven't tested them on other computers.

    http://www.michaelhallquist.com/ubun...ustom_i386.deb
    http://www.michaelhallquist.com/ubun...ustom_i386.deb

    To install these .debs, see step 10 below (basically you need to run: sudo dpkg -i <package>).

    Thanks to tseliot for putting together a newbie's kernel compilation guide on Ubuntu (http://ubuntuforums.org/showthread.php?t=56835). This guide is based largely on his documentation. Please read his guide before you jump into adding CFS to your kernel.

    1) Prepare your box for kernel compilation. Follow the aforementioned guide up to the part where you have installed the necessary tools and have unpacked the kernel source. I skipped the xorg.conf modification from tseliot's guide above because I compiled the Nvidia module myself (see step 11 below). Tseliot's guide is a bit out of date, so you won't need gcc-3.4, and the latest source package is called linux-source-2.6.20. If you've done things correctly, you should now have the kernel source available at /usr/src/linux-source-2.6.20.

    2) Obtain the patch from Ingo's site: http://people.redhat.com/mingo/cfs-s...16-v20.4.patch

    (NOTE: there's a slightly newer v20.5 patch, but I haven't tested it and v20.4 is only a few days old)

    3) Move the patch into the kernel source directory and run the patch against the source like so:

    # sudo mv sched-cfs-v2.6.20.16-v20.4.patch /usr/src/linux-source-2.6.20
    # cd /usr/src/linux-source-2.6.20
    # sudo patch -p1 < sched-cfs-v2.6.20.16-v20.4.patch

    4) You'll encounter two errors in the patch. The first is in the /usr/src/linux-source-2.6.20/Makefile and the second is /usr/src/linux-source-2.6.20/kernel/sched.c. These occur because the patch was written for 2.6.20.16 vanilla sources, whereas I think the Ubuntu is a heavily patched 2.6.20.3. You can resolve these simple conflicts yourself (look at Makefile.rej and sched.c.rej) or just download the versions I fixed:

    http://www.michaelhallquist.com/ubuntu-cfs/sched.c
    http://www.michaelhallquist.com/ubuntu-cfs/Makefile

    Replace the old versions with those.

    5) Additionally, the 2.6.20 vanilla sources didn't include a definition for arch_enter_lazy_cpu, but the Ubuntu source does (in include/asm-i386/paravirt.h). Ingo's patch adds a null definition for arch_enter_lazy_cpu (assuming vanilla sources), which results in a duplicate definition. If you compile without fixing the duplication, I think it will work (you'll get lots of warnings), but I would instead just comment out line 118 of the post-patch file /usr/src/linux-source-2.6.20/include/linux/sched.h. This line is:

    #define arch_enter_lazy_cpu_mode() do { } while (0)

    Again, the corrected file can be pulled from:

    http://www.michaelhallquist.com/ubuntu-cfs/sched.h

    6) Okay, now the source is in good shape to compile. Make sure the source is cleaned of object files and any old config files:

    # cd /usr/src/linux-source-2.6.20
    # sudo make-kpkg clean
    # sudo rm .config .config.old

    7) I didn't want to compile from scratch and wanted to stay close to the stock kernel, so I imported the 2.6.20-16-generic config like so:

    # sudo cp /boot/config-2.6.20-16-generic /usr/src/linux-source-2.6.20/.config

    8) By default, Ubuntu has kernel debugging turned on in the config, which makes the kernel and modules much bigger than they need to be (see also https://wiki.ubuntu.com/KernelCustomBuild). So turn that off. Run sudo make menuconfig, go under "Kernel Hacking" and turn off "Kernel debugging." You can also alter your config while you're in there to turn off SMP, compile just for your architecture, and so on... but that's beyond the scope of this discussion. Or, you can get the config file I used from:

    http://www.michaelhallquist.com/ubun...untu-cfs-v20.4

    9) Okay, now we're ready to compile. Create the .debs for the image and headers following tseliot's guide:

    # sudo make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers

    (you can omit the --append-to-version portion if you like or change it to whatever suits you)

    10) Once it compiles (it may take a while), there should be two debs in the /usr/src directory. Mine were called:

    linux-image-2.6.20.16-ubuntu-cfs-v20.4_2.6.20.16-ubuntu-cfs-v20.4-10.00.Custom_i386.deb
    linux-headers-2.6.20.16-ubuntu-cfs-v20.4_2.6.20.16-ubuntu-cfs-v20.4-10.00.Custom_i386.deb

    Whatever yours are called, install the debs with:

    # sudo dpkg -i linux-image-<name here>.deb
    # sudo dpkg -i linux-headers-<name here>.deb

    11) (FOR NVIDIA CARD BINARY DRIVER USERS ONLY) Now, with luck, the new kernel and headers are installed. But wait! I run an Nvidia graphics card and I need a module compiled against the new kernel (If you reboot before you make the module, X windows will not start, which may be uncomfortable for those not used to a command line interface). I have no clue about ATI, so you're on your own if you have an ATI card. You'll need the nvidia-kernel-source package installed. This will give you the /usr/src/nvidia-kernel-source.tar.gz archive. Extract that and compile a module against the new kernel like so:

    # cd /usr/src
    # sudo tar xf nvidia-kernel-source.tar.gz
    # cd modules/nvidia-kernel/nv
    # SYSSRC=/usr/src/linux-headers-2.6.20.16-ubuntu-cfs-v20.4/ make module install

    Note that the SYSSRC argument above must be set to wherever your kernel source headers were installed from step 10. Now, the new module should be installed in the proper /lib/modules directory. If you do get stranded at a CLI without the driver, login, then type:

    # sudo apt-get remove nvidia-glx
    # sudo apt-get install nvidia-glx
    # sudo /etc/init.d/gdm restart

    This should get the driver up and running for you.

    12) Reboot the computer and choose the new CFS-based kernel (should have cfs-v20.4 at the end)! The new kernel worked great for me and I've had no problems. I haven't observed drastic responsiveness improvements over the old scheduler, but I haven't really put the kernel through its paces, either. You can verify that CFS is running by looking in the /proc/sys/kernel directory. If you have CFS running, you'll see something like this:

    # ls /proc/sys/kernel

    sched_batch_wakeup_granularity_ns sched_features sched_min_granularity_ns sched_stat_granularity_ns
    sched_child_runs_first sched_latency_ns sched_runtime_limit_ns sched_wakeup_granularity_ns

    All those sched parameters are for CFS. I don't know what tweaking them would do, so I'd leave it at the default for now.

    I hope this guide proves useful to others interested in trying out the new Completely Fair Scheduler!

    - Michael
    Last edited by volsungs; September 5th, 2007 at 01:46 PM. Reason: added sudo to patch command

  2. #2
    Join Date
    Aug 2007
    Beans
    5

    Re: Compiling CFS for 2.6.22 kernel

    Several people have expressed interest in compiling CFS into the 2.6.22 branch, which is currently being tested for Ubuntu Gutsy Gibbon. The following information updates the above HOWTO by patching a 2.6.22 kernel with CFS.

    For those who prefer to use precompiled packages, rather than compiling their own, I have provided .deb files for the 2.6.22-cfs kernel here. These were compiled against the 2.6.22.4 source for Ubuntu Gutsy, and the kernel configuration was the same as the Gutsy generic kernel (with kernel debugging turned off), so they should be as usable as the existing stock Gutsy kernel.

    DISCLAIMER: I accept no liability for the files provided below. They work great on my machine, but I haven't tested them on other computers.

    http://www.michaelhallquist.com/ubun...-cfs-v20.5.deb
    http://www.michaelhallquist.com/ubun...-cfs-v20.5.deb


    1) Obtain the latest 2.6.22 kernel source

    # sudo gedit /etc/apt/sources.list

    Insert the following line at the bottom and save the file:

    deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted

    Then run:

    # sudo apt-get update
    # sudo apt-get install linux-source-2.6.22
    # cd /usr/src
    # tar xf linux-source-2.6.22.tar.bz2

    2) Remove the Gutsy packages from your deb sources (i.e., get rid of the line you inserted above)

    # sudo gedit /etc/apt/sources.list
    # sudo apt-get update

    NOTE: It's important to remove the gutsy sources. Otherwise, you'll get notifications to update many packages and you'll end up running Gutsy, which is not yet ready for prime time.

    3) Obtain the CFS patch for 2.6.22 tree: http://people.redhat.com/mingo/cfs-s....5-v20.5.patch

    4) Move the patch into the source tree and perform the patch:

    # sudo mv sched-cfs-v2.6.22.5-v20.5.patch /usr/src/linux-source-2.6.22
    # cd /usr/src/linux-source-2.6.22
    # sudo patch -p1 < sched-cfs-v2.6.22.5-v20.5.patch

    5) Two rejections will occur: the first is /usr/src/linux-source-2.6.22/Makefile and the second is /usr/src/linux-source-2.6.22/arch/sparc64/kernel/smp.c. You can resolve these yourself or download the fixed files here:

    http://www.michaelhallquist.com/ubun....6.22/Makefile
    http://www.michaelhallquist.com/ubuntu-cfs/2.6.22/smp.c

    Replace the old versions with those files.

    6) Obtain the proper 2.6.22 config file from my site. I used the config from Gutsy's default 2.6.22-generic kernel. As in the previous guide, kernel debugging was turned off.

    http://www.michaelhallquist.com/ubun...untu-cfs-v20.5

    Move the file into place:

    # sudo mv config-2.6.22-ubuntu-cfs-v20.5 /usr/src/linux-source-2.6.22/.config

    7) Follow steps 9 and 10 from the previous guide to compile the kernel. Of course, make sure to type in the commands for 2.6.22, not 2.6.20. If all goes well, the 2.6.22 kernel with CFS should be up and running!

    As for Nvidia drivers for the 2.6.22 kernel, I had the best luck downloading and running the latest package directly from Nvidia.

    http://www.nvidia.com/object/unix.html

    Check out this thread for more driver details. http://ubuntuforums.org/showthread.php?p=2587126

    That's it for the 2.6.22 kernel.

    - Michael

  3. #3
    Join Date
    Nov 2005
    Location
    Cambridge, UK
    Beans
    22
    Distro
    Gutsy Gibbon Testing

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Absolutly amazing!! my old hardware (thinkpad 600e - PII 366) feels so much more responive, menus open smoothly, firefox can still scroll while somthing else is eating the cpu, mp3 and ogg dosn't skip when somthing hits the cpu any more, its just superb
    I wish this could make it i to GG, I was sceptical before, but now i've tryed it on this old hardware i'm convinved this is a special cas and should be seriously consiered for GG.
    As a (poor) fix for this maby somone with the know-how will post up an unofficial repository with the patched kerneal kept up to date, the same way others have for compiz, etc in the past?

    Thanks for makin it easy for me to try this, i'm liking what i see!

  4. #4
    Join Date
    Jun 2007
    Location
    In a dark room
    Beans
    94
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    haven't had the time yet to do the problem solving i normally do but
    i managed to get to step 4b on the gutsy install and it couldn't find the directory.
    So i used both debs and i now have about 4 different kernel boot options cfs 22-10 22-15 and 22-16. i've tried installing nvidia drivers on cfs and 22-10 and it hasn't worked, but i'll post back after i tried some more stuff, i just cant right now.

  5. #5
    Join Date
    Mar 2005
    Location
    Kuala Lumpur, Malaysia
    Beans
    54

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Hi, tried to install using the debs you provided. Manage to install the header and image but I got stuck when I tried to install the header for my nvidia driver at the SYSSRC part. I got the error below:
    Code:
    vassalle@vassalle-desktop:/usr/src/modules/nvidia-kernel/nv$ SYSSRC=/usr/src/linux-headers-2.6.22.4-cfs-v20.5/ make module install
    ./conftest.sh: 946: cannot create conftest6297.c: Permission denied
    
    The C compiler 'cc' does not appear to be able to
    create executables.  Please make sure you have 
    your Linux distribution's gcc and libc development
    packages installed.
    
    *** Failed CC sanity check. Bailing out! ***
    
    make: *** [select_makefile] Error 1
    I've installed the required tools as per tselliot's howto. What else am i missing?

    Thanks.

  6. #6
    Join Date
    Aug 2007
    Beans
    5

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Code:
    vassalle@vassalle-desktop:/usr/src/modules/nvidia-kernel/nv$ SYSSRC=/usr/src/linux-headers-2.6.22.4-cfs-v20.5/ make module install
    ./conftest.sh: 946: cannot create conftest6297.c: Permission denied
    
    The C compiler 'cc' does not appear to be able to
    create executables.  Please make sure you have 
    your Linux distribution's gcc and libc development
    packages installed.
    
    *** Failed CC sanity check. Bailing out! ***
    
    make: *** [select_makefile] Error 1

    Hi Vassalle,

    Make sure you run the command with sudo, like so:

    # SYSSRC=/usr/src/linux-headers-2.6.22.4-cfs-v20.5 sudo make module install

    With the 2.6.22 kernel, I had really good luck with the installer from Nvidia. Download the installer from here: http://www.nvidia.com/object/unix.html. Then run it with:

    sudo sh NVIDIA-package-name.run

    Give those two things a try -- I think one or the other should get you a working Nvidia module.

  7. #7
    Join Date
    Mar 2005
    Location
    Kuala Lumpur, Malaysia
    Beans
    54

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Will try with Sudo later.

    Anyway, I have already installed my Nvidia driver using the installer from Nvidia and it's working perfectly on the stock gutsy kernel (w/out the CFS). Just need to sort out the SYSSRC problem.

    Thanks for your effort. Very much appreciate it, even more so when I can run a CFS patched kernel!

  8. #8
    Join Date
    Jun 2007
    Location
    In a dark room
    Beans
    94
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    got the driver working on cfs(with more than a couple errors but everything went fine)
    Though my problem is its now like i've zoomed out all the text is smaller, as well a pictures, its very annoying.

    edit: well the problems seems fixed after an amd x.org update in update manager and a subsequent reinstall of the driver.
    Last edited by Nigmah; September 7th, 2007 at 04:01 AM.

  9. #9
    Join Date
    Aug 2007
    Beans
    5

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Quote Originally Posted by vassalle View Post
    Will try with Sudo later.

    Anyway, I have already installed my Nvidia driver using the installer from Nvidia and it's working perfectly on the stock gutsy kernel (w/out the CFS). Just need to sort out the SYSSRC problem.

    Thanks for your effort. Very much appreciate it, even more so when I can run a CFS patched kernel!
    Hi Vassalle,

    If you've gotten the Nvidia module working on the stock Gutsy kernel, all you need to do is boot up using the new CFS kernel, wait for gdm to bomb out, log in at the command line, and run the Nvidia installer like so:

    sudo sh NVIDIA-packagenamehere.run

    That will compile the module and insert it into the kernel. Then type:

    sudo /etc/init.d/gdm restart

    And you should have the module up and running for the CFS kernel. Basically, even though you used the installer for the stock kernel, it only compiled for that kernel (in the appropriate /lib/modules folder), but not for the new CFS kernel. Anyway, give that a try.

  10. #10
    Join Date
    May 2007
    Beans
    10

    Re: HOWTO: Compiling Feisty Kernel with Completely Fair Scheduler (CFS)

    Just tried the 2.6.20 kernel, works fantastically. The audio output from last.fm radio no longer skips, adobe acroread no longer causes my machine to crawl when it (inevitably) screws up etc... Thanks!

    Only one nitpick, I couldn't get the framebuffer to work eg vga=0x318 kernel boot option fails.

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •