lkml.org 
[lkml]   [2008]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks

This patch checks if we can set the rt_runtime_us to 0. If there is a
realtime task in the group, we don't want to set the rt_runtime_us to 0
otherwise bad things will happen.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
---
kernel/sched.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+)

Index: linux-2.6.25-rc3/kernel/sched.c
===================================================================
--- linux-2.6.25-rc3.orig/kernel/sched.c
+++ linux-2.6.25-rc3/kernel/sched.c
@@ -7960,6 +7960,17 @@ static int __rt_schedulable(struct task_
return total + to_ratio(period, runtime) < global_ratio;
}

+/* Must be called with tasklist_lock held */
+static inline int tg_has_rt_tasks(struct task_group *tg)
+{
+ struct task_struct *p;
+ for_each_process(p) {
+ if (rt_task(p) && rt_rq_of_se(&p->rt)->tg == tg)
+ return 1;
+ }
+ return 0;
+}
+
int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
{
u64 rt_runtime, rt_period;
@@ -7971,6 +7982,13 @@ int sched_group_set_rt_runtime(struct ta
rt_runtime = rt_period;

mutex_lock(&rt_constraints_mutex);
+ read_lock(&tasklist_lock);
+ if (rt_runtime_us == 0) {
+ if (tg_has_rt_tasks(tg)) {
+ err = -EINVAL;
+ goto unlock;
+ }
+ }
if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
err = -EINVAL;
goto unlock;
@@ -7979,6 +7997,7 @@ int sched_group_set_rt_runtime(struct ta
rt_runtime = RUNTIME_INF;
tg->rt_runtime = rt_runtime;
unlock:
+ read_unlock(&tasklist_lock);
mutex_unlock(&rt_constraints_mutex);

return err;
--
regards,
Dhaval

\
 
 \ /
  Last update: 2008-02-27 12:11    [W:0.061 / U:2.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site