Bug 773259 - tests don't run in root cpu cgroup with systemd
Summary: tests don't run in root cpu cgroup with systemd
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: beah
Version: 0.8
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Bill Peck
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-11 10:50 UTC by Jan Stancek
Modified: 2019-05-22 13:42 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-09 08:06:35 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1001304 0 unspecified CLOSED Remove obsolete ControlGroup option from beah service file 2021-02-22 00:41:40 UTC

Internal Links: 1001304

Description Jan Stancek 2012-01-11 10:50:15 UTC
Description of problem:
At the moment harness runs in SysV compatible mode under systemd. There is no systemd unit file, where we could change systemd defaults.

So in automated beaker environment we have tests using cpu cgroup like:
cpu:/system/beah-srv.service
and when running same test in shell (ssh), it's root cpu cgroup
cpu:/

This difference is making some tests to fail in beaker, while they work perfectly OK when run manually, for example sched_rr_ tests from LTP
(fail at http://lxr.linux.no/#linux+v3.2/kernel/sched.c#L5353).

[1] http://www.freedesktop.org/wiki/Software/systemd/PaxControlGroups
By default systemd will place services only in automatic cgroups in the "cpu" hierarchy and in its own private tree "name=systemd".

[2] http://comments.gmane.org/gmane.comp.sysutils.systemd.devel/1231
Note that pam_systemd in git now explicitly resets the "cpu" cgroup of
all sessions to the root group since otherwise RT scheduling will not be
available for any user daemons.

It should be easy to workaround this issue in test, I'm submitting this report for consideration about general solution if/when harness will have its own systemd unit file one day. Then adding following to systemd unit file should take care of it:
ControlGroup=cpu:/


Version-Release number of selected component (if applicable):
beah-0.6.35-1.fc14.noarch
systemd-37-3.fc16.x86_64
Fedora 16

How reproducible:
100%

Steps to Reproduce:
1.
cat > /root/setscheduler.c <<EOF
#include <sched.h>

int main()
{
    struct sched_param s = { .sched_priority = 1 };
    return sched_setscheduler(0, SCHED_RR, &s);
}
EOF
gcc /root/setscheduler.c -o /root/setscheduler

2.
cat > /root/test.sh <<EOF
#!/bin/bash
strace -f -F -v /root/setscheduler &> /root/data.txt
EOF

3. running from shell is OK
chmod a+x /root/test.sh
/root/test.sh
tail /root/data.txt | grep sched_setscheduler
> sched_setscheduler(0, SCHED_RR, { 1 })  = 0

4. running as SysV service with systemd defaults fails
ln -s /root/test.sh /etc/init.d/test
systemctl --system daemon-reload
systemctl restart test.service

tail /root/data.txt | grep sched_setscheduler
> sched_setscheduler(0, SCHED_RR, { 1 })  = -1 EPERM (Operation not permitted)

Actual results:
tests are run in non-root cpu cgroup

Expected results:
tests run in root cpu cgroup

Additional info:

Comment 1 Jan Stancek 2012-01-17 11:20:05 UTC
(In reply to comment #0)
> It should be easy to workaround this issue in test

The workaround we have in place now, is to check /proc/self/cgroup, find cpu cgroup mount point, and move process running runtest.sh to root cpu cgroup:
echo $$ > $cpu_cgroup_mnt/tasks

Comment 2 Bill Peck 2012-01-17 14:27:22 UTC
Marian,

If 0.8.2 is an issue let me know

Comment 3 Bill Peck 2012-07-31 16:58:59 UTC
http://gerrit.beaker-project.org/1259

Comment 5 Dan Callaghan 2012-08-09 08:06:35 UTC
Beaker 0.9.2 has been released.


Note You need to log in before you can comment on or make changes to this bug.