Kernel patch speeds up Linux

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
eden6000
Posts: 259
Joined: Sun 08 Apr 2007, 06:49

Kernel patch speeds up Linux

#1 Post by eden6000 »

The ~200 Line Linux Kernel Patch That Does Wonders
...The patch being talked about is designed to automatically create task groups per TTY in an effort to improve the desktop interactivity under system strain. Mike Galbraith wrote the patch, which is currently in its third version in recent weeks, after Linus Torvalds inspired this idea. In its third form (patch), this patch only adds 224 lines of code to the kernel's scheduler while stripping away nine lines of code, thus only 233 lines of code are in play.

Tests done by Mike show the maximum latency dropping by over ten times and the average latency of the desktop by about 60 times. Linus Torvalds has already heavily praised (in an email) this miracle patch....

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#2 Post by nooby »

In recent weeks and months there has been quite a bit of work towards improving the responsiveness of the Linux desktop with some very significant milestones building up recently and new patches continuing to come. This work is greatly improving the experience of the Linux desktop when the computer is withstanding a great deal of CPU load and memory strain. Fortunately, the exciting improvements are far from over. There is a new patch that has not yet been merged but has undergone a few revisions over the past several weeks and it is quite small -- just over 200 lines of code -- but it does wonders for the Linux desktop.
Yes in Swedish at the idg.se site but I was too lazy to translate into english and failed to find your text so I waited and there your post came. :)

Looks interesting but it comes in first quarter of 2011 and not in the kernel that is about to get released now?
I use Google Search on Puppy Forum
not an ideal solution though

eden6000
Posts: 259
Joined: Sun 08 Apr 2007, 06:49

#3 Post by eden6000 »

Well...it seems it is due to come out in kernel 2.6.38, so there is sometime to wait....

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#4 Post by jemimah »

Well we can patch it now... open source rocks. ;)

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#5 Post by BarryK »

Very interesting, I wonder if the patch will apply on older kernels, like my 2.6.31.14 used in Wary?
[url]https://bkhome.org/news/[/url]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#6 Post by Flash »

The discussion that follows this article about the new Linux kernel patch seems educational, especially the comments by honeymonster.

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#7 Post by jemimah »

I tried on 2.6.35.7. It's not going to go on easy.

Code: Select all

patch -p1 --dry-run < performance.patch 
patching file include/linux/sched.h
Hunk #1 succeeded at 513 (offset 4 lines).
Hunk #3 succeeded at 1903 (offset -33 lines).
patching file kernel/sched.c
Hunk #1 FAILED at 78.
Hunk #2 succeeded at 611 (offset 5 lines).
Hunk #3 FAILED at 2015.
Hunk #4 succeeded at 7548 (offset -436 lines).
Hunk #5 succeeded at 8509 (offset -5 lines).
Hunk #6 succeeded at 8103 (offset -436 lines).
2 out of 6 hunks FAILED -- saving rejects to file kernel/sched.c.rej
patching file kernel/fork.c
Hunk #1 succeeded at 173 (offset -1 lines).
Hunk #2 succeeded at 903 with fuzz 1 (offset -3 lines).
can't find file to patch at input line 164
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: linux-2.6/drivers/tty/tty_io.c
|===================================================================
|--- linux-2.6.orig/drivers/tty/tty_io.c
|+++ linux-2.6/drivers/tty/tty_io.c
--------------------------

User avatar
dejan555
Posts: 2798
Joined: Sun 30 Nov 2008, 11:57
Location: Montenegro
Contact:

#8 Post by dejan555 »

Wow, sounds cool. Linux can be even faster? :)
puppy.b0x.me stuff mirrored [url=https://drive.google.com/open?id=0B_Mb589v0iCXNnhSZWRwd3R2UWs]HERE[/url] or [url=http://archive.org/details/Puppy_Linux_puppy.b0x.me_mirror]HERE[/url]

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

Attempt at the super miracle patch on Wary k-2.6.31.14

#9 Post by Sit Heel Speak »

BarryK wrote:Very interesting, I wonder if the patch will apply on older kernels, like my 2.6.31.14 used in Wary?
An attempt on your 2.6.31.14 Wary kernel, after adjusting the patch to point not at drivers/tty/tty_io.c but rather where it resides in this older kernel, drivers/char/tty_io.c:

Code: Select all

# pwd
/mnt/sdb2/KERNEL_SOURCE/2.6.31.14 Barry's--experiment with super miracle patch/testbed/usr/src/linux-2.6.31.14
# 
# patch -p1 -N --dry-run < ../the_patch
patching file include/linux/sched.h
Hunk #1 succeeded at 523 (offset 14 lines).
Hunk #2 succeeded at 588 (offset 10 lines).
Hunk #3 succeeded at 1849 (offset -87 lines).
patching file kernel/sched.c
Hunk #1 FAILED at 78.
Hunk #2 FAILED at 606.
Hunk #3 FAILED at 2010.
Hunk #4 FAILED at 7984.
Hunk #5 succeeded at 9788 with fuzz 2 (offset 1274 lines).
Hunk #6 succeeded at 9815 with fuzz 1 (offset 1276 lines).
4 out of 6 hunks FAILED -- saving rejects to file kernel/sched.c.rej
patching file kernel/fork.c
Hunk #1 FAILED at 174.
Hunk #2 succeeded at 871 with fuzz 2 (offset -35 lines).
1 out of 2 hunks FAILED -- saving rejects to file kernel/fork.c.rej
patching file drivers/char/tty_io.c
Hunk #1 succeeded at 3009 (offset -151 lines).
patching file kernel/sched_autogroup.h
patching file kernel/sched_autogroup.c
patching file kernel/sysctl.c
Hunk #1 succeeded at 366 with fuzz 2 (offset -16 lines).
patching file init/Kconfig
Hunk #1 succeeded at 614 with fuzz 2 (offset -114 lines).
patching file Documentation/kernel-parameters.txt
Hunk #1 succeeded at 1558 (offset -64 lines).
# 
sched.c and fork.c are fast-evolving, so to say that this alteration is "just" the 200-or-so-lines patch is misleading. You would need to backport sched.c, fork.c, and who-knows-how-many of their headers.

l0wt3ch

#10 Post by l0wt3ch »

http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html
Alternative To The "200 Lines Kernel Patch That Does Wonders" Which You Can Use Right Away

Phoronix recently published an article regarding a ~200 lines Linux Kernel patch that improves responsiveness under system strain. Well, Lennart Poettering, a RedHat developer replied to Linus Torvalds on a maling list with an alternative to this patch that does the same thing yet all you have to do is run 2 commands and paste 4 lines in your ~/.bashrc file. I know it sounds unbelievable, but apparently someone even ran some tests which prove that Lennart's solution works. Read on!
I'm using this right now on my Ubuntu laptop, and it's working awesome.

The Ubuntu laptop is perfect to test this on, because normally it has trouble playing music and using Firefox at the same time - I very frequently have to turn the volume down for a page to load.

Or, should I say it used to have trouble... :D

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#11 Post by 2lss »

I'm running the patch now with 2.6.37-rc2 on ubuntu lucid

So far its working good, although I wouldn't say its a 10X improvement.

Big Buck Bunny @1080p, Midori, Thunderbird, Gnome Terminal, Bricscad, and glxgears all running at the same time. The video payback was slightly choppy but everything else responded ok.

Keep in mind, this is on a core 2 duo with intel GM965/GL960 video. Not exactly the cream of the crop.

If I get some actual numbers I will post them.

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#12 Post by nooby »

Would be cool to have it in later Luci-238 then?
I use Google Search on Puppy Forum
not an ideal solution though

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

Attempt--k2.6.31.14 alternative script to the miracle patch

#13 Post by Sit Heel Speak »

It seems that one ought *somehow* to apply this alternative script to Puppy. But I know nothing of cgroups, don't know how to apply them.

I have re-compiled the wary 2.6.31.14 kernel with cgroups and configfs activated, as shown in these three screencaps:

http://i53.tinypic.com/21948za.png
http://i51.tinypic.com/j803kh.png
http://i53.tinypic.com/6giohy.png

then have attempted to replicate the commands disclosed at
http://lkml.org/lkml/2010/11/16/392
starting thusly:

Code: Select all

cd /config
mkdir fs
cd fs
mkdir cgroup
cd cgroup
mkdir cpu
cd cpu
mkdir user
cd user
I then attempted to *literally* replicate the next command --not to /sys of course, but to /config, like this:

Code: Select all

# echo $$ > /config/fs/cgroup/cpu/user/$$/tasks
That returned:

Code: Select all

# echo $$ > /config/fs/cgroup/cpu/user/$$/tasks
bash: /config/fs/cgroup/cpu/user/8817/tasks: No such file or directory
and so, taking that as my clue, I then issued

Code: Select all

mkdir 8817
and then

Code: Select all

# echo $$ > /config/fs/cgroup/cpu/user/$$/tasks
which resulted in the file "tasks" being created within /config/fs/cgroup/cpu/user/8817.

I then tried (and got):

Code: Select all

# mount -t cgroup cgroup /sys/fs/cgroup/cpu -o cpu
mount: mount point /sys/fs/cgroup/cpu does not exist
so then tried mounting it under /config, thusly:

Code: Select all

# mount -t cgroup cgroup /config/fs/cgroup/cpu -o cpu
but got the return

Code: Select all

mount: special device cgroup does not exist
, and at this point I'm out of know-how. Can someone tell me how to create special device cgroup?

Anyone have any other ideas?

jogreer
Posts: 22
Joined: Tue 28 Sep 2010, 20:02

cgroup patching puppylinux

#14 Post by jogreer »

Okay, this is how I did it, BUT DO NOTICE THAT mount -t cgroup DOES NOT WORK WITH KERNEL 2.6.33.2! Can someone take a look at implementing cgroup in kernel?

Add the following commands in your /etc/rc.d/rc.local (open it with: geany /etc/rc.d/rc.local) file:

mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent

and make it executable:
chmod +x /etc/rc.d/rc.local

And then add the following to your /root/.bashrc file (to open it: geany /root/.bashrc):

if [ "$PS1" ] ; then
mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi

Run the following command:
geany /usr/local/sbin/cgroup_clean

And paste this:

#!/bin/sh
rm -rf /dev/cgroup/cpu/user/$*

then save the file and make it executable:
chmod +x /usr/local/sbin/cgroup_clean

And finally, restart the computer or manually run the /etc/rc.d/rc.local file ("/etc/rc.d/rc.local").

Run "ls /dev/cgroup/cpu/user/" to see if the different groups are created and running

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#15 Post by amigo »

SHS, what is this /config directory? The stuff needs to go under sysfs because that is where the virtual file system interface is. You need a 'mkdir $$' after cd'ing into: /sysfs/fs/cgroup/cpu/user/
Simpler to just do:
mkdir -p -m700 /config/fs/cgroup/cpu/user/$$
before:
echo $$ > /config/fs/cgroup/cpu/user/$$/tasks

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#16 Post by sc0ttman »

Would this work as a .pet? (using a pinstall.sh script):

Code: Select all

#!/bin/bash
[ ! -e /etc/rc.d/rc.local ] && exit 0

# apply changes in rc.local
echo '
# speedup
mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
"/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent
' >> /etc/rc.d/rc.local

# make rc.local executable
[ ! -x /etc/rc.d/rc.local ] && chmod +x /etc/rc.d/rc.local 

# apply changes in /root/.bashrc
echo '
if [ "$PS1" ] ; then
	mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1
	echo $$ > /dev/cgroup/cpu/user/$$/tasks
	echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi
' >> /root/.bashrc

# create /usr/local/sbin/cgroup_clean if needed
echo '
#!/bin/sh
rm -rf /dev/cgroup/cpu/user/$*
' > /usr/local/sbin/cgroup_clean 

# make it executable
chmod +x /usr/local/sbin/cgroup_clean 

# run it, so its applied immediately
exec /etc/rc.d/rc.local &

REPLY=""
Xdialog --title "Speed up ting" --msgbox "The speed up thing should be installed and running.\n\nDo you want to check?" 0 0
REPLY=$?
[ "$REPLY" = 0 ] && rvxt -e ls /dev/cgroup/cpu/user/ &

exit 0
I'm gonna try it and test :?

EDIT: I get the

Code: Select all

mount:  unknown filesystem type 'cmount'
I'm using kernel 2.6.25.16

:(
Attachments
speedup-installer.pet
the above code, self installer, may work for someone??
(813 Bytes) Downloaded 360 times
Last edited by sc0ttman on Fri 03 Dec 2010, 17:02, edited 4 times in total.

User avatar
DaveS
Posts: 3685
Joined: Thu 09 Oct 2008, 16:01
Location: UK

#17 Post by DaveS »

There is another thread for this here http://murga-linux.com/puppy/viewtopic. ... 178a3bf070
but it is inconclusive
Spup Frugal HD and USB
Root forever!

Post Reply