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:	Fri, 16 Oct 2009 17:41:01 +0200
From:	Raistlin <raistlin@...ux.it>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	linux-kernel <linux-kernel@...r.kernel.org>,
	michael trimarchi <michael@...dence.eu.com>,
	Fabio Checconi <fabio@...dalf.sssup.it>,
	Ingo Molnar <mingo@...e.hu>,
	Thomas Gleixner <tglx@...utronix.de>,
	Dhaval Giani <dhaval.giani@...il.com>,
	Johan Eker <johan.eker@...csson.com>,
	"p.faure" <p.faure@...tech.ch>,
	Chris Friesen <cfriesen@...tel.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Henrik Austad <henrik@...tad.us>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Darren Hart <darren@...art.com>,
	Sven-Thorsten Dietrich <sven@...bigcorporation.com>,
	Bjoern Brandenburg <bbb@...unc.edu>,
	Tommaso Cucinotta <tommaso.cucinotta@...up.it>,
	"giuseppe.lipari" <giuseppe.lipari@...up.it>,
	Juri Lelli <juri.lelli@...il.com>
Subject: Re: [RFC 0/12][PATCH] SCHED_DEADLINE: fork and terminate task logic

This commits adds the code that make it possible for a SCHED_DEADLINE task
to fork a child and to correctly terminate.

The child of a SCHED_DEADLINE task is (if !reset_on_fork) SCHED_DEADLINE as
well, but it has no bandwidth and it thus can't even start running.
To make it run, some other task (e.g., the parent) should provide it with
valid SCHED_DEADLINE parameters.

Actually, this is one of the simplest alternatives we have here, but it might
not be the best one. Therefore, discussion on what the ``most natural''
behaviour is is still open and comments are welcome.

Signed-off-by: Raistlin <raistlin@...ux.it>
---
 kernel/sched.c          |   18 +++++++++++++++++-
 kernel/sched_deadline.c |   20 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index adf1414..243066e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2561,8 +2561,20 @@ void sched_fork(struct task_struct *p, int clone_flags)
 	 * Make sure we do not leak PI boosting priority to the child.
 	 */
 	p->prio = current->normal_prio;
+	if (deadline_task(p)) {
+		p->sched_class = &deadline_sched_class;
 
-	if (!rt_prio(p->prio))
+		/*
+		 * the child will be SCHED_DEADLINE, but with zero bandwidth.
+		 * The parent (or some other task) must call setscheduler_ex
+		 * on it, or it won't ever start.
+		 */
+		init_deadline_task(p);
+		p->dl.flags &= ~DL_NEW;
+		p->dl.flags |= DL_THROTTLED;
+	} else if (rt_prio(p->prio))
+		p->sched_class = &rt_sched_class;
+	else
 		p->sched_class = &fair_sched_class;
 
 #ifdef CONFIG_SMP
@@ -2744,6 +2756,10 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev)
 	if (mm)
 		mmdrop(mm);
 	if (unlikely(prev_state == TASK_DEAD)) {
+		/* a deadline task is dying: stop the bandwidth timer */
+		if (deadline_task(prev))
+			hrtimer_cancel(&prev->dl.dl_timer);
+
 		/*
 		 * Remove function-return probe instances associated with this
 		 * task and put them back on the free list.
diff --git a/kernel/sched_deadline.c b/kernel/sched_deadline.c
index 5430c48..b4be178 100644
--- a/kernel/sched_deadline.c
+++ b/kernel/sched_deadline.c
@@ -213,6 +213,26 @@ unlock:
 	return HRTIMER_NORESTART;
 }
 
+static void init_deadline_timer(struct hrtimer *timer)
+{
+	if (hrtimer_active(timer)) {
+		hrtimer_try_to_cancel(timer);
+		return;
+	}
+
+	hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	timer->function = deadline_timer;
+}
+
+static void init_deadline_task(struct task_struct *p)
+{
+	RB_CLEAR_NODE(&p->dl.rb_node);
+	init_deadline_timer(&p->dl.dl_timer);
+	p->dl.sched_runtime = p->dl.runtime = 0;
+	p->dl.sched_deadline = p->dl.deadline = 0;
+	p->dl.flags = p->dl.bw = 0;
+}
+
 static
 int deadline_runtime_exceeded(struct rq *rq, struct sched_dl_entity *dl_se)
 {
-- 
1.6.0.4

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
----------------------------------------------------------------------
Dario Faggioli, ReTiS Lab, Scuola Superiore Sant'Anna, Pisa  (Italy)

http://blog.linux.it/raistlin / raistlin@...ga.net /
dario.faggioli@...ber.org

Download attachment "signature.asc" of type "application/pgp-signature" (198 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ