public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* stable backport: sched: Fix migration thread runtime bogosity
@ 2012-10-10 19:24 Steven Rostedt
  2012-10-10 19:52 ` Greg Kroah-Hartman
  2012-10-14  9:27 ` Ben Hutchings
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2012-10-10 19:24 UTC (permalink / raw)
  To: LKML, stable
  Cc: Greg Kroah-Hartman, Ben Hutchings, Mike Galbraith, Peter Zijlstra,
	Thomas Gleixner

Greg, Ben,

Can you add this commit to the stable branches. Without it, the
migration thread's accounting is just totally screwed up:

By running a simple shell while loop along with a ps loop, top shows:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
   17 root      RT   0     0    0    0 S 9999.0  0.0   9:27.50 migration/3    
   13 root      RT   0     0    0    0 S 128.2  0.0   9:50.23 migration/2       
 2805 root      20   0  105m 1904 1416 S 13.9  0.1   0:06.69 bash               
 4090 root      20   0  105m 1904 1416 S  2.0  0.1   0:00.90 bash               
 2773 root      20   0 85484 3372 2620 S  0.3  0.2   0:00.03 sshd               


For 3.4, the commit can be directly cherry picked:

commit 8f6189684eb4e85e6c593cd710693f09c944450a
Author: Mike Galbraith <mgalbraith@suse.de>
Date:   Sat Aug 4 05:44:14 2012 +0200

    sched: Fix migration thread runtime bogosity

Below is a backport for 3.2.

Thanks! 

-- Steve

>From 8f6189684eb4e85e6c593cd710693f09c944450a Mon Sep 17 00:00:00 2001
From: Mike Galbraith <mgalbraith@suse.de>
Date: Sat, 4 Aug 2012 05:44:14 +0200
Subject: [PATCH] sched: Fix migration thread runtime bogosity

Make stop scheduler class do the same accounting as other classes,

Migration threads can be caught in the act while doing exec balancing,
leading to the below due to use of unmaintained ->se.exec_start.  The
load that triggered this particular instance was an apparently out of
control heavily threaded application that does system monitoring in
what equated to an exec bomb, with one of the VERY frequently migrated
tasks being ps.

%CPU   PID USER     CMD
99.3    45 root     [migration/10]
97.7    53 root     [migration/12]
97.0    57 root     [migration/13]
90.1    49 root     [migration/11]
89.6    65 root     [migration/15]
88.7    17 root     [migration/3]
80.4    37 root     [migration/8]
78.1    41 root     [migration/9]
44.2    13 root     [migration/2]

Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1344051854.6739.19.camel@marge.simpson.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/sched_stoptask.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

Index: linux-trace.git/kernel/sched_stoptask.c
===================================================================
--- linux-trace.git.orig/kernel/sched_stoptask.c
+++ linux-trace.git/kernel/sched_stoptask.c
@@ -25,8 +25,10 @@ static struct task_struct *pick_next_tas
 {
 	struct task_struct *stop = rq->stop;
 
-	if (stop && stop->on_rq)
+	if (stop && stop->on_rq) {
+		stop->se.exec_start = rq->clock_task;
 		return stop;
+	}
 
 	return NULL;
 }
@@ -50,6 +52,21 @@ static void yield_task_stop(struct rq *r
 
 static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)
 {
+	struct task_struct *curr = rq->curr;
+	u64 delta_exec;
+
+	delta_exec = rq->clock_task - curr->se.exec_start;
+	if (unlikely((s64)delta_exec < 0))
+		delta_exec = 0;
+
+	schedstat_set(curr->se.statistics.exec_max,
+			max(curr->se.statistics.exec_max, delta_exec));
+
+	curr->se.sum_exec_runtime += delta_exec;
+	account_group_exec_runtime(curr, delta_exec);
+
+	curr->se.exec_start = rq->clock_task;
+	cpuacct_charge(curr, delta_exec);
 }
 
 static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued)
@@ -58,6 +75,9 @@ static void task_tick_stop(struct rq *rq
 
 static void set_curr_task_stop(struct rq *rq)
 {
+	struct task_struct *stop = rq->stop;
+
+	stop->se.exec_start = rq->clock_task;
 }
 
 static void switched_to_stop(struct rq *rq, struct task_struct *p)



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

* Re: stable backport: sched: Fix migration thread runtime bogosity
  2012-10-10 19:24 stable backport: sched: Fix migration thread runtime bogosity Steven Rostedt
@ 2012-10-10 19:52 ` Greg Kroah-Hartman
  2012-10-14  9:27 ` Ben Hutchings
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2012-10-10 19:52 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, stable, Ben Hutchings, Mike Galbraith, Peter Zijlstra,
	Thomas Gleixner

On Wed, Oct 10, 2012 at 03:24:03PM -0400, Steven Rostedt wrote:
> Greg, Ben,
> 
> Can you add this commit to the stable branches. Without it, the
> migration thread's accounting is just totally screwed up:
> 
> By running a simple shell while loop along with a ps loop, top shows:
> 
>   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
>    17 root      RT   0     0    0    0 S 9999.0  0.0   9:27.50 migration/3    
>    13 root      RT   0     0    0    0 S 128.2  0.0   9:50.23 migration/2       
>  2805 root      20   0  105m 1904 1416 S 13.9  0.1   0:06.69 bash               
>  4090 root      20   0  105m 1904 1416 S  2.0  0.1   0:00.90 bash               
>  2773 root      20   0 85484 3372 2620 S  0.3  0.2   0:00.03 sshd               
> 
> 
> For 3.4, the commit can be directly cherry picked:
> 
> commit 8f6189684eb4e85e6c593cd710693f09c944450a
> Author: Mike Galbraith <mgalbraith@suse.de>
> Date:   Sat Aug 4 05:44:14 2012 +0200
> 
>     sched: Fix migration thread runtime bogosity

Now applied to 3.4-stable queue.

greg k-h

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

* Re: stable backport: sched: Fix migration thread runtime bogosity
  2012-10-10 19:24 stable backport: sched: Fix migration thread runtime bogosity Steven Rostedt
  2012-10-10 19:52 ` Greg Kroah-Hartman
@ 2012-10-14  9:27 ` Ben Hutchings
  1 sibling, 0 replies; 3+ messages in thread
From: Ben Hutchings @ 2012-10-14  9:27 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, stable, Greg Kroah-Hartman, Mike Galbraith, Peter Zijlstra,
	Thomas Gleixner

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

On Wed, 2012-10-10 at 15:24 -0400, Steven Rostedt wrote:
> Greg, Ben,
> 
> Can you add this commit to the stable branches. Without it, the
> migration thread's accounting is just totally screwed up:
> 
> By running a simple shell while loop along with a ps loop, top shows:
> 
>   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
>    17 root      RT   0     0    0    0 S 9999.0  0.0   9:27.50 migration/3    
>    13 root      RT   0     0    0    0 S 128.2  0.0   9:50.23 migration/2       
>  2805 root      20   0  105m 1904 1416 S 13.9  0.1   0:06.69 bash               
>  4090 root      20   0  105m 1904 1416 S  2.0  0.1   0:00.90 bash               
>  2773 root      20   0 85484 3372 2620 S  0.3  0.2   0:00.03 sshd               
> 
> 
> For 3.4, the commit can be directly cherry picked:
> 
> commit 8f6189684eb4e85e6c593cd710693f09c944450a
> Author: Mike Galbraith <mgalbraith@suse.de>
> Date:   Sat Aug 4 05:44:14 2012 +0200
> 
>     sched: Fix migration thread runtime bogosity
> 
> Below is a backport for 3.2.
[...]

Queued up for 3.2, thanks.

Ben.

-- 
Ben Hutchings
Always try to do things in chronological order;
it's less confusing that way.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2012-10-14  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-10 19:24 stable backport: sched: Fix migration thread runtime bogosity Steven Rostedt
2012-10-10 19:52 ` Greg Kroah-Hartman
2012-10-14  9:27 ` Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox