lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 06 Oct 2017 14:48:58 +0300
From:   Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
To:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Cc:     Tejun Heo <tj@...nel.org>
Subject: [PATCH] sched/cgroup: allow rt tasks in cpu cgroup without group rt
 scheduler

Without group rt scheduler rt tasks works in cpu cgroup perfectly fine.
This artificial restriction blocks attaching rt threads to cpu cgroup.

Moreover __sched_setscheduler() never had such check and allow changing
policy to rt for threads which are already in non-root cpu cgroup.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
---
 kernel/sched/core.c  |    8 +++-----
 kernel/sched/rt.c    |    9 ---------
 kernel/sched/sched.h |    1 -
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d17c5da523a0..ceb7df51d448 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6338,11 +6338,9 @@ static int cpu_cgroup_can_attach(struct cgroup_taskset *tset)
 
 	cgroup_taskset_for_each(task, css, tset) {
 #ifdef CONFIG_RT_GROUP_SCHED
-		if (!sched_rt_can_attach(css_tg(css), task))
-			return -EINVAL;
-#else
-		/* We don't support RT-tasks being in separate groups */
-		if (task->sched_class != &fair_sched_class)
+		/* Don't accept rt tasks when there is no way for them to run */
+		if (rt_bandwidth_enabled() && rt_task(task) &&
+		    css_tg(css)->rt_bandwidth.rt_runtime == 0)
 			return -EINVAL;
 #endif
 		/*
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 0af5ca9e3e3f..e25b460d051f 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2650,15 +2650,6 @@ static int sched_rt_global_constraints(void)
 	return ret;
 }
 
-int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk)
-{
-	/* Don't accept realtime tasks when there is no way for them to run */
-	if (rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0)
-		return 0;
-
-	return 1;
-}
-
 #else /* !CONFIG_RT_GROUP_SCHED */
 static int sched_rt_global_constraints(void)
 {
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 14db76cd496f..266c5a16ccda 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -387,7 +387,6 @@ extern int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
 extern int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_us);
 extern long sched_group_rt_runtime(struct task_group *tg);
 extern long sched_group_rt_period(struct task_group *tg);
-extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk);
 
 extern struct task_group *sched_create_group(struct task_group *parent);
 extern void sched_online_group(struct task_group *tg,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ