[转载]200+行内核补丁的替代方案

最新ubuntu/linux/开源新闻或者其它IT相关资讯
回复
头像
hakie
帖子: 270
注册时间: 2008-04-30 12:14
送出感谢: 0
接收感谢: 2 次

[转载]200+行内核补丁的替代方案

#1

帖子 hakie » 2010-11-19 11:21

前几天有报道称,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.
Archlinux+FVWM

虽然没技术折腾,但一直在默默折腾。
头像
Ubuntu与Linux
帖子: 1211
注册时间: 2010-06-09 19:57
送出感谢: 2 次
接收感谢: 9 次

Re: [转载]200+行内核补丁的替代方案

#2

帖子 Ubuntu与Linux » 2010-11-19 11:49

等待测试结果 :em11
头像
hcym
帖子: 15634
注册时间: 2007-05-06 2:46
送出感谢: 0
接收感谢: 2 次

Re: [转载]200+行内核补丁的替代方案

#3

帖子 hcym » 2010-11-19 12:04

等待测试
وإذا كان هذا لا يحصل أكثر من 100 ملاحظات ، انا ذاهب الى غضب
头像
jarryson
帖子: 4002
注册时间: 2005-08-14 19:53
送出感谢: 1 次
接收感谢: 2 次
联系:

Re: [转载]200+行内核补丁的替代方案

#4

帖子 jarryson » 2010-11-19 13:02

像我是使用bfs,是禁用cgroups的,所以这个方法对我无效。而是使用ck提供的schedtool。貌似效果不错
头像
扭曲杰
帖子: 528
注册时间: 2010-03-24 10:33
送出感谢: 2 次
接收感谢: 0

Re: [转载]200+行内核补丁的替代方案

#6

帖子 扭曲杰 » 2010-11-19 14:58

有哪位同学试试? :em09
squall724
帖子: 126
注册时间: 2007-06-13 9:36
送出感谢: 0
接收感谢: 5 次

Re: [转载]200+行内核补丁的替代方案

#7

帖子 squall724 » 2010-11-19 17:29

楼主的脚本有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 测试通过
bachue
帖子: 9
注册时间: 2009-07-03 23:59
送出感谢: 0
接收感谢: 0

Re: [转载]200+行内核补丁的替代方案

#8

帖子 bachue » 2010-11-19 20:26

发现第一次开终端的时候是对的,然后关掉终端再开就出错了,因为不知道怎么的/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 版本有点低
rediscover
帖子: 3173
注册时间: 2010-01-13 23:26
送出感谢: 0
接收感谢: 12 次

Re: [转载]200+行内核补丁的替代方案

#9

帖子 rediscover » 2010-11-19 20:27

脚本在挂载上的处理有问他,Drop
Here I am.
Ubuntu 桌面培训 - 全中文官方文档,含汉化截图,提供PDF
beachmarble
帖子: 18
注册时间: 2009-09-29 23:42
送出感谢: 0
接收感谢: 0

Re: [转载]200+行内核补丁的替代方案

#10

帖子 beachmarble » 2010-11-19 23:41

請問一下, 1.用"/dev"替换"/sys/fs" 是啥意思,要怎樣做??
头像
hakie
帖子: 270
注册时间: 2008-04-30 12:14
送出感谢: 0
接收感谢: 2 次

Re: [转载]200+行内核补丁的替代方案

#11

帖子 hakie » 2010-11-20 1:13

以下是邮件列表原文。

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 (torvalds@linux-foundation.org) wrote:
>
> >
> > On Tue, Nov 16, 2010 at 9:03 AM, Lennart Poettering
> > <mzxreary@0pointer.de> 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 majordomo@vger.kernel.org
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
送出感谢: 1 次
接收感谢: 3 次
联系:

Re: [转载]200+行内核补丁的替代方案

#12

帖子 我就是我2 » 2010-11-23 18:32

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 测试通过
arch通过。根本不用理会那个把/sys××换成。。。 :em20

感觉是xterm启动快一点。
苏东坡问佛印道:“人人皆念观世音菩萨,观世音菩萨念谁?”
佛印答道:“念观世音菩萨。”
苏东坡诧异:“为何亦念观世音菩萨?”
曰:“求人不如求己。”


dropbox 誰好奇,誰來點
勞碌一生又如何,虛度一生又如何,你過得開心嗎?人活著就要開心嘛!
回复

回到 “新闻和通知”