public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Sudhir Kumar <skumar@linux.vnet.ibm.com>,
	Balbir Singh <balbir@in.ibm.com>,
	Aneesh Kumar KV <aneesh.kumar@linux.vnet.ibm.com>,
	Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks
Date: Wed, 27 Feb 2008 13:46:56 +0100	[thread overview]
Message-ID: <1204116417.6242.383.camel@lappy> (raw)
In-Reply-To: <20080227110829.GA15731@linux.vnet.ibm.com>


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;


  reply	other threads:[~2008-02-27 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1204116417.6242.383.camel@lappy \
    --to=a.p.zijlstra@chello.nl \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=balbir@in.ibm.com \
    --cc=dhaval@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=skumar@linux.vnet.ibm.com \
    --cc=vatsa@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox