r/programming • • Nov 19 '10

Alternative To the 200-Line Linux Kernel Patch

http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html
40 Upvotes

13 comments sorted by

3

u/[deleted] Nov 19 '10

Can someone explain to the ignorant, what does all that shell wrangling accomplish? I take it it writes something to some special device that tells the kernel to change something inside itself. But what?

8

u/[deleted] Nov 19 '10

The magic keyword here is "Control groups". It's basically a mechanism to group different tasks/processes into a so called cgroup which enables you to control their resource usage. This in turn can be used to tell the scheduler to prioritize certain tasks, which results into a better response time. The patch essentially automates this within the kernel.

1

u/[deleted] Nov 19 '10

Thank you! So does the patch create intelligent and rational control groups? Or is something dumb? If the patch uses some kind of heuristic to make a good default choice for the control group creation, I think it's a good idea. What do you think?

4

u/[deleted] Nov 19 '10

So does the patch create intelligent and rational control groups?

Not really. According to the article that was discussed here on reddit:

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.

As far as I understand it, everything that is started from terminal (TTY) runs with a lower priority in regard to CPU usage. The end result is that the other tasks (like the desktop stuff) react fast even when the system is under load by a terminal run process.

1

u/wazoox Nov 19 '10

I don't see what's preventing the first approach to work on ubuntu, really...

1

u/nikosk Nov 19 '10

FYI: Just tried it on an Ubuntu 10.04 desktop and I can confirm that at the least your system won't crash. I can't comment on actual performance improvements yet, not without any hard data at least.

PS: My current kernel signature is: 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:48:22 UTC 2010 i686 GNU/Linux

0

u/[deleted] Nov 19 '10

[deleted]

0

u/[deleted] Nov 19 '10

[deleted]

3

u/literal Nov 19 '10

Every line of code in the kernel is a possible system crashing bug. Never do in kernel mode what you can get away with in user mode.

You have to take into account that the solution mention in the article is there to activate a kernel feature (cgroup) to solve the problem. Whether that part of the kernel is more bloated or better tested than this patch is another matter, though.

5

u/spotter Nov 19 '10

You point is valid. But please note that this patch is 200 lines of code, while 2.6.32 is 12606910 LOC.

200/12606910 is 1.586431568084487e-05, or 0.000016, or as Python programmer would tell you: 0. ;-)

2

u/w0073r Nov 19 '10
epanastrophe:~$ python3
Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 200 / 12606910
1.586431568084487e-05

2

u/spotter Nov 20 '10

I said "Python programmer", not "Python3 programmer", you guys are the __future__ though. Sheesh! ;)

0

u/[deleted] Nov 19 '10

[deleted]

2

u/bonzinip Nov 19 '10

As an end user, why exactly should I care about some scheduler magic deep in the bowels of the system?

Because it's not generic. It does wonders if you run compilations from a terminal, but not if a program runs "make > /tmp/blah.txt".

It's policy, and policy belongs in things such as gdm (or systemd) or gnome-terminal, not in the kernel.

-1

u/DPyro Nov 19 '10

So now every UI frontend must implement its own scheduler policy?

The current scheduling system for desktop Linux just sucks, period.

3

u/bonzinip Nov 19 '10

Yes, because these frontends are all different, so these policies are also different even though they share the basic idea.

If you implement it in systemd, every console (session) gets a fair share of the CPU. If you implement it in the desktop, every app in the session gets a fair share of the CPU within what is allotted to the session. If you implement it in gnome-terminal, every tab gets a fair share of the CPU within what is allotted to gnome-terminal by the desktop. And so on. Every application that needs to subdivide its share of the CPU must implement the policy.

Within the kernel, you can only make a simple per-tty policy, which only works in a very specific case ("the desktop will not get less CPU than what each tty will get"). For example, it will not work if you have mplayer in one window and an ffmpeg frontend on the other. It makes no sense, except that it affects Linus's workflow so he likes it.

0

u/[deleted] Nov 19 '10

[deleted]

2

u/NitWit005 Nov 19 '10

And for a scenario that only matters to kernel devs?

And anyone who would like their desktop to stop freezing up?

1

u/Comment111 Nov 19 '10

I like running rtorrent in another tty and do my packet managing in a different tty, especially with KMS switching is so easy. Now I have to suffer because they want to lower the priority on the ttys.