public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: Don't allow priority switch to realtime when the task doesn't belong to init_task_group and when CONFIG_RT_GROUP_SCHED isn't set
@ 2008-11-20  6:18 Bharata B Rao
  2008-11-20  7:58 ` Ingo Molnar
  2008-11-23  1:11 ` Peter Zijlstra
  0 siblings, 2 replies; 16+ messages in thread
From: Bharata B Rao @ 2008-11-20  6:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Srivatsa Vaddagiri, Peter Zijlstra, Ingo Molnar, Dhaval Giani

Applies on 2.6.28-rc5.

With CONFIG_RT_GROUP_SCHED not set, don't allow a task's priority switch
to realtime if the task isn't part of init_task_group.

A task belonging to a fair group could use sched_setscheduler/sched_setparam
to become a realtime task. If such a task belongs to one of the
child groups of init_task_group and if CONFIG_RT_GROUP_SCHED is not set,
then it ends up getting queued in init_task_group's runqueue.
So we have a situation where, a task belongs to one group (child)
but ends in the runqueue of another group (init_task_group).
This does not look correct.

Fix this by failing such priority change requests in sched_setscheduler()
and sched_setparam().

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 kernel/sched.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5206,6 +5206,13 @@ recheck:
 		if (rt_bandwidth_enabled() && rt_policy(policy) &&
 				task_group(p)->rt_bandwidth.rt_runtime == 0)
 			return -EPERM;
+#elif defined(CONFIG_FAIR_GROUP_SCHED)
+		/*
+		 * If the task doesn't belong to init_task_group, don't
+		 * allow priority switch to realtime. (!CONFIG_RT_GROUP_SCHED)
+		 */
+		if (rt_policy(policy) && (task_group(p) != &init_task_group))
+			return -EPERM;
 #endif
 
 		retval = security_task_setscheduler(p, policy, param);
Regards,
Bharata.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-11-25 20:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20  6:18 [PATCH] sched: Don't allow priority switch to realtime when the task doesn't belong to init_task_group and when CONFIG_RT_GROUP_SCHED isn't set Bharata B Rao
2008-11-20  7:58 ` Ingo Molnar
2008-11-20  8:03   ` Dhaval Giani
2008-11-20  8:17     ` Ingo Molnar
2008-11-20  8:19   ` Bharata B Rao
2008-11-23  1:11 ` Peter Zijlstra
2008-11-24  3:58   ` Bharata B Rao
2008-11-24  8:32     ` Peter Zijlstra
2008-11-24  8:46       ` Dhaval Giani
2008-11-24  9:06         ` Peter Zijlstra
2008-11-24 15:24           ` Chris Friesen
2008-11-24 15:36             ` Peter Zijlstra
2008-11-25 18:51               ` Chris Friesen
2008-11-25 20:17                 ` Peter Zijlstra
2008-11-24 17:05       ` Srivatsa Vaddagiri
2008-11-24 18:46         ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox