LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-17-2019, 11:12 AM   #1
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Rep: Reputation: 253Reputation: 253Reputation: 253
[Testing needed] Responsiveness-optimizing cgroups (rc script).


Hello, everyone.

I would like to ask for some testing, since now the cool thing I have bodged only works 'on my machine', but I think that it may be found useful by more people.

I was frustrated by the fact that my system is not optimised for responsiveness, and that some misbehaving applications may, for example, occupy all the cpu and render the system unusable, or occupy too much swap, and make the system unable to hibernate. So I decided to use libcgroup (as it is included in the stock Slackware) to control the misbehaving applications.

What is it ?

It is one main rc.d script, and a few application lists, generated on stock Slackware-current, which configure several restriction groups which don't allow applications to misbehave.

What are the 'groups'?
  • Root group: the total memory is limited to the amount of swap. This way everything fits into the swap when hibernation is neede.
  • System group: Always has at least one core (or half of a core on a 1-core machine) available for itself.
  • GUI group: Always have more than one core available for itself, and never swaps.
  • Multimedia group: Always has a bit of cpu available (so that music keeps playing) and is limited to 90% cpu max, to constrain misbehaviour.
  • Restricted group: Has its memory limited to half of the system memory. (And unlimited swap.) I put browsers in this group, as they are the most likely to misbehave.
  • The secret Skype group: The most restricted one.

The parameters are mostly tunable in /etc/rc.d/rc.lwf_userfriendly_cgroup.conf , or in the lists in /etc/cgconfig.templates/ and /etc/cgrules.templates/
Please, don't edit the .conf files directly, as they are dynamically generated with bash and awk.

The script starts for ~1 minute, but this is due to extra care when pgreping.
If anyone wants a much-much faster version, I could do it.

The rules are enforced by cgrulesengd, and you can run a default one, or rely on the script having it's own one.

Any feedback welcome, please, test, I really need it.

Source code: https://gitlab.com/Lockywolf/lwf_userfriendly_cgroup/

The version 0.0.3 should be usable.

There is a SlackBuild prepared, which needs a 0.0.3 tar.gz

https://gitlab.com/Lockywolf/lwfslac...riendly_cgroup

I start the script at boot by softlinking:
Code:
ln -s /etc/rc.d/rc.lwf_userfriendly_cgroup /etc/rc.d/rc3.d/S00userfriendly
ln -s /etc/rc.d/rc.lwf_userfriendly_cgroup /etc/rc.d/rc4.d/S00userfriendly
But you can add it to rc.local if you want.

The script is not really Slackware-specific. If you have libcgroup and recent GNU coreutils, it should work.
 
Old 06-17-2019, 12:59 PM   #2
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,500

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
And why we will want this systemd-ish feature in Slackware?
 
1 members found this post helpful.
Old 06-17-2019, 04:12 PM   #3
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
This is using functionality that is present in the kernel itself.

It's a way of restricting how much of a resource a given type of process can grab.

If you don't see a need for it yourself, that's fine. But it doesn't have anything to do with systemd.
 
3 members found this post helpful.
Old 06-18-2019, 12:10 AM   #4
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Original Poster
Rep: Reputation: 253Reputation: 253Reputation: 253
Version 0.0.4 tagged in the repo.

Now the full list of files written in /etc/ is in the top of the rc.lwf_userfriendly_cgroup, so you can check what it mutates when runs.

Added installation instructions for those who don't use Slackware or want to install the script manually.

The SlackBuild is also updated.

Any feedback would be welcomed, especially other tricks for responsiveness optimisation.
(I am thinking about a perbash-cgroup trick, but that on I already know.)

https://gitlab.com/Lockywolf/lwf_use...p/-/tags/0.0.4

Any suggestions for other mean software to be restricted would be welcomed.
 
1 members found this post helpful.
Old 06-18-2019, 08:49 PM   #5
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Original Poster
Rep: Reputation: 253Reputation: 253Reputation: 253
Quote:
Originally Posted by LuckyCyborg View Post
And why we will want this systemd-ish feature in Slackware?

1) It's not systemd-ish. libcgroup is many years older than systemd
2) not sure about you, but on my machine Firefox (and some other apps) has a tendency to sometimes put the whole system in a knee-chest position by stealing all the cpu, memory and IO. I don't like this, I like my foxen caged.
 
Old 06-22-2019, 07:24 AM   #6
gus3
Member
 
Registered: Jun 2014
Distribution: Slackware
Posts: 490

Rep: Reputation: Disabled
What the heck. I'll take the plunge. I've never done any experimenting with cgroups, beyond a single introduction explaining how to use them. Maybe this will motivate me to do some research.
 
1 members found this post helpful.
Old 06-22-2019, 09:28 PM   #7
gus3
Member
 
Registered: Jun 2014
Distribution: Slackware
Posts: 490

Rep: Reputation: Disabled
Hm, looks like I have some reading to do...
 
Old 06-22-2019, 11:39 PM   #8
philanc
Member
 
Registered: Jan 2011
Posts: 308

Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by Lockywolf View Post
Version 0.0.4 tagged in the repo.

Now the full list of files written in /etc/ is in the top of the rc.lwf_userfriendly_cgroup, so you can check what it mutates when runs.

Added installation instructions for those who don't use Slackware or want to install the script manually.

https://gitlab.com/Lockywolf/lwf_use...p/-/tags/0.0.4
Will have a look at it. Thanks for sharing.
 
1 members found this post helpful.
Old 06-22-2019, 11:51 PM   #9
ZhaoLin1457
Senior Member
 
Registered: Jan 2018
Posts: 1,022

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Lockywolf View Post
Root group: the total memory is limited to the amount of swap. This way everything fits into the swap when hibernation is neede.
My main box have 16GB DDR3 RAM, and with my usage habits, I will have to put efforts to consume barely 8GB, that's why I chosen to not use a real SWAP partition, but a 1GB ZRAM (compressed memory) device, just to give a chance to kernel to defragment the memory.

So, according with your wise vision, the root shall use in that box only 1GB from 16GB available, even there are no chances for it to hibernate ever?

No offense, but that's ridiculous.

Last edited by ZhaoLin1457; 06-23-2019 at 01:29 AM.
 
Old 06-23-2019, 04:09 AM   #10
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Original Poster
Rep: Reputation: 253Reputation: 253Reputation: 253
Quote:
Originally Posted by ZhaoLin1457 View Post
My main box have 16GB DDR3 RAM, and with my usage habits, I will have to put efforts to consume barely 8GB, that's why I chosen to not use a real SWAP partition, but a 1GB ZRAM (compressed memory) device, just to give a chance to kernel to defragment the memory.

So, according with your wise vision, the root shall use in that box only 1GB from 16GB available, even there are no chances for it to hibernate ever?

No offense, but that's ridiculous.
Well, you're not forced to use this feature. Just turn it off if your only want to restrict firefox.
 
Old 06-23-2019, 08:01 AM   #11
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Original Poster
Rep: Reputation: 253Reputation: 253Reputation: 253
After digging into cgroups more, I've found an even more tasty feature.

With cgroups-v2 it seems possible to turn off thrashing.
 
Old 06-23-2019, 11:00 PM   #12
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Original Poster
Rep: Reputation: 253Reputation: 253Reputation: 253
Damn, it seems that libcgroup doesn't support v2.

This seems to be a huge problem. V1 (the version used now) are much worse...

But the only userspace code I have found to support cgroups-v2 is in systemd.

It may be possible to rip the code related to cgroupsv2 from systemd into an independent library, but I am not sure it is an easy thing to do, and would take me a lot of time. Not good.

If anyone is aware of tools for working with cgroups-v2 without systemd, I'd be very interested.
 
Old 06-23-2019, 11:17 PM   #13
ZhaoLin1457
Senior Member
 
Registered: Jan 2018
Posts: 1,022

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
No offense, but someone warned you already that you are playing with a thing which is (today) part of systemd, at least as user-space side, as it seems...
 
Old 06-24-2019, 12:25 AM   #14
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Original Poster
Rep: Reputation: 253Reputation: 253Reputation: 253
Quote:
Originally Posted by ZhaoLin1457 View Post
No offense, but someone warned you already that you are playing with a thing which is (today) part of systemd, at least as user-space side, as it seems...

No offence, but _everything_ is now a thing which is (today) part of systemd. There is systemd-bootlogd, systemd-bootd, systemd-loggerd, systemd-nspawn, systemd-cgroups, systemd-virtd, systemd-networkd, systemd-udev, systemd-consoled, and * knows what.
 
Old 06-24-2019, 07:26 AM   #15
gus3
Member
 
Registered: Jun 2014
Distribution: Slackware
Posts: 490

Rep: Reputation: Disabled
There's probably copies of Emacs and DOS somewhere in there, too...
 
  


Reply

Tags
cgroups, responsiveness, speed



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow mouse responsiveness in X, is this normal? orgee Linux - Software 20 10-25-2004 02:46 PM
UI responsiveness yaBoy Linux - Laptop and Netbook 1 05-21-2004 05:23 PM
Improving USB Keyboard Responsiveness? dumtruck51 Linux - Newbie 4 12-26-2003 10:54 AM
USB problems with 2.6.0test11 - LOW system responsiveness GD_19 Linux - Hardware 1 12-03-2003 01:31 AM
Kernel tweaks/patches to improve responsiveness? sb73542 Linux - General 3 08-26-2003 02:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration