All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <pmoore@redhat.com>
To: selinux@tycho.nsa.gov
Subject: [PATCH 3/4] selinux-testsuite: enable task_setscheduler to work with cgroups
Date: Mon, 09 Feb 2015 18:06:41 -0500	[thread overview]
Message-ID: <20150209230641.2579.48731.stgit@localhost> (raw)
In-Reply-To: <20150209230426.2579.84520.stgit@localhost>

On recent systemd based distributions, systemd manages cgroups
automatically and we may be running in a cgroup by default.
Unfortunately, this can cause problems when trying to set the
scheduler policy so we need to move the target process to the root
cgroup (no scheduler policy restrictions in the root cgroup) before
we attempt to change the scheduler settings.

Signed-off-by: Paul Moore <pmoore@redhat.com>
---
 0 files changed

diff --git a/tests/task_setscheduler/test b/tests/task_setscheduler/test
index f1b71eb..f63db07 100755
--- a/tests/task_setscheduler/test
+++ b/tests/task_setscheduler/test
@@ -12,6 +12,15 @@ if ( ($pid = fork()) == 0 ) {
 
 sleep 1; # Give it a second to start
 
+$cgroup_cpu = "/sys/fs/cgroup/cpu/tasks";
+if ( -w $cgroup_cpu ) {
+	# We can only set the scheduler policy fo SCHED_{RR,FIFO} in the root
+	# cgroup so move our target process to the root cgroup.
+	open(my $fd, ">>", $cgroup_cpu);
+	print $fd $pid;
+	close $fd;
+}
+
 # Verify that test_setsched_yes_t can change the scheduling.
 # SCHED_OTHER	0	priority must == 0
 # SCHED_FIFO	1	priority 1..99

  parent reply	other threads:[~2015-02-09 23:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09 23:06 [PATCH 0/4] Fix the selinux-testsuite for RHEL5,6,7 and Rawhide Paul Moore
2015-02-09 23:06 ` [PATCH 1/4] selinux-testsuite: add improved OS detection Paul Moore
2015-02-09 23:06 ` [PATCH 2/4] selinux-testsuite: allow the file test to work with all coreutils versions Paul Moore
2015-02-09 23:06 ` Paul Moore [this message]
2015-02-09 23:06 ` [PATCH 4/4] selinux-testsuite: allow unconfined_t entrypoint to test_nnp_bounded_exec_t Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150209230641.2579.48731.stgit@localhost \
    --to=pmoore@redhat.com \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.