All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] a perf and some sched patches
@ 2009-12-17 12:16 Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 1/6] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits Peter Zijlstra
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML

Fixes an issue with the per-task-per-cpu counters, reported by acme.
Fixes an false positive in the set_task_cpu() debug check, reported by Ingo.
Fixes up the task->state to char bits, gumbled at by tglx.


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

* [PATCH 1/6] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
@ 2009-12-17 12:16 ` Peter Zijlstra
  2009-12-17 12:30   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 2/6] sched: Add missing state chars to TASK_STATE_TO_CHAR_STR Peter Zijlstra
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Peter Zijlstra

[-- Attachment #1: sched-state.patch --]
[-- Type: text/plain, Size: 924 bytes --]

So that we don't keep forgetting about it

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 include/linux/sched.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -193,6 +193,8 @@ print_cfs_rq(struct seq_file *m, int cpu
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256
 
+#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
+
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
 #define TASK_STOPPED		(TASK_WAKEKILL | __TASK_STOPPED)
@@ -2595,8 +2597,6 @@ static inline void mm_init_owner(struct 
 }
 #endif /* CONFIG_MM_OWNER */
 
-#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
-
 #endif /* __KERNEL__ */
 
 #endif

-- 


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

* [PATCH 2/6] sched: Add missing state chars to TASK_STATE_TO_CHAR_STR
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 1/6] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits Peter Zijlstra
@ 2009-12-17 12:16 ` Peter Zijlstra
  2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 3/6] sched: Update task_state_arraypwith new states Peter Zijlstra
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Peter Zijlstra

[-- Attachment #1: sched-state-1.patch --]
[-- Type: text/plain, Size: 756 bytes --]

We grew 3 new task states since the last time someone touched it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 include/linux/sched.h |    2 +-
 1 file changed, 1 insertion(+), 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
@@ -193,7 +193,7 @@ print_cfs_rq(struct seq_file *m, int cpu
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256
 
-#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
+#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
 
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)

-- 


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

* [PATCH 3/6] sched: Update task_state_arraypwith new states
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 1/6] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 2/6] sched: Add missing state chars to TASK_STATE_TO_CHAR_STR Peter Zijlstra
@ 2009-12-17 12:16 ` Peter Zijlstra
  2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 4/6] sched: Assert task state bits at build time Peter Zijlstra
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Peter Zijlstra

[-- Attachment #1: sched-state-2.patch --]
[-- Type: text/plain, Size: 841 bytes --]

Neglected because its hidden... (who reads comments anyway)

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 fs/proc/array.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6/fs/proc/array.c
===================================================================
--- linux-2.6.orig/fs/proc/array.c
+++ linux-2.6/fs/proc/array.c
@@ -138,9 +138,12 @@ static const char *task_state_array[] = 
 	"S (sleeping)",		/*  1 */
 	"D (disk sleep)",	/*  2 */
 	"T (stopped)",		/*  4 */
-	"T (tracing stop)",	/*  8 */
+	"t (tracing stop)",	/*  8 */
 	"Z (zombie)",		/* 16 */
-	"X (dead)"		/* 32 */
+	"X (dead)",		/* 32 */
+	"x (dead)",		/* 64 */
+	"K (wakekill)",		/* 128 */
+	"W (waking)",		/* 256 */
 };
 
 static inline const char *get_task_state(struct task_struct *tsk)

-- 


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

* [PATCH 4/6] sched: Assert task state bits at build time
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
                   ` (2 preceding siblings ...)
  2009-12-17 12:16 ` [PATCH 3/6] sched: Update task_state_arraypwith new states Peter Zijlstra
@ 2009-12-17 12:16 ` Peter Zijlstra
  2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 5/6] sched: Fix broken assertion Peter Zijlstra
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Peter Zijlstra

[-- Attachment #1: sched-state-3.patch --]
[-- Type: text/plain, Size: 2104 bytes --]

Since everybody is lazy and prone to forgetting things, make the
compiler help us a bit.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 fs/proc/array.c       |   18 ++++++++++--------
 include/linux/sched.h |    4 ++++
 2 files changed, 14 insertions(+), 8 deletions(-)

Index: linux-2.6/fs/proc/array.c
===================================================================
--- linux-2.6.orig/fs/proc/array.c
+++ linux-2.6/fs/proc/array.c
@@ -134,14 +134,14 @@ static inline void task_name(struct seq_
  * simple bit tests.
  */
 static const char *task_state_array[] = {
-	"R (running)",		/*  0 */
-	"S (sleeping)",		/*  1 */
-	"D (disk sleep)",	/*  2 */
-	"T (stopped)",		/*  4 */
-	"t (tracing stop)",	/*  8 */
-	"Z (zombie)",		/* 16 */
-	"X (dead)",		/* 32 */
-	"x (dead)",		/* 64 */
+	"R (running)",		/*   0 */
+	"S (sleeping)",		/*   1 */
+	"D (disk sleep)",	/*   2 */
+	"T (stopped)",		/*   4 */
+	"t (tracing stop)",	/*   8 */
+	"Z (zombie)",		/*  16 */
+	"X (dead)",		/*  32 */
+	"x (dead)",		/*  64 */
 	"K (wakekill)",		/* 128 */
 	"W (waking)",		/* 256 */
 };
@@ -151,6 +151,8 @@ static inline const char *get_task_state
 	unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
 	const char **p = &task_state_array[0];
 
+	BUILD_BUG_ON(1 + ilog2(TASK_STATE_MAX) != ARRAY_SIZE(task_state_array));
+
 	while (state) {
 		p++;
 		state >>= 1;
Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -192,9 +192,13 @@ print_cfs_rq(struct seq_file *m, int cpu
 #define TASK_DEAD		64
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256
+#define TASK_STATE_MAX		512
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
 
+extern char ___assert_task_state[1 - 2*!!(
+		sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
+
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
 #define TASK_STOPPED		(TASK_WAKEKILL | __TASK_STOPPED)

-- 


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

* [PATCH 5/6] sched: Fix broken assertion
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
                   ` (3 preceding siblings ...)
  2009-12-17 12:16 ` [PATCH 4/6] sched: Assert task state bits at build time Peter Zijlstra
@ 2009-12-17 12:16 ` Peter Zijlstra
  2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
  2009-12-17 12:16 ` [PATCH 6/6] perf: Dont report side-band events on each cpu for per-task-per-cpu events Peter Zijlstra
  2009-12-17 12:23 ` [PATCH 0/6] a perf and some sched patches Ingo Molnar
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Peter Zijlstra

[-- Attachment #1: foo14.patch --]
[-- Type: text/plain, Size: 987 bytes --]

There's a preemption race in the set_task_cpu() debug check in that
when we get preempted after setting task->state we'd still be on the
rq proper, but fail the test.

Check for preempted tasks, since those are always on the RQ.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 kernel/sched.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -2041,7 +2041,8 @@ void set_task_cpu(struct task_struct *p,
 	 * We should never call set_task_cpu() on a blocked task,
 	 * ttwu() will sort out the placement.
 	 */
-	WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING);
+	WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING &&
+			!(task_thread_info(p)->preempt_count & PREEMPT_ACTIVE));
 #endif
 
 	trace_sched_migrate_task(p, new_cpu);

-- 


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

* [PATCH 6/6] perf: Dont report side-band events on each cpu for per-task-per-cpu events
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
                   ` (4 preceding siblings ...)
  2009-12-17 12:16 ` [PATCH 5/6] sched: Fix broken assertion Peter Zijlstra
@ 2009-12-17 12:16 ` Peter Zijlstra
  2009-12-17 12:30   ` [tip:perf/urgent] perf events: " tip-bot for Peter Zijlstra
  2009-12-17 12:23 ` [PATCH 0/6] a perf and some sched patches Ingo Molnar
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2009-12-17 12:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Peter Zijlstra, Paul Mackerras

[-- Attachment #1: perf4.patch --]
[-- Type: text/plain, Size: 3283 bytes --]

Acme noticed that his FORK/MMAP numbers were inflated by about the
same factor as his cpu-count.

This led to the discovery of a few more sites that need to respect the
event->cpu filter.

Reported-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
---
 kernel/perf_event.c |   32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -1381,6 +1381,9 @@ static void perf_ctx_adjust_freq(struct 
 		if (event->state != PERF_EVENT_STATE_ACTIVE)
 			continue;
 
+		if (event->cpu != -1 && event->cpu != smp_processor_id())
+			continue;
+
 		hwc = &event->hw;
 
 		interrupts = hwc->interrupts;
@@ -3265,6 +3268,9 @@ static void perf_event_task_output(struc
 
 static int perf_event_task_match(struct perf_event *event)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (event->attr.comm || event->attr.mmap || event->attr.task)
 		return 1;
 
@@ -3290,12 +3296,11 @@ static void perf_event_task_event(struct
 	rcu_read_lock();
 	cpuctx = &get_cpu_var(perf_cpu_context);
 	perf_event_task_ctx(&cpuctx->ctx, task_event);
-	put_cpu_var(perf_cpu_context);
-
 	if (!ctx)
 		ctx = rcu_dereference(task_event->task->perf_event_ctxp);
 	if (ctx)
 		perf_event_task_ctx(ctx, task_event);
+	put_cpu_var(perf_cpu_context);
 	rcu_read_unlock();
 }
 
@@ -3372,6 +3377,9 @@ static void perf_event_comm_output(struc
 
 static int perf_event_comm_match(struct perf_event *event)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (event->attr.comm)
 		return 1;
 
@@ -3408,15 +3416,10 @@ static void perf_event_comm_event(struct
 	rcu_read_lock();
 	cpuctx = &get_cpu_var(perf_cpu_context);
 	perf_event_comm_ctx(&cpuctx->ctx, comm_event);
-	put_cpu_var(perf_cpu_context);
-
-	/*
-	 * doesn't really matter which of the child contexts the
-	 * events ends up in.
-	 */
 	ctx = rcu_dereference(current->perf_event_ctxp);
 	if (ctx)
 		perf_event_comm_ctx(ctx, comm_event);
+	put_cpu_var(perf_cpu_context);
 	rcu_read_unlock();
 }
 
@@ -3491,6 +3494,9 @@ static void perf_event_mmap_output(struc
 static int perf_event_mmap_match(struct perf_event *event,
 				   struct perf_mmap_event *mmap_event)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (event->attr.mmap)
 		return 1;
 
@@ -3564,15 +3570,10 @@ got_name:
 	rcu_read_lock();
 	cpuctx = &get_cpu_var(perf_cpu_context);
 	perf_event_mmap_ctx(&cpuctx->ctx, mmap_event);
-	put_cpu_var(perf_cpu_context);
-
-	/*
-	 * doesn't really matter which of the child contexts the
-	 * events ends up in.
-	 */
 	ctx = rcu_dereference(current->perf_event_ctxp);
 	if (ctx)
 		perf_event_mmap_ctx(ctx, mmap_event);
+	put_cpu_var(perf_cpu_context);
 	rcu_read_unlock();
 
 	kfree(buf);
@@ -3863,6 +3864,9 @@ static int perf_swevent_match(struct per
 				struct perf_sample_data *data,
 				struct pt_regs *regs)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (!perf_swevent_is_counting(event))
 		return 0;
 

-- 


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

* Re: [PATCH 0/6] a perf and some sched patches
  2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
                   ` (5 preceding siblings ...)
  2009-12-17 12:16 ` [PATCH 6/6] perf: Dont report side-band events on each cpu for per-task-per-cpu events Peter Zijlstra
@ 2009-12-17 12:23 ` Ingo Molnar
  6 siblings, 0 replies; 14+ messages in thread
From: Ingo Molnar @ 2009-12-17 12:23 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Thomas Gleixner, LKML, Mike Galbraith


* Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:

> Fixes an issue with the per-task-per-cpu counters, reported by acme. Fixes 
> an false positive in the set_task_cpu() debug check, reported by Ingo. Fixes 
> up the task->state to char bits, gumbled at by tglx.

Applied, thanks Peter!

	Ingo

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

* [tip:perf/urgent] perf events: Dont report side-band events on each cpu for per-task-per-cpu events
  2009-12-17 12:16 ` [PATCH 6/6] perf: Dont report side-band events on each cpu for per-task-per-cpu events Peter Zijlstra
@ 2009-12-17 12:30   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-12-17 12:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, hpa, mingo, a.p.zijlstra, acme, tglx, mingo

Commit-ID:  5d27c23df09b702868d9a3bff86ec6abd22963ac
Gitweb:     http://git.kernel.org/tip/5d27c23df09b702868d9a3bff86ec6abd22963ac
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Thu, 17 Dec 2009 13:16:32 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 13:21:36 +0100

perf events: Dont report side-band events on each cpu for per-task-per-cpu events

Acme noticed that his FORK/MMAP numbers were inflated by about
the same factor as his cpu-count.

This led to the discovery of a few more sites that need to
respect the event->cpu filter.

Reported-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <20091217121830.215333434@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/perf_event.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 8ab8698..03cc061 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1381,6 +1381,9 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
 		if (event->state != PERF_EVENT_STATE_ACTIVE)
 			continue;
 
+		if (event->cpu != -1 && event->cpu != smp_processor_id())
+			continue;
+
 		hwc = &event->hw;
 
 		interrupts = hwc->interrupts;
@@ -3265,6 +3268,9 @@ static void perf_event_task_output(struct perf_event *event,
 
 static int perf_event_task_match(struct perf_event *event)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (event->attr.comm || event->attr.mmap || event->attr.task)
 		return 1;
 
@@ -3290,12 +3296,11 @@ static void perf_event_task_event(struct perf_task_event *task_event)
 	rcu_read_lock();
 	cpuctx = &get_cpu_var(perf_cpu_context);
 	perf_event_task_ctx(&cpuctx->ctx, task_event);
-	put_cpu_var(perf_cpu_context);
-
 	if (!ctx)
 		ctx = rcu_dereference(task_event->task->perf_event_ctxp);
 	if (ctx)
 		perf_event_task_ctx(ctx, task_event);
+	put_cpu_var(perf_cpu_context);
 	rcu_read_unlock();
 }
 
@@ -3372,6 +3377,9 @@ static void perf_event_comm_output(struct perf_event *event,
 
 static int perf_event_comm_match(struct perf_event *event)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (event->attr.comm)
 		return 1;
 
@@ -3408,15 +3416,10 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
 	rcu_read_lock();
 	cpuctx = &get_cpu_var(perf_cpu_context);
 	perf_event_comm_ctx(&cpuctx->ctx, comm_event);
-	put_cpu_var(perf_cpu_context);
-
-	/*
-	 * doesn't really matter which of the child contexts the
-	 * events ends up in.
-	 */
 	ctx = rcu_dereference(current->perf_event_ctxp);
 	if (ctx)
 		perf_event_comm_ctx(ctx, comm_event);
+	put_cpu_var(perf_cpu_context);
 	rcu_read_unlock();
 }
 
@@ -3491,6 +3494,9 @@ static void perf_event_mmap_output(struct perf_event *event,
 static int perf_event_mmap_match(struct perf_event *event,
 				   struct perf_mmap_event *mmap_event)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (event->attr.mmap)
 		return 1;
 
@@ -3564,15 +3570,10 @@ got_name:
 	rcu_read_lock();
 	cpuctx = &get_cpu_var(perf_cpu_context);
 	perf_event_mmap_ctx(&cpuctx->ctx, mmap_event);
-	put_cpu_var(perf_cpu_context);
-
-	/*
-	 * doesn't really matter which of the child contexts the
-	 * events ends up in.
-	 */
 	ctx = rcu_dereference(current->perf_event_ctxp);
 	if (ctx)
 		perf_event_mmap_ctx(ctx, mmap_event);
+	put_cpu_var(perf_cpu_context);
 	rcu_read_unlock();
 
 	kfree(buf);
@@ -3863,6 +3864,9 @@ static int perf_swevent_match(struct perf_event *event,
 				struct perf_sample_data *data,
 				struct pt_regs *regs)
 {
+	if (event->cpu != -1 && event->cpu != smp_processor_id())
+		return 0;
+
 	if (!perf_swevent_is_counting(event))
 		return 0;
 

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

* [tip:sched/urgent] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits
  2009-12-17 12:16 ` [PATCH 1/6] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits Peter Zijlstra
@ 2009-12-17 12:30   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-12-17 12:30 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  733421516b42c44b9e21f1793c430cc801ef8324
Gitweb:     http://git.kernel.org/tip/733421516b42c44b9e21f1793c430cc801ef8324
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Thu, 17 Dec 2009 13:16:27 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 13:22:43 +0100

sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits

So that we don't keep forgetting about it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091217121829.815779372@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/sched.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 973b2b8..c28ed1b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -193,6 +193,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256
 
+#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
+
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
 #define TASK_STOPPED		(TASK_WAKEKILL | __TASK_STOPPED)
@@ -2595,8 +2597,6 @@ static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
 }
 #endif /* CONFIG_MM_OWNER */
 
-#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
-
 #endif /* __KERNEL__ */
 
 #endif

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

* [tip:sched/urgent] sched: Add missing state chars to TASK_STATE_TO_CHAR_STR
  2009-12-17 12:16 ` [PATCH 2/6] sched: Add missing state chars to TASK_STATE_TO_CHAR_STR Peter Zijlstra
@ 2009-12-17 12:31   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-12-17 12:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  44d90df6b757c59651ddd55f1a84f28132b50d29
Gitweb:     http://git.kernel.org/tip/44d90df6b757c59651ddd55f1a84f28132b50d29
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Thu, 17 Dec 2009 13:16:28 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 13:22:44 +0100

sched: Add missing state chars to TASK_STATE_TO_CHAR_STR

We grew 3 new task states since the last time someone touched
it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091217121829.892737686@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/sched.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index c28ed1b..94858df 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -193,7 +193,7 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256
 
-#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
+#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
 
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)

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

* [tip:sched/urgent] sched: Update task_state_arraypwith new states
  2009-12-17 12:16 ` [PATCH 3/6] sched: Update task_state_arraypwith new states Peter Zijlstra
@ 2009-12-17 12:31   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-12-17 12:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  464763cf1c6df632dccc8f2f4c7e50163154a2c0
Gitweb:     http://git.kernel.org/tip/464763cf1c6df632dccc8f2f4c7e50163154a2c0
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Thu, 17 Dec 2009 13:16:29 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 13:22:45 +0100

sched: Update task_state_arraypwith new states

Neglected because its hidden... (who reads comments anyway)

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091217121829.970166036@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 fs/proc/array.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 4badde1..96361e8 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -138,9 +138,12 @@ static const char *task_state_array[] = {
 	"S (sleeping)",		/*  1 */
 	"D (disk sleep)",	/*  2 */
 	"T (stopped)",		/*  4 */
-	"T (tracing stop)",	/*  8 */
+	"t (tracing stop)",	/*  8 */
 	"Z (zombie)",		/* 16 */
-	"X (dead)"		/* 32 */
+	"X (dead)",		/* 32 */
+	"x (dead)",		/* 64 */
+	"K (wakekill)",		/* 128 */
+	"W (waking)",		/* 256 */
 };
 
 static inline const char *get_task_state(struct task_struct *tsk)

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

* [tip:sched/urgent] sched: Assert task state bits at build time
  2009-12-17 12:16 ` [PATCH 4/6] sched: Assert task state bits at build time Peter Zijlstra
@ 2009-12-17 12:31   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-12-17 12:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  e1781538cf5c870ab696e9b8f0a5c498d3900f2f
Gitweb:     http://git.kernel.org/tip/e1781538cf5c870ab696e9b8f0a5c498d3900f2f
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Thu, 17 Dec 2009 13:16:30 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 13:22:45 +0100

sched: Assert task state bits at build time

Since everybody is lazy and prone to forgetting things, make the
compiler help us a bit.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091217121830.060186433@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 fs/proc/array.c       |   18 ++++++++++--------
 include/linux/sched.h |    4 ++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 96361e8..f560325 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -134,14 +134,14 @@ static inline void task_name(struct seq_file *m, struct task_struct *p)
  * simple bit tests.
  */
 static const char *task_state_array[] = {
-	"R (running)",		/*  0 */
-	"S (sleeping)",		/*  1 */
-	"D (disk sleep)",	/*  2 */
-	"T (stopped)",		/*  4 */
-	"t (tracing stop)",	/*  8 */
-	"Z (zombie)",		/* 16 */
-	"X (dead)",		/* 32 */
-	"x (dead)",		/* 64 */
+	"R (running)",		/*   0 */
+	"S (sleeping)",		/*   1 */
+	"D (disk sleep)",	/*   2 */
+	"T (stopped)",		/*   4 */
+	"t (tracing stop)",	/*   8 */
+	"Z (zombie)",		/*  16 */
+	"X (dead)",		/*  32 */
+	"x (dead)",		/*  64 */
 	"K (wakekill)",		/* 128 */
 	"W (waking)",		/* 256 */
 };
@@ -151,6 +151,8 @@ static inline const char *get_task_state(struct task_struct *tsk)
 	unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
 	const char **p = &task_state_array[0];
 
+	BUILD_BUG_ON(1 + ilog2(TASK_STATE_MAX) != ARRAY_SIZE(task_state_array));
+
 	while (state) {
 		p++;
 		state >>= 1;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 94858df..3754387 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -192,9 +192,13 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
 #define TASK_DEAD		64
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256
+#define TASK_STATE_MAX		512
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
 
+extern char ___assert_task_state[1 - 2*!!(
+		sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
+
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
 #define TASK_STOPPED		(TASK_WAKEKILL | __TASK_STOPPED)

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

* [tip:sched/urgent] sched: Fix broken assertion
  2009-12-17 12:16 ` [PATCH 5/6] sched: Fix broken assertion Peter Zijlstra
@ 2009-12-17 12:31   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-12-17 12:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  077614ee1e93245a3b9a4e1213659405dbeb0ba6
Gitweb:     http://git.kernel.org/tip/077614ee1e93245a3b9a4e1213659405dbeb0ba6
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Thu, 17 Dec 2009 13:16:31 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 13:22:46 +0100

sched: Fix broken assertion

There's a preemption race in the set_task_cpu() debug check in
that when we get preempted after setting task->state we'd still
be on the rq proper, but fail the test.

Check for preempted tasks, since those are always on the RQ.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091217121830.137155561@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 7be88a7..720df10 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2041,7 +2041,8 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 	 * We should never call set_task_cpu() on a blocked task,
 	 * ttwu() will sort out the placement.
 	 */
-	WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING);
+	WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING &&
+			!(task_thread_info(p)->preempt_count & PREEMPT_ACTIVE));
 #endif
 
 	trace_sched_migrate_task(p, new_cpu);

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

end of thread, other threads:[~2009-12-17 12:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-17 12:16 [PATCH 0/6] a perf and some sched patches Peter Zijlstra
2009-12-17 12:16 ` [PATCH 1/6] sched: Move TASK_STATE_TO_CHAR_STR near the TASK_state bits Peter Zijlstra
2009-12-17 12:30   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
2009-12-17 12:16 ` [PATCH 2/6] sched: Add missing state chars to TASK_STATE_TO_CHAR_STR Peter Zijlstra
2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
2009-12-17 12:16 ` [PATCH 3/6] sched: Update task_state_arraypwith new states Peter Zijlstra
2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
2009-12-17 12:16 ` [PATCH 4/6] sched: Assert task state bits at build time Peter Zijlstra
2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
2009-12-17 12:16 ` [PATCH 5/6] sched: Fix broken assertion Peter Zijlstra
2009-12-17 12:31   ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
2009-12-17 12:16 ` [PATCH 6/6] perf: Dont report side-band events on each cpu for per-task-per-cpu events Peter Zijlstra
2009-12-17 12:30   ` [tip:perf/urgent] perf events: " tip-bot for Peter Zijlstra
2009-12-17 12:23 ` [PATCH 0/6] a perf and some sched patches Ingo Molnar

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.