* [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
@ 2008-02-27 11:08 Dhaval Giani
2008-02-27 12:46 ` Peter Zijlstra
0 siblings, 1 reply; 10+ messages in thread
From: Dhaval Giani @ 2008-02-27 11:08 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Sudhir Kumar, Balbir Singh, Aneesh Kumar KV, Srivatsa Vaddagiri,
lkml
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 11:08 [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks Dhaval Giani
@ 2008-02-27 12:46 ` Peter Zijlstra
2008-02-27 13:24 ` Dhaval Giani
0 siblings, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2008-02-27 12:46 UTC (permalink / raw)
To: Dhaval Giani
Cc: Ingo Molnar, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, 2008-02-27 at 16:38 +0530, Dhaval Giani wrote:
> 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.
I had considered this a: don't do that then, thing. But sure, helping
the admin seems like a valid option.
> 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;
-EBUSY perhaps?
> + 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;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 12:46 ` Peter Zijlstra
@ 2008-02-27 13:24 ` Dhaval Giani
2008-02-27 13:40 ` Peter Zijlstra
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Dhaval Giani @ 2008-02-27 13:24 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Ingo Molnar, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, Feb 27, 2008 at 01:46:56PM +0100, Peter Zijlstra wrote:
>
> On Wed, 2008-02-27 at 16:38 +0530, Dhaval Giani wrote:
> > 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.
>
> I had considered this a: don't do that then, thing. But sure, helping
> the admin seems like a valid option.
>
Well, if it can be done, it shall be done :)
<snip>
>
> > + err = -EINVAL;
>
> -EBUSY perhaps?
>
Well, the group is certainly not busy. I will go with invalid as it is
definitly an invalid value when the groups have rt tasks. But if someone
disagrees, I have no issue with it being something else.
Corrected patch as follows,
--
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 as 0
or bad things will happen.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
---
kernel/sched.c | 17 +++++++++++++++++
1 files changed, 17 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,11 @@ 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 && tg_has_rt_tasks(tg)) {
+ err = -EINVAL;
+ goto unlock;
+ }
if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
err = -EINVAL;
goto unlock;
@@ -7979,6 +7995,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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 13:24 ` Dhaval Giani
@ 2008-02-27 13:40 ` Peter Zijlstra
2008-02-27 14:11 ` Peter Zijlstra
2008-02-27 21:47 ` Peter Zijlstra
2 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2008-02-27 13:40 UTC (permalink / raw)
To: Dhaval Giani
Cc: Ingo Molnar, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
> Well, if it can be done, it shall be done :)
May I suggest: rm -rf /
/me runs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 13:24 ` Dhaval Giani
2008-02-27 13:40 ` Peter Zijlstra
@ 2008-02-27 14:11 ` Peter Zijlstra
2008-02-27 15:03 ` Ingo Molnar
2008-02-27 21:47 ` Peter Zijlstra
2 siblings, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2008-02-27 14:11 UTC (permalink / raw)
To: Dhaval Giani
Cc: Ingo Molnar, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
> 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 as 0
> or bad things will happen.
>
> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
> kernel/sched.c | 17 +++++++++++++++++
> 1 files changed, 17 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,11 @@ 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 && tg_has_rt_tasks(tg)) {
> + err = -EINVAL;
> + goto unlock;
> + }
> if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
> err = -EINVAL;
> goto unlock;
> @@ -7979,6 +7995,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;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 14:11 ` Peter Zijlstra
@ 2008-02-27 15:03 ` Ingo Molnar
2008-02-27 15:08 ` Peter Zijlstra
2008-02-27 15:10 ` Dhaval Giani
0 siblings, 2 replies; 10+ messages in thread
From: Ingo Molnar @ 2008-02-27 15:03 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Dhaval Giani, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
* Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
>
> > 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 as 0
> > or bad things will happen.
> >
> > Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
>
> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
doesnt apply to sched-devel.git - what's the plan here?
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 15:03 ` Ingo Molnar
@ 2008-02-27 15:08 ` Peter Zijlstra
2008-02-27 15:10 ` Dhaval Giani
1 sibling, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2008-02-27 15:08 UTC (permalink / raw)
To: Ingo Molnar
Cc: Dhaval Giani, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, 2008-02-27 at 16:03 +0100, Ingo Molnar wrote:
> * Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> >
> > On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
> >
> > > 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 as 0
> > > or bad things will happen.
> > >
> > > Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
> >
> > Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
>
> doesnt apply to sched-devel.git - what's the plan here?
stick in front, drop the other two sched-rt-group patches for which I'll
send you an update somewhere today.
These two patches would be candidates to push to linus..
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 15:03 ` Ingo Molnar
2008-02-27 15:08 ` Peter Zijlstra
@ 2008-02-27 15:10 ` Dhaval Giani
1 sibling, 0 replies; 10+ messages in thread
From: Dhaval Giani @ 2008-02-27 15:10 UTC (permalink / raw)
To: Ingo Molnar
Cc: Peter Zijlstra, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, Feb 27, 2008 at 04:03:50PM +0100, Ingo Molnar wrote:
>
> * Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> >
> > On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
> >
> > > 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 as 0
> > > or bad things will happen.
> > >
> > > Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
> >
> > Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
>
> doesnt apply to sched-devel.git - what's the plan here?
>
Belongs to mainline.
--
regards,
Dhaval
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 13:24 ` Dhaval Giani
2008-02-27 13:40 ` Peter Zijlstra
2008-02-27 14:11 ` Peter Zijlstra
@ 2008-02-27 21:47 ` Peter Zijlstra
2008-02-28 9:51 ` Dhaval Giani
2 siblings, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2008-02-27 21:47 UTC (permalink / raw)
To: Dhaval Giani
Cc: Ingo Molnar, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
> 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 as 0
> or bad things will happen.
>
> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
> ---
> kernel/sched.c | 17 +++++++++++++++++
> 1 files changed, 17 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;
> + }
This should be a do_each_thread() { } while_each_thread(); iteration
loop;
cgroups are thread oriented, not task.
Sorry for missing this earlier.
> + return 0;
> +}
> +
> int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
> {
> u64 rt_runtime, rt_period;
> @@ -7971,6 +7982,11 @@ 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 && tg_has_rt_tasks(tg)) {
> + err = -EINVAL;
> + goto unlock;
> + }
> if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
> err = -EINVAL;
> goto unlock;
> @@ -7979,6 +7995,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;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
2008-02-27 21:47 ` Peter Zijlstra
@ 2008-02-28 9:51 ` Dhaval Giani
0 siblings, 0 replies; 10+ messages in thread
From: Dhaval Giani @ 2008-02-28 9:51 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Ingo Molnar, Sudhir Kumar, Balbir Singh, Aneesh Kumar KV,
Srivatsa Vaddagiri, lkml
On Wed, Feb 27, 2008 at 10:47:19PM +0100, Peter Zijlstra wrote:
>
> On Wed, 2008-02-27 at 18:54 +0530, Dhaval Giani wrote:
> > + struct task_struct *p;
> > + for_each_process(p) {
> > + if (rt_task(p) && rt_rq_of_se(&p->rt)->tg == tg)
> > + return 1;
> > + }
>
> This should be a do_each_thread() { } while_each_thread(); iteration
> loop;
>
> cgroups are thread oriented, not task.
>
> Sorry for missing this earlier.
>
Nice catch! Sorry for the mistake, corrected patch follows.
---
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 as 0
or bad things will happen.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
---
kernel/sched.c | 17 +++++++++++++++++
1 files changed, 17 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 *g, *p;
+ do_each_thread(g, p) {
+ if (rt_task(p) && rt_rq_of_se(&p->rt)->tg == tg)
+ return 1;
+ } while_each_thread(g, p);
+ return 0;
+}
+
int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
{
u64 rt_runtime, rt_period;
@@ -7971,6 +7982,11 @@ 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 && tg_has_rt_tasks(tg)) {
+ err = -EINVAL;
+ goto unlock;
+ }
if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
err = -EINVAL;
goto unlock;
@@ -7979,6 +7995,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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-02-28 9:53 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-27 11:08 [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks Dhaval Giani
2008-02-27 12:46 ` Peter Zijlstra
2008-02-27 13:24 ` Dhaval Giani
2008-02-27 13:40 ` Peter Zijlstra
2008-02-27 14:11 ` Peter Zijlstra
2008-02-27 15:03 ` Ingo Molnar
2008-02-27 15:08 ` Peter Zijlstra
2008-02-27 15:10 ` Dhaval Giani
2008-02-27 21:47 ` Peter Zijlstra
2008-02-28 9:51 ` Dhaval Giani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox