linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [parch] sched: task_times() explosion avoidance for tasks with > 2^32 acrued ticks
@ 2012-08-06 13:58 Mike Galbraith
  2012-08-07  6:30 ` Mike Galbraith
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Galbraith @ 2012-08-06 13:58 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra


If stime + utime > 2^32, and lower 32 are 0 when user calls getrusage(),
you've got a dead box.

Signed-off-by: Mike Galbraith <efault@gmx.de>

 kernel/sched/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 82ad284..0ac2cac 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3151,7 +3151,7 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
 	 */
 	rtime = nsecs_to_cputime(p->se.sum_exec_runtime);
 
-	if (total) {
+	if (total && total == (__force u32) total) {
 		u64 temp = (__force u64) rtime;
 
 		temp *= (__force u64) utime;
@@ -3184,7 +3184,7 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
 	total = cputime.utime + cputime.stime;
 	rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
 
-	if (total) {
+	if (total && total == (__force u32) total) {
 		u64 temp = (__force u64) rtime;
 
 		temp *= (__force u64) cputime.utime;



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [parch] sched: task_times() explosion avoidance for tasks with > 2^32 acrued ticks
  2012-08-06 13:58 [parch] sched: task_times() explosion avoidance for tasks with > 2^32 acrued ticks Mike Galbraith
@ 2012-08-07  6:30 ` Mike Galbraith
  2012-08-07  8:02   ` [patch] sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled Mike Galbraith
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Galbraith @ 2012-08-07  6:30 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra

Wrong xx.

sched: task_times() explosion avoidance for tasks with > 2^32 accrued ticks

If stime + utime > 2^32, and lower 32 are 0 when user calls getrusage(),
you've got a dead box.

Signed-off-by: Mike Galbraith <efault@gmx.de>

 kernel/sched/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 82ad284..b0b0d29 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3155,7 +3155,7 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
 		u64 temp = (__force u64) rtime;
 
 		temp *= (__force u64) utime;
-		do_div(temp, (__force u32) total);
+		temp = div64_u64(temp, (__force u64) total);
 		utime = (__force cputime_t) temp;
 	} else
 		utime = rtime;
@@ -3188,7 +3188,7 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
 		u64 temp = (__force u64) rtime;
 
 		temp *= (__force u64) cputime.utime;
-		do_div(temp, (__force u32) total);
+		temp = div64_u64(temp, (__force u64) total);
 		utime = (__force cputime_t) temp;
 	} else
 		utime = rtime;



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled
  2012-08-07  6:30 ` Mike Galbraith
@ 2012-08-07  8:02   ` Mike Galbraith
  2012-08-13 16:52     ` [tip:sched/urgent] " tip-bot for Mike Galbraith
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Galbraith @ 2012-08-07  8:02 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra

Speaking of old "parches" lying about, the below fixes a real problem if
you're using either 'should die' isolcpus or 'should work' cpusets to
isolate cores.

sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled

Root task group bandwidth replenishment must service all CPUs, regardless of
where the timer was last started, and regardless of the isolation mechanism,
lest 'Quoth the Raven, "Nevermore"' become rt scheduling policy.

Signed-off-by: Mike Galbraith <efault@gmx.de>
---
 kernel/sched/rt.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -788,6 +788,19 @@ static int do_sched_rt_period_timer(stru
 	const struct cpumask *span;
 
 	span = sched_rt_period_mask();
+#ifdef CONFIG_RT_GROUP_SCHED
+	/*
+	 * FIXME: isolated CPUs should really leave the root task group,
+	 * whether they are isolcpus or were isolated via cpusets, lest
+	 * the timer run on a CPU which does not service all runqueues,
+	 * potentially leaving other CPUs indefinitely throttled.  If
+	 * isolation is really required, the user will turn the throttle
+	 * off to kill the perturbations it causes anyway.  Meanwhile,
+	 * this maintains functionality for boot and/or troubleshooting.
+	 */
+	if (rt_b == &root_task_group.rt_bandwidth)
+		span = cpu_online_mask;
+#endif
 	for_each_cpu(i, span) {
 		int enqueue = 0;
 		struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:sched/urgent] sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled
  2012-08-07  8:02   ` [patch] sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled Mike Galbraith
@ 2012-08-13 16:52     ` tip-bot for Mike Galbraith
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Mike Galbraith @ 2012-08-13 16:52 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, a.p.zijlstra, efault, tglx

Commit-ID:  e221d028bb08b47e624c5f0a31732c642db9d19a
Gitweb:     http://git.kernel.org/tip/e221d028bb08b47e624c5f0a31732c642db9d19a
Author:     Mike Galbraith <efault@gmx.de>
AuthorDate: Tue, 7 Aug 2012 10:02:38 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 13 Aug 2012 18:41:55 +0200

sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled

Root task group bandwidth replenishment must service all CPUs, regardless of
where the timer was last started, and regardless of the isolation mechanism,
lest 'Quoth the Raven, "Nevermore"' become rt scheduling policy.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1344326558.6968.25.camel@marge.simpson.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/sched/rt.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 573e1ca..944cb68 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -788,6 +788,19 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 	const struct cpumask *span;
 
 	span = sched_rt_period_mask();
+#ifdef CONFIG_RT_GROUP_SCHED
+	/*
+	 * FIXME: isolated CPUs should really leave the root task group,
+	 * whether they are isolcpus or were isolated via cpusets, lest
+	 * the timer run on a CPU which does not service all runqueues,
+	 * potentially leaving other CPUs indefinitely throttled.  If
+	 * isolation is really required, the user will turn the throttle
+	 * off to kill the perturbations it causes anyway.  Meanwhile,
+	 * this maintains functionality for boot and/or troubleshooting.
+	 */
+	if (rt_b == &root_task_group.rt_bandwidth)
+		span = cpu_online_mask;
+#endif
 	for_each_cpu(i, span) {
 		int enqueue = 0;
 		struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-13 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-06 13:58 [parch] sched: task_times() explosion avoidance for tasks with > 2^32 acrued ticks Mike Galbraith
2012-08-07  6:30 ` Mike Galbraith
2012-08-07  8:02   ` [patch] sched,rt: fix isolated CPUs leaving root_task_group indefinitely throttled Mike Galbraith
2012-08-13 16:52     ` [tip:sched/urgent] " tip-bot for Mike Galbraith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).