Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 533922

Summary: sci-misc/boinc should use cgroups instead of nice -19
Product: Gentoo Linux Reporter: Toralf Förster <toralf>
Component: Current packagesAssignee: Sven Eden <sven.eden>
Status: RESOLVED WONTFIX    
Severity: normal CC: arthur, bircoph, jstein, redwolfe, sci
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Toralf Förster gentoo-dev 2014-12-29 14:29:07 UTC
With the P-State kernel driver one good feature of the old ondemand governor is lost: niced processes (nice -19) formerly did not increase the cpu speed to max, but now this is the case (https://lkml.org/lkml/2013/5/3/376)

As an "alternative" the cgroups are proposed, which would need the following changes to the init script:

i) boinc depends on dev-libs/libcgroup

ii)
3 commands like this has to be run :

$> CGROUP_DAEMON="cpu:/background"
$> cgcreate -g $CGROUP_DAEMON
$> cgset -r cpu.shares=2 `echo $CGROUP_DAEMON | cut -f2 -d:`

iii) the init.d script needs something like this to start the boinc process:
cgexec -g cpu:background ...



What's left however with these (incomplete ?) settings : the cpu speed is set often to max resulting a´in a high temperature of a notebook.
Comment 1 Sven Eden 2016-05-06 06:48:17 UTC
Basically I agree, but there are two things to consider:

1) Does the cgroup setting cascade down to the applications started by the boinc daemon?

2) What about the (many?) users who either use a kernel with BFS scheduler (no cgroups) or have cgroups disabled themselves?
Comment 2 Toralf Förster gentoo-dev 2016-05-06 08:09:47 UTC
1) definitely yes IMO, due to the autogroup feature of the kernel

2) no idea
Comment 3 Sven Eden 2016-11-04 11:54:17 UTC
Sorry for the long delay.

I am currently working on other bugs. Hopefully I have my next pull request ready this afternoon. If it gets accepted, I'll add the cgroups support.

For something like BOINC it looks really promising.
Comment 4 Jonas Stein gentoo-dev 2017-07-25 15:35:56 UTC
Any news?
Comment 5 Sven Eden 2017-07-26 09:59:04 UTC
(In reply to Jonas Stein from comment #4)
> Any news?

The problem is to have an idea how to do this correctly.

 - What if a user does not have cgroups support? Make cgroups support mandatory?
 - Wouldn't it be sufficient to add something like "boinc cpu,memory background" to /etc/cgroup/cgrules.conf? /etc/init.d/cgred would have to run anyway, right?

However, even if the usage of cgexec is not needed, the init script must at least create and configure the cgroup.
Comment 6 Sven Eden 2017-07-26 10:16:26 UTC
Actually I think it is sufficient to add

--------
group background {
        cpu {
                cpu.shares="8";
        }
        memory {
                memory.limit_in_bytes="16G";
                memory.memsw.limit_in_bytes="24G";
        }
}
--------

to /etc/cgroup/cgconfig.conf, this is my config on an 8 core notebook with 32GB RAM, and to add

--------
@boinc          cpu,memory              background
--------

to /etc/cgroup/cgrules.conf. All processes started by someone in the boinc group are then handled by cpu/background and cpu/background.
Comment 7 Andrew Savchenko gentoo-dev 2017-07-26 11:06:53 UTC
(In reply to Sven Eden from comment #6)
> Actually I think it is sufficient to add
> 
> --------
> group background {
>         cpu {
>                 cpu.shares="8";
>         }
>         memory {
>                 memory.limit_in_bytes="16G";
>                 memory.memsw.limit_in_bytes="24G";
>         }
> }
> --------
> 
> to /etc/cgroup/cgconfig.conf, this is my config on an 8 core notebook with
> 32GB RAM, and to add
> 
> --------
> @boinc          cpu,memory              background
> --------
> 
> to /etc/cgroup/cgrules.conf. All processes started by someone in the boinc
> group are then handled by cpu/background and cpu/background.

This is not portable. How about users with different CPU/RAM amounts?

Anyway, there are people not using cgroups (including myself), so nice should be available as fallback.

BTW, if one wants to save battery, why to run BOINC in the first place? I always thought it is for desktops/servers with resources wasted otherwise.
Comment 8 Sven Eden 2017-07-26 11:13:56 UTC
(In reply to Andrew Savchenko from comment #7)
> > to /etc/cgroup/cgconfig.conf, this is my config on an 8 core notebook with
> > 32GB RAM, and to add
> > 
> > --------
> > @boinc          cpu,memory              background
> > --------
> > 
> > to /etc/cgroup/cgrules.conf. All processes started by someone in the boinc
>
> This is not portable. How about users with different CPU/RAM amounts?

Of course not. Every user who wants cgroups can set this up for themselves without any change needed on the boinc init script. It really can not decide for you how to set it up.

I could add this stuff to the init script, setting everything up manually, and steered through /etc/conf.d/boinc, but I couldn't even come up with sane defaults.

> Anyway, there are people not using cgroups (including myself), so nice
> should be available as fallback.

Yes. That's why I thought about this manual DIY-approach.

> BTW, if one wants to save battery, why to run BOINC in the first place? I
> always thought it is for desktops/servers with resources wasted otherwise.

BOINC goes into suspend mode when running on battery. At least that's the default. Users can change that on their own discretion of course...
Comment 9 Andrew Savchenko gentoo-dev 2017-07-26 20:13:50 UTC
(In reply to Sven Eden from comment #8)
> Of course not. Every user who wants cgroups can set this up for themselves
> without any change needed on the boinc init script. It really can not decide
> for you how to set it up.

Ah, OK. Sorry I misunderstood you, I though you're suggesting these values as defaults for everyone.
Comment 10 Sven Eden 2018-01-23 08:19:14 UTC
I am closing this, because I can not find a simple solution that does not result in a no-fit for most users.

The setup of cgroups to control cpu and memory shares are highly dependent on the target machines layout, both hardware and other cgroups configurations, that it is best to let users configure this themselves (this is actually quite easy) if they care.

Please feel free to re-open this bug if a simple solution crosses your path.