From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbdJFLtF (ORCPT ); Fri, 6 Oct 2017 07:49:05 -0400 Received: from forwardcorp1g.cmail.yandex.net ([87.250.241.190]:40385 "EHLO forwardcorp1g.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751535AbdJFLtC (ORCPT ); Fri, 6 Oct 2017 07:49:02 -0400 Authentication-Results: smtpcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH] sched/cgroup: allow rt tasks in cpu cgroup without group rt scheduler From: Konstantin Khlebnikov To: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org Cc: Tejun Heo Date: Fri, 06 Oct 2017 14:48:58 +0300 Message-ID: <150729053840.744865.8446192218258392956.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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,