Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757702AbYB0Mrd (ORCPT ); Wed, 27 Feb 2008 07:47:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757037AbYB0MrX (ORCPT ); Wed, 27 Feb 2008 07:47:23 -0500 Received: from pentafluge.infradead.org ([213.146.154.40]:56676 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755022AbYB0MrW (ORCPT ); Wed, 27 Feb 2008 07:47:22 -0500 Subject: Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups having rt tasks From: Peter Zijlstra To: Dhaval Giani Cc: Ingo Molnar , Sudhir Kumar , Balbir Singh , Aneesh Kumar KV , Srivatsa Vaddagiri , lkml In-Reply-To: <20080227110829.GA15731@linux.vnet.ibm.com> References: <20080227110829.GA15731@linux.vnet.ibm.com> Content-Type: text/plain Date: Wed, 27 Feb 2008 13:46:56 +0100 Message-Id: <1204116417.6242.383.camel@lappy> Mime-Version: 1.0 X-Mailer: Evolution 2.21.90 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2084 Lines: 70 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 > --- > 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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/