lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 27 Feb 2008 18:54:59 +0530
From:	Dhaval Giani <dhaval@...ux.vnet.ibm.com>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Ingo Molnar <mingo@...e.hu>,
	Sudhir Kumar <skumar@...ux.vnet.ibm.com>,
	Balbir Singh <balbir@...ibm.com>,
	Aneesh Kumar KV <aneesh.kumar@...ux.vnet.ibm.com>,
	Srivatsa Vaddagiri <vatsa@...ux.vnet.ibm.com>,
	lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] sched: don't allow rt_runtime_us to be zero for groups
	having rt tasks

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@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ