[转载]200+行内核补丁的替代方案
- hakie
- 帖子: 270
- 注册时间: 2008-04-30 12:14
[转载]200+行内核补丁的替代方案
前几天有报道称,200+行的Kernel补丁能显著改善桌面性能,降低延迟。Red Hat的开发者Lennart Poettering在邮件列表上回复Linus Torvalds时称,他有一个替代方案,只需运行两次命令,在~/.bashrc文件中粘贴4行代码就可实现相同的效果。 Ubuntu发行版的使用指南:
1.用"/dev"替换"/sys/fs";在 /etc/rc.local文件中的exit 0上面中加入以下命令:
mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
echo "1" > /dev/cgroup/cpu/user/notify_on_release
echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent
2.执行:sudo chmod +x /etc/rc.local
3.在~/.bashrc文件中加入以下代码:
if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
fi
4.运行命令:sudo gedit /usr/local/sbin/cgroup_clean
5.粘贴代码:
#!/bin/sh
rmdir /dev/cgroup/cpu/$1
6.保存文件,执行命令:sudo chmod +x /usr/local/sbin/cgroup_clean
7.重启电脑。
以上转自Solidot.
1.用"/dev"替换"/sys/fs";在 /etc/rc.local文件中的exit 0上面中加入以下命令:
mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
echo "1" > /dev/cgroup/cpu/user/notify_on_release
echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent
2.执行:sudo chmod +x /etc/rc.local
3.在~/.bashrc文件中加入以下代码:
if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
fi
4.运行命令:sudo gedit /usr/local/sbin/cgroup_clean
5.粘贴代码:
#!/bin/sh
rmdir /dev/cgroup/cpu/$1
6.保存文件,执行命令:sudo chmod +x /usr/local/sbin/cgroup_clean
7.重启电脑。
以上转自Solidot.
Archlinux+FVWM
虽然没技术折腾,但一直在默默折腾。
虽然没技术折腾,但一直在默默折腾。
- Ubuntu与Linux
- 帖子: 1211
- 注册时间: 2010-06-09 19:57
- hcym
- 帖子: 15634
- 注册时间: 2007-05-06 2:46
- jarryson
- 帖子: 4002
- 注册时间: 2005-08-14 19:53
Re: [转载]200+行内核补丁的替代方案
像我是使用bfs,是禁用cgroups的,所以这个方法对我无效。而是使用ck提供的schedtool。貌似效果不错
- photor
- 论坛版主
- 帖子: 11004
- 注册时间: 2008-04-26 12:41
- 扭曲杰
- 帖子: 528
- 注册时间: 2010-03-24 10:33
Re: [转载]200+行内核补丁的替代方案
有哪位同学试试? 

-
- 帖子: 130
- 注册时间: 2007-06-13 9:36
- 系统: ubuntuunity
Re: [转载]200+行内核补丁的替代方案
楼主的脚本有bug
1.在 /etc/rc.local文件中的exit 0上面中加入以下命令:
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
2.执行:sudo chmod +x /etc/rc.local
3.在~/.bashrc文件中加入以下代码:
if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi
4.运行命令:sudo gedit /usr/local/sbin/cgroup_clean
5.粘贴代码:
#!/bin/sh
rmdir /dev/cgroup/cpu/$*
6.保存文件,执行命令:sudo chmod +x /usr/local/sbin/cgroup_clean
7.重启电脑。
ubuntu 10.04 kernel 2.6.36 测试通过
1.在 /etc/rc.local文件中的exit 0上面中加入以下命令:
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
2.执行:sudo chmod +x /etc/rc.local
3.在~/.bashrc文件中加入以下代码:
if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi
4.运行命令:sudo gedit /usr/local/sbin/cgroup_clean
5.粘贴代码:
#!/bin/sh
rmdir /dev/cgroup/cpu/$*
6.保存文件,执行命令:sudo chmod +x /usr/local/sbin/cgroup_clean
7.重启电脑。
ubuntu 10.04 kernel 2.6.36 测试通过
-
- 帖子: 9
- 注册时间: 2009-07-03 23:59
Re: [转载]200+行内核补丁的替代方案
发现第一次开终端的时候是对的,然后关掉终端再开就出错了,因为不知道怎么的/dev/cgroup/cpu/user/被自动删除了,然后运行~/bashrc的时候mkdir -m 0700 /dev/cgroup/cpu/user/$$使得出错。就是这样,后来我把 /usr/local/sbin/cgroup_clean里的内容注释掉,不出错了,只是/dev/cgroup/cpu/user/中的文件也不会自动删除了。
ubuntu 10.04 kernel 2.6.32-25 版本有点低
ubuntu 10.04 kernel 2.6.32-25 版本有点低
-
- 帖子: 3173
- 注册时间: 2010-01-13 23:26
-
- 帖子: 18
- 注册时间: 2009-09-29 23:42
Re: [转载]200+行内核补丁的替代方案
請問一下, 1.用"/dev"替换"/sys/fs" 是啥意思,要怎樣做??
- hakie
- 帖子: 270
- 注册时间: 2008-04-30 12:14
Re: [转载]200+行内核补丁的替代方案
以下是邮件列表原文。
Date Tue, 16 Nov 2010 20:42:32 +0100
From Markus Trippelsdorf <>
Subject Re: [RFC/RFT PATCH v3] sched: automated per tty task groups
On 2010.11.16 at 19:16 +0100, Lennart Poettering wrote:
> On Tue, 16.11.10 09:11, Linus Torvalds ([email protected]) wrote:
>
> >
> > On Tue, Nov 16, 2010 at 9:03 AM, Lennart Poettering
> > <[email protected]> wrote:
> > >
> > > Binding something like this to TTYs is just backwards.
> >
> > Numbers talk, bullshit walks.
> >
> > The numbers have been quoted. The clear interactive behavior has been seen.
>
> Here's my super-complex patch btw, to achieve exactly the same thing
> from userspace without involving any kernel or systemd patching and
> kernel-side logic. Simply edit your own ~/.bashrc and add this to the end:
>
> if [ "$PS1" ] ; then
> mkdir -m 0700 /sys/fs/cgroup/cpu/user/$$
> echo $$ > /sys/fs/cgroup/cpu/user/$$/tasks
> fi
>
> Then, as the superuser do this:
>
> mount -t cgroup cgroup /sys/fs/cgroup/cpu -o cpu
> mkdir -m 0777 /sys/fs/cgroup/cpu/user
>
> Done. Same effect. However: not crazy.
>
> I am not sure I myself will find the time to prep some 'numbers' for
> you. They'd be the same as with the kernel patch anyway. But I am sure
> somebody else will do it for you...
OK, I've done some tests and the result is that Lennart's approach seems
to work best. It also _feels_ better interactively compared to the
vanilla kernel and in-kernel cgrougs on my machine. Also it's really
nice to have an interface to actually see what is going on. With the
kernel patch you're totally in the dark about what is going on right
now.
Here are some numbers all recorded while running a make -j4 job in one
shell.
perf sched record sleep 30
perf trace -s /usr/libexec/perf-core/scripts/perl/wakeup-latency.pl :
vanilla kernel without cgroups:
total_wakeups: 44306
avg_wakeup_latency (ns): 36784
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 9378852
with in-kernel patch:
total_wakeups: 43836
avg_wakeup_latency (ns): 67607
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 8983036
with Lennart's approach:
total_wakeups: 51070
avg_wakeup_latency (ns): 29047
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 10008237
perf record -a -e sched:sched_switch -e sched:sched_wakeup sleep 10
perf trace -s /usr/libexec/perf-core/scripts/perl/wakeup-latency.pl :
without cgroups:
total_wakeups: 13195
avg_wakeup_latency (ns): 48484
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 8722497
with in-kernel approach:
total_wakeups: 14106
avg_wakeup_latency (ns): 92532
min_wakeup_latency (ns): 20
max_wakeup_latency (ns): 5642393
Lennart's approach:
total_wakeups: 22215
avg_wakeup_latency (ns): 24118
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 8001142
--
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Date Tue, 16 Nov 2010 20:42:32 +0100
From Markus Trippelsdorf <>
Subject Re: [RFC/RFT PATCH v3] sched: automated per tty task groups
On 2010.11.16 at 19:16 +0100, Lennart Poettering wrote:
> On Tue, 16.11.10 09:11, Linus Torvalds ([email protected]) wrote:
>
> >
> > On Tue, Nov 16, 2010 at 9:03 AM, Lennart Poettering
> > <[email protected]> wrote:
> > >
> > > Binding something like this to TTYs is just backwards.
> >
> > Numbers talk, bullshit walks.
> >
> > The numbers have been quoted. The clear interactive behavior has been seen.
>
> Here's my super-complex patch btw, to achieve exactly the same thing
> from userspace without involving any kernel or systemd patching and
> kernel-side logic. Simply edit your own ~/.bashrc and add this to the end:
>
> if [ "$PS1" ] ; then
> mkdir -m 0700 /sys/fs/cgroup/cpu/user/$$
> echo $$ > /sys/fs/cgroup/cpu/user/$$/tasks
> fi
>
> Then, as the superuser do this:
>
> mount -t cgroup cgroup /sys/fs/cgroup/cpu -o cpu
> mkdir -m 0777 /sys/fs/cgroup/cpu/user
>
> Done. Same effect. However: not crazy.
>
> I am not sure I myself will find the time to prep some 'numbers' for
> you. They'd be the same as with the kernel patch anyway. But I am sure
> somebody else will do it for you...
OK, I've done some tests and the result is that Lennart's approach seems
to work best. It also _feels_ better interactively compared to the
vanilla kernel and in-kernel cgrougs on my machine. Also it's really
nice to have an interface to actually see what is going on. With the
kernel patch you're totally in the dark about what is going on right
now.
Here are some numbers all recorded while running a make -j4 job in one
shell.
perf sched record sleep 30
perf trace -s /usr/libexec/perf-core/scripts/perl/wakeup-latency.pl :
vanilla kernel without cgroups:
total_wakeups: 44306
avg_wakeup_latency (ns): 36784
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 9378852
with in-kernel patch:
total_wakeups: 43836
avg_wakeup_latency (ns): 67607
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 8983036
with Lennart's approach:
total_wakeups: 51070
avg_wakeup_latency (ns): 29047
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 10008237
perf record -a -e sched:sched_switch -e sched:sched_wakeup sleep 10
perf trace -s /usr/libexec/perf-core/scripts/perl/wakeup-latency.pl :
without cgroups:
total_wakeups: 13195
avg_wakeup_latency (ns): 48484
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 8722497
with in-kernel approach:
total_wakeups: 14106
avg_wakeup_latency (ns): 92532
min_wakeup_latency (ns): 20
max_wakeup_latency (ns): 5642393
Lennart's approach:
total_wakeups: 22215
avg_wakeup_latency (ns): 24118
min_wakeup_latency (ns): 0
max_wakeup_latency (ns): 8001142
--
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Archlinux+FVWM
虽然没技术折腾,但一直在默默折腾。
虽然没技术折腾,但一直在默默折腾。
- 我就是我2
- 帖子: 1215
- 注册时间: 2008-12-13 10:55
- 来自: the Earth
- 联系:
Re: [转载]200+行内核补丁的替代方案
arch通过。根本不用理会那个把/sys××换成。。。squall724 写了:楼主的脚本有bug
1.在 /etc/rc.local文件中的exit 0上面中加入以下命令:
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
2.执行:sudo chmod +x /etc/rc.local
3.在~/.bashrc文件中加入以下代码:
if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi
4.运行命令:sudo gedit /usr/local/sbin/cgroup_clean
5.粘贴代码:
#!/bin/sh
rmdir /dev/cgroup/cpu/$*
6.保存文件,执行命令:sudo chmod +x /usr/local/sbin/cgroup_clean
7.重启电脑。
ubuntu 10.04 kernel 2.6.36 测试通过

感觉是xterm启动快一点。
苏东坡问佛印道:“人人皆念观世音菩萨,观世音菩萨念谁?”
佛印答道:“念观世音菩萨。”
苏东坡诧异:“为何亦念观世音菩萨?”
曰:“求人不如求己。”
自然灋則
dropbox 誰好奇,誰來點
勞碌一生又如何,虛度一生又如何,你過得開心嗎?人活著就要開心嘛!
佛印答道:“念观世音菩萨。”
苏东坡诧异:“为何亦念观世音菩萨?”
曰:“求人不如求己。”
自然灋則
dropbox 誰好奇,誰來點
勞碌一生又如何,虛度一生又如何,你過得開心嗎?人活著就要開心嘛!