关于 sched:每个 tty 任务组的自动化
我是内核开发新手,我试图了解新的内核补丁 sched :每个 tty 任务组自动化。
有人可以简要解释一下它到底在做什么吗?
I am new to kernel development and I am trying to understand about new kernel patch sched: automated per tty task groups .
Can some one explain in brief what exactly it is doing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对该补丁的印象(尽管大多数关于它的文章都没有详细介绍)是它可以以自动方式更均匀地平衡 CPU 比例。Linux
CFS Completely Fair Scheduler 有一个小组-暂时平衡行为。这意味着,如果用户 A 启动 500 个任务,而用户 B 仅启动一个任务,则公平性应该在用户之间平衡,而不是在任务之间平衡。
为此,用户 A 的所有作业都应在一个组中,而用户 B 的所有作业应在另一组中,并且 CPU 将在它们之间平等共享 - 用户 A 不会仅仅因为他们反社交而获得更多容量运行更多任务。
然而,公平性要么基于用户 ID(动态),要么基于控制组(一种相对痛苦的静态设置方法)。
这个补丁的作用似乎是根据 TTY 自动将作业分配给一个组。这样,分组就成为一项自动功能(无需设置控制组),并且是在比用户 ID 更细的粒度上进行的功能(因为典型的桌面只有有一个用户执行大部分操作)工作,至少是非自动管理的工作)。
因此,当 Linus 坐下来为我们编译下一个内核时,大规模并行构建过程会将所有任务放在一组中,然后 Linus 可以启动 VLC 观看最新一集的 大爆炸理论(我不知道他是否观看这个节目,也不知道他的盒子上是否有各种软件,因为我不知道知道,他可以在 Windows 7 下运行 Windows Media Player)在一个完全独立的组中。
然后,CPU 将在两个组之间相对平等地共享,Linus 不必看着 Sheldon 在屏幕上急速移动。
当然,这会减慢内核构建的速度,但这并不是他为我们执行的一项重要任务。如果这意味着他的理智水平得以维持,我们可以稍等一下:-)
从我读到的(和看到的)来看,这极大提高了桌面应用程序的响应能力。它不会为您提供更多的整体容量,但在某些情况下确实会大大改善事情。
当然,如果您的使用情况配置文件是每个 TTY 中的一项任务(或单个 TTY 中的所有任务),那么它可能不会有太大帮助。但是,如果它改善了某些场景并且不会降低太多其他场景,那么它将成为赢家。而且,即使它确实降低了其他性能,它也是可配置的行为,因此它可能仍然会潜入内核。
有趣的是,既然这个候选补丁已经成为“主流媒体”,有人突然冒出来说你可以做同样的事情,对
.bashrc
进行修改并进行其他一些细微调整。这基本上围绕我之前提到的控制组包装了一个“自动化”工具。Linus 已经拒绝了这个用户态解决方案,因为他希望它与 shell 无关,而这不是用户应该做的事情:
我必须同意这种观点 - 如果您只是被允许告诉用户他们必须做一些特殊的事情来获得额外的性能,您可以让他们使用
"nice make -j64"
而不是 <代码>“make -j64”。My impression of the patch (light on detail though most of the articles about it are) was that it can more evenly balance the CPU proportions in an automatic way.
The Linux CFS Completely Fair Scheduler has had a group-balancing behaviour for a while. What this means is that if user A starts 500 tasks and user B starts only one, the fairness should balance between the users, not the tasks.
To that end, all of the user A jobs should be in one group and all of user B's jobs in another, and the CPU will be shared equally among them - user A doesn't get more capacity just because they're anti-socially running more tasks.
However, the fairness was either based on user ID (dynamic) or control groups (a relatively painful, static setup method).
What this patch appears to do is to automatically allocate jobs to a group based on their TTY. In that way, the separation into group becomes an automatic feature (no setting up control groups), and one that happens on a finer grain than user ID (since typical desktops only have one user doing most of the jobs, at least the non-auto-admin ones).
So, when Linus sits down to compile the next kernel for us, the massively parallel build process has all its tasks put in one group and Linus can then fire up VLC to watch the latest episode of The Big Bang Theory (I have no idea whether he watches this show, nor whether he has various pieces of software on his box, for all I know, he may run Windows Media Player under Windows 7) in a totally separate group.
The CPU will then be shared relatively equally between the two groups, and Linus won't have to watch Sheldon jerkily move across the screen.
It'll slow down the kernel build of course, but it's not as if that's an important task he's performing for us. We can wait a little if it means his sanity levels are maintained :-)
From what I've read (and seen), this greatly improves the responsiveness of desktop applications. It doesn't give you more overall capacity but it does improve things a lot in certain scenarios.
Of course, if your usage profile is one task per TTY (or all tasks in a single TTY), it probably won't help that much. But, if it improves some scenarios and doesn't degrade too many others, it'll be a winner. And, even if it does degrade others, it's configurable behaviour, so it'll probably still sneak in to the kernel.
Interestingly enough, now that this patch candidate has gone "mainstream media", there are people coming out of the woodwork stating you can do the same thing with modifications to your
.bashrc
and some other minor tweaking. This basically wraps an "automated" tool around the control groups I mentioned previously.Linus has already rejected this user-land solution since he wants it to be shell-agnostic and this is not something users should have to do:
I have to agree with that sentiment - if you were just allowed to tell the user they had to do something special for extra performance, you could just get them to use
"nice make -j64"
rather than"make -j64"
.