All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	containers@lists.linux-foundation.org, stable@kernel.org,
	Nathan Lynch <ntl@pobox.com>,
	linux-pm@lists.linux-foundation.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>
Subject: [patch 2/2] sched: fix nr_uninterruptible accounting of frozen tasks	really
Date: Fri, 17 Jul 2009 12:25:01 -0000	[thread overview]
Message-ID: <20090717122103.225652146@linutronix.de> (raw)
In-Reply-To: 20090717121545.489258927@linutronix.de

[-- Attachment #1: freezer-fix-accounting-for-real.patch --]
[-- Type: text/plain, Size: 2857 bytes --]

commit e3c8ca8336 (sched: do not count frozen tasks toward load) broke
the nr_uninterruptible accounting on freeze/thaw. On freeze the task
is excluded from accounting with a check for (task->flags &
PF_FROZEN), but that flag is cleared before the task is thawed. So
while we prevent that the freezing task with state
TASK_UNINTERRUPTIBLE is accounted to nr_uninterruptible we decrement
nr_uninterruptible on thaw.

Use a separate flag which is handled by the freezing task itself. Set
it before calling the scheduler with TASK_UNINTERRUPTIBLE state and
clear it after we return from frozen state.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Nathan Lynch <ntl@pobox.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nigel Cunningham <nigel@tuxonice.net>
Cc: <stable@kernel.org>
Cc: containers@lists.linux-foundation.org
Cc: linux-pm@lists.linux-foundation.org
Cc: Matt Helsley <matthltc@us.ibm.com>

---
 include/linux/sched.h |    3 ++-
 kernel/freezer.c      |    7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -209,7 +209,7 @@ extern unsigned long long time_sync_thre
 			((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
 #define task_contributes_to_load(task)	\
 				((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
-				 (task->flags & PF_FROZEN) == 0)
+				 (task->flags & PF_FREEZING) == 0)
 
 #define __set_task_state(tsk, state_value)		\
 	do { (tsk)->state = (state_value); } while (0)
@@ -1680,6 +1680,7 @@ extern cputime_t task_gtime(struct task_
 #define PF_MEMALLOC	0x00000800	/* Allocating memory */
 #define PF_FLUSHER	0x00001000	/* responsible for disk writeback */
 #define PF_USED_MATH	0x00002000	/* if unset the fpu must be initialized before use */
+#define PF_FREEZING	0x00004000	/* freeze in progress. do not account to load */
 #define PF_NOFREEZE	0x00008000	/* this thread should not be frozen */
 #define PF_FROZEN	0x00010000	/* frozen for system suspend */
 #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
Index: linux-2.6/kernel/freezer.c
===================================================================
--- linux-2.6.orig/kernel/freezer.c
+++ linux-2.6/kernel/freezer.c
@@ -44,12 +44,19 @@ void refrigerator(void)
 	recalc_sigpending(); /* We sent fake signal, clean it up */
 	spin_unlock_irq(&current->sighand->siglock);
 
+	/* prevent accounting of that task to load */
+	current->flags |= PF_FREEZING;
+
 	for (;;) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (!frozen(current))
 			break;
 		schedule();
 	}
+
+	/* Remove the accounting blocker */
+	current->flags &= ~PF_FREEZING;
+
 	pr_debug("%s left refrigerator\n", current->comm);
 	__set_current_state(save);
 }

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Rafael Wysocki <rjw@sisk.pl>, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Nathan Lynch <ntl@pobox.com>,
	Nigel Cunningham <nigel@tuxonice.net>, <stable@kernel.org>,
	containers@lists.linux-foundation.org,
	linux-pm@lists.linux-foundation.org,
	Matt Helsley <matthltc@us.ibm.com>
Subject: [patch 2/2] sched: fix nr_uninterruptible accounting of frozen tasks really
Date: Fri, 17 Jul 2009 12:25:01 -0000	[thread overview]
Message-ID: <20090717122103.225652146@linutronix.de> (raw)
In-Reply-To: 20090717121545.489258927@linutronix.de

[-- Attachment #1: freezer-fix-accounting-for-real.patch --]
[-- Type: text/plain, Size: 2859 bytes --]

commit e3c8ca8336 (sched: do not count frozen tasks toward load) broke
the nr_uninterruptible accounting on freeze/thaw. On freeze the task
is excluded from accounting with a check for (task->flags &
PF_FROZEN), but that flag is cleared before the task is thawed. So
while we prevent that the freezing task with state
TASK_UNINTERRUPTIBLE is accounted to nr_uninterruptible we decrement
nr_uninterruptible on thaw.

Use a separate flag which is handled by the freezing task itself. Set
it before calling the scheduler with TASK_UNINTERRUPTIBLE state and
clear it after we return from frozen state.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Nathan Lynch <ntl@pobox.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nigel Cunningham <nigel@tuxonice.net>
Cc: <stable@kernel.org>
Cc: containers@lists.linux-foundation.org
Cc: linux-pm@lists.linux-foundation.org
Cc: Matt Helsley <matthltc@us.ibm.com>

---
 include/linux/sched.h |    3 ++-
 kernel/freezer.c      |    7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -209,7 +209,7 @@ extern unsigned long long time_sync_thre
 			((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
 #define task_contributes_to_load(task)	\
 				((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
-				 (task->flags & PF_FROZEN) == 0)
+				 (task->flags & PF_FREEZING) == 0)
 
 #define __set_task_state(tsk, state_value)		\
 	do { (tsk)->state = (state_value); } while (0)
@@ -1680,6 +1680,7 @@ extern cputime_t task_gtime(struct task_
 #define PF_MEMALLOC	0x00000800	/* Allocating memory */
 #define PF_FLUSHER	0x00001000	/* responsible for disk writeback */
 #define PF_USED_MATH	0x00002000	/* if unset the fpu must be initialized before use */
+#define PF_FREEZING	0x00004000	/* freeze in progress. do not account to load */
 #define PF_NOFREEZE	0x00008000	/* this thread should not be frozen */
 #define PF_FROZEN	0x00010000	/* frozen for system suspend */
 #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
Index: linux-2.6/kernel/freezer.c
===================================================================
--- linux-2.6.orig/kernel/freezer.c
+++ linux-2.6/kernel/freezer.c
@@ -44,12 +44,19 @@ void refrigerator(void)
 	recalc_sigpending(); /* We sent fake signal, clean it up */
 	spin_unlock_irq(&current->sighand->siglock);
 
+	/* prevent accounting of that task to load */
+	current->flags |= PF_FREEZING;
+
 	for (;;) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (!frozen(current))
 			break;
 		schedule();
 	}
+
+	/* Remove the accounting blocker */
+	current->flags &= ~PF_FREEZING;
+
 	pr_debug("%s left refrigerator\n", current->comm);
 	__set_current_state(save);
 }



  parent reply	other threads:[~2009-07-17 12:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-17 12:24 [patch 0/2] fix load average accounting Thomas Gleixner
2009-07-17 12:24 ` [patch 1/2] sched: fix load average accounting vs. cpu hotplug Thomas Gleixner
2009-07-17 12:25 ` [patch 2/2] sched: fix nr_uninterruptible accounting of frozen tasks really Thomas Gleixner
2009-07-17 12:25 ` Thomas Gleixner [this message]
2009-07-17 12:25   ` Thomas Gleixner
2009-07-17 12:31   ` Peter Zijlstra
2009-07-17 12:31   ` Peter Zijlstra
2009-07-17 12:48     ` Thomas Gleixner
2009-07-17 12:48     ` Thomas Gleixner
     [not found]       ` <alpine.LFD.2.00.0907171441020.11571-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-17 22:26         ` Nigel Cunningham
2009-07-17 22:26       ` Nigel Cunningham
2009-07-17 22:26       ` Nigel Cunningham
2009-07-17 12:48     ` Thomas Gleixner
2009-07-17 15:22     ` Matt Helsley
2009-07-17 15:22     ` Matt Helsley
2009-07-17 16:47       ` Peter Zijlstra
     [not found]       ` <20090717152235.GA5878-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-17 16:47         ` Peter Zijlstra
2009-07-17 16:47           ` Peter Zijlstra
2009-07-17 20:55           ` Nathan Lynch
2009-07-18 12:56             ` Peter Zijlstra
     [not found]             ` <1247864134.17553.30.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-18 12:56               ` Peter Zijlstra
2009-07-18 12:56                 ` Peter Zijlstra
2009-07-18 23:59                 ` Nathan Lynch
2009-07-18 23:59                 ` Nathan Lynch
2009-07-18 23:59                   ` Nathan Lynch
2009-07-17 20:55           ` Nathan Lynch
2009-07-17 20:55           ` Nathan Lynch
2009-07-17 15:22     ` Matt Helsley
     [not found]   ` <20090717122103.225652146-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2009-07-17 12:31     ` Peter Zijlstra
2009-07-17 15:51     ` Matt Helsley
2009-07-17 20:54     ` Nathan Lynch
2009-07-17 15:51   ` Matt Helsley
2009-07-17 15:55     ` Peter Zijlstra
2009-07-17 16:20       ` Matt Helsley
2009-07-17 16:20       ` Matt Helsley
2009-07-17 16:20       ` Matt Helsley
2009-07-17 15:55     ` Peter Zijlstra
     [not found]     ` <20090717155116.GB5878-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-17 15:55       ` Peter Zijlstra
2009-07-17 15:51   ` Matt Helsley
2009-07-17 20:54   ` Nathan Lynch
2009-07-17 20:54   ` Nathan Lynch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090717122103.225652146@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mingo@elte.hu \
    --cc=ntl@pobox.com \
    --cc=peterz@infradead.org \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.