All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] yet more perf counter patches
@ 2009-05-25 12:45 Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 1/5] perf_counter: fix perf-$cmd invokation Peter Zijlstra
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Peter Zijlstra @ 2009-05-25 12:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mackerras, Corey Ashford, linux-kernel, Peter Zijlstra,
	Arnaldo Carvalho de Melo, John Kacur


-- 


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

* [PATCH 1/5] perf_counter: fix perf-$cmd invokation
  2009-05-25 12:45 [PATCH 0/5] yet more perf counter patches Peter Zijlstra
@ 2009-05-25 12:45 ` Peter Zijlstra
  2009-05-25 13:03   ` [tip:perfcounters/core] perf_counter: Fix " tip-bot for Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 2/5] perf_counter: remove unused ABI bits Peter Zijlstra
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2009-05-25 12:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mackerras, Corey Ashford, linux-kernel, Peter Zijlstra,
	Arnaldo Carvalho de Melo, John Kacur

[-- Attachment #1: perf_counter-fix-perf-cmd.patch --]
[-- Type: text/plain, Size: 735 bytes --]

Fix:

  $ perf-top
  fatal: cannot handle -top internally

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

Index: linux-2.6/Documentation/perf_counter/perf.c
===================================================================
--- linux-2.6.orig/Documentation/perf_counter/perf.c
+++ linux-2.6/Documentation/perf_counter/perf.c
@@ -357,7 +357,7 @@ int main(int argc, const char **argv)
 	 * die if that one cannot handle it.
 	 */
 	if (!prefixcmp(cmd, "perf-")) {
-		cmd += 4;
+		cmd += 5;
 		argv[0] = cmd;
 		handle_internal_command(argc, argv);
 		die("cannot handle %s internally", cmd);

-- 


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

* [PATCH 2/5] perf_counter: remove unused ABI bits.
  2009-05-25 12:45 [PATCH 0/5] yet more perf counter patches Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 1/5] perf_counter: fix perf-$cmd invokation Peter Zijlstra
@ 2009-05-25 12:45 ` Peter Zijlstra
  2009-05-25 13:03   ` [tip:perfcounters/core] perf_counter: Remove " tip-bot for Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 3/5] perf_counter: make pctrl() affect inherited counters too Peter Zijlstra
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2009-05-25 12:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mackerras, Corey Ashford, linux-kernel, Peter Zijlstra,
	Arnaldo Carvalho de Melo, John Kacur

[-- Attachment #1: perf_counter-cleanup-abi.patch --]
[-- Type: text/plain, Size: 721 bytes --]

extra_config_len isn't used for anything, remove it.

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

Index: linux-2.6/include/linux/perf_counter.h
===================================================================
--- linux-2.6.orig/include/linux/perf_counter.h
+++ linux-2.6/include/linux/perf_counter.h
@@ -154,11 +154,11 @@ struct perf_counter_hw_event {
 
 				__reserved_1   : 51;
 
-	__u32			extra_config_len;
 	__u32			wakeup_events;	/* wakeup every n events */
+	__u32			__reserved_2;
 
-	__u64			__reserved_2;
 	__u64			__reserved_3;
+	__u64			__reserved_4;
 };
 
 /*

-- 


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

* [PATCH 3/5] perf_counter: make pctrl() affect inherited counters too
  2009-05-25 12:45 [PATCH 0/5] yet more perf counter patches Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 1/5] perf_counter: fix perf-$cmd invokation Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 2/5] perf_counter: remove unused ABI bits Peter Zijlstra
@ 2009-05-25 12:45 ` Peter Zijlstra
  2009-05-25 13:03   ` [tip:perfcounters/core] perf_counter: Make " tip-bot for Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 4/5] perf_counter: propagate inheritance failures down the fork() path Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 5/5] perf_counter: fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters Peter Zijlstra
  4 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2009-05-25 12:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mackerras, Corey Ashford, linux-kernel, Peter Zijlstra,
	Arnaldo Carvalho de Melo, John Kacur

[-- Attachment #1: perf_counter-pctrl-child.patch --]
[-- Type: text/plain, Size: 2182 bytes --]

Paul noted that the new ptcrl() didn't work on child counters.

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

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1067,30 +1067,6 @@ static void perf_counter_cpu_sched_in(st
 	__perf_counter_sched_in(ctx, cpuctx, cpu);
 }
 
-int perf_counter_task_enable(void)
-{
-	struct perf_counter *counter;
-
-	mutex_lock(&current->perf_counter_mutex);
-	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
-		perf_counter_enable(counter);
-	mutex_unlock(&current->perf_counter_mutex);
-
-	return 0;
-}
-
-int perf_counter_task_disable(void)
-{
-	struct perf_counter *counter;
-
-	mutex_lock(&current->perf_counter_mutex);
-	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
-		perf_counter_disable(counter);
-	mutex_unlock(&current->perf_counter_mutex);
-
-	return 0;
-}
-
 static void perf_log_period(struct perf_counter *counter, u64 period);
 
 static void perf_adjust_freq(struct perf_counter_context *ctx)
@@ -1505,6 +1481,30 @@ static long perf_ioctl(struct file *file
 	return 0;
 }
 
+int perf_counter_task_enable(void)
+{
+	struct perf_counter *counter;
+
+	mutex_lock(&current->perf_counter_mutex);
+	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
+		perf_counter_for_each_child(counter, perf_counter_enable);
+	mutex_unlock(&current->perf_counter_mutex);
+
+	return 0;
+}
+
+int perf_counter_task_disable(void)
+{
+	struct perf_counter *counter;
+
+	mutex_lock(&current->perf_counter_mutex);
+	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
+		perf_counter_for_each_child(counter, perf_counter_disable);
+	mutex_unlock(&current->perf_counter_mutex);
+
+	return 0;
+}
+
 /*
  * Callers need to ensure there can be no nesting of this function, otherwise
  * the seqlock logic goes bad. We can not serialize this because the arch

-- 


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

* [PATCH 4/5] perf_counter: propagate inheritance failures down the fork() path
  2009-05-25 12:45 [PATCH 0/5] yet more perf counter patches Peter Zijlstra
                   ` (2 preceding siblings ...)
  2009-05-25 12:45 ` [PATCH 3/5] perf_counter: make pctrl() affect inherited counters too Peter Zijlstra
@ 2009-05-25 12:45 ` Peter Zijlstra
  2009-05-25 13:04   ` [tip:perfcounters/core] perf_counter: Propagate " tip-bot for Peter Zijlstra
  2009-05-25 12:45 ` [PATCH 5/5] perf_counter: fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters Peter Zijlstra
  4 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2009-05-25 12:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mackerras, Corey Ashford, linux-kernel, Peter Zijlstra,
	Arnaldo Carvalho de Melo, John Kacur

[-- Attachment #1: perf_counter-init-fail.patch --]
[-- Type: text/plain, Size: 2732 bytes --]

Fail fork() when we fail inheritance for some reason (-ENOMEM most likely).

LKML-Reference: <new-submission>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/fork.c         |    5 ++++-
 kernel/perf_counter.c |   20 ++++++++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)

Index: linux-2.6/kernel/fork.c
===================================================================
--- linux-2.6.orig/kernel/fork.c
+++ linux-2.6/kernel/fork.c
@@ -983,7 +983,9 @@ static struct task_struct *copy_process(
 		goto fork_out;
 
 	rt_mutex_init_task(p);
-	perf_counter_init_task(p);
+	retval = perf_counter_init_task(p);
+	if (retval)
+		goto bad_fork_free;
 
 #ifdef CONFIG_PROVE_LOCKING
 	DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
@@ -1309,6 +1311,7 @@ bad_fork_cleanup_count:
 	put_cred(p->real_cred);
 	put_cred(p->cred);
 bad_fork_free:
+	perf_counter_exit_task(p);
 	free_task(p);
 fork_out:
 	return ERR_PTR(retval);
Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -3434,18 +3434,23 @@ again:
 /*
  * Initialize the perf_counter context in task_struct
  */
-void perf_counter_init_task(struct task_struct *child)
+int perf_counter_init_task(struct task_struct *child)
 {
 	struct perf_counter_context *child_ctx, *parent_ctx;
 	struct perf_counter *counter;
 	struct task_struct *parent = current;
 	int inherited_all = 1;
+	int ret = 0;
 
 	child->perf_counter_ctxp = NULL;
 
 	mutex_init(&child->perf_counter_mutex);
 	INIT_LIST_HEAD(&child->perf_counter_list);
 
+	parent_ctx = parent->perf_counter_ctxp;
+	if (likely(!parent_ctx || !parent_ctx->nr_counters))
+		return 0;
+
 	/*
 	 * This is executed from the parent task context, so inherit
 	 * counters that have been marked for cloning.
@@ -3454,11 +3459,7 @@ void perf_counter_init_task(struct task_
 
 	child_ctx = kmalloc(sizeof(struct perf_counter_context), GFP_KERNEL);
 	if (!child_ctx)
-		return;
-
-	parent_ctx = parent->perf_counter_ctxp;
-	if (likely(!parent_ctx || !parent_ctx->nr_counters))
-		return;
+		return -ENOMEM;
 
 	__perf_counter_init_context(child_ctx, child);
 	child->perf_counter_ctxp = child_ctx;
@@ -3482,8 +3483,9 @@ void perf_counter_init_task(struct task_
 			continue;
 		}
 
-		if (inherit_group(counter, parent,
-				  parent_ctx, child, child_ctx)) {
+		ret = inherit_group(counter, parent, parent_ctx,
+					     child, child_ctx);
+		if (ret) {
 			inherited_all = 0;
 			break;
 		}
@@ -3505,6 +3507,8 @@ void perf_counter_init_task(struct task_
 	}
 
 	mutex_unlock(&parent_ctx->mutex);
+
+	return ret;
 }
 
 static void __cpuinit perf_counter_init_cpu(int cpu)

-- 


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

* [PATCH 5/5] perf_counter: fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters
  2009-05-25 12:45 [PATCH 0/5] yet more perf counter patches Peter Zijlstra
                   ` (3 preceding siblings ...)
  2009-05-25 12:45 ` [PATCH 4/5] perf_counter: propagate inheritance failures down the fork() path Peter Zijlstra
@ 2009-05-25 12:45 ` Peter Zijlstra
  2009-05-25 13:04   ` [tip:perfcounters/core] perf_counter: Fix " tip-bot for Peter Zijlstra
  4 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2009-05-25 12:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mackerras, Corey Ashford, linux-kernel, Peter Zijlstra,
	Arnaldo Carvalho de Melo, John Kacur

[-- Attachment #1: perf_counter-fix-swcounter-context-switches.patch --]
[-- Type: text/plain, Size: 1017 bytes --]

Ingo noticed that cpu counters had 0 context switches, even though there
was plenty scheduling on the cpu.

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

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -932,14 +932,13 @@ void perf_counter_task_sched_out(struct 
 	struct perf_counter_context *next_ctx;
 	struct pt_regs *regs;
 
+	regs = task_pt_regs(task);
+	perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs, 0);
+
 	if (likely(!ctx || !cpuctx->task_ctx))
 		return;
 
 	update_context_time(ctx);
-
-	regs = task_pt_regs(task);
-	perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs, 0);
-
 	next_ctx = next->perf_counter_ctxp;
 	if (next_ctx && context_equiv(ctx, next_ctx)) {
 		task->perf_counter_ctxp = next_ctx;

-- 


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

* [tip:perfcounters/core] perf_counter: Fix perf-$cmd invokation
  2009-05-25 12:45 ` [PATCH 1/5] perf_counter: fix perf-$cmd invokation Peter Zijlstra
@ 2009-05-25 13:03   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-05-25 13:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, paulus, hpa, mingo, jkacur, a.p.zijlstra,
	tglx, cjashfor, mingo

Commit-ID:  266dfb0b58bc4181b6158ee63a0069abaa9f3a98
Gitweb:     http://git.kernel.org/tip/266dfb0b58bc4181b6158ee63a0069abaa9f3a98
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 25 May 2009 14:45:24 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 25 May 2009 14:54:59 +0200

perf_counter: Fix perf-$cmd invokation

Fix:

  $ perf-top
  fatal: cannot handle -top internally

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090525124559.995591577@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 Documentation/perf_counter/perf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/perf_counter/perf.c b/Documentation/perf_counter/perf.c
index 594d270..1d6d7aa 100644
--- a/Documentation/perf_counter/perf.c
+++ b/Documentation/perf_counter/perf.c
@@ -357,7 +357,7 @@ int main(int argc, const char **argv)
 	 * die if that one cannot handle it.
 	 */
 	if (!prefixcmp(cmd, "perf-")) {
-		cmd += 4;
+		cmd += 5;
 		argv[0] = cmd;
 		handle_internal_command(argc, argv);
 		die("cannot handle %s internally", cmd);

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

* [tip:perfcounters/core] perf_counter: Remove unused ABI bits
  2009-05-25 12:45 ` [PATCH 2/5] perf_counter: remove unused ABI bits Peter Zijlstra
@ 2009-05-25 13:03   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-05-25 13:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, paulus, hpa, mingo, jkacur, a.p.zijlstra,
	tglx, cjashfor, mingo

Commit-ID:  e527ea312f31e88a7fa5472b71db71c565b0d44f
Gitweb:     http://git.kernel.org/tip/e527ea312f31e88a7fa5472b71db71c565b0d44f
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 25 May 2009 14:45:25 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 25 May 2009 14:55:00 +0200

perf_counter: Remove unused ABI bits

extra_config_len isn't used for anything, remove it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090525124600.116035832@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 include/linux/perf_counter.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 2ddf5e3..b1f2bac 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -154,11 +154,11 @@ struct perf_counter_hw_event {
 
 				__reserved_1   : 51;
 
-	__u32			extra_config_len;
 	__u32			wakeup_events;	/* wakeup every n events */
+	__u32			__reserved_2;
 
-	__u64			__reserved_2;
 	__u64			__reserved_3;
+	__u64			__reserved_4;
 };
 
 /*

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

* [tip:perfcounters/core] perf_counter: Make pctrl() affect inherited counters too
  2009-05-25 12:45 ` [PATCH 3/5] perf_counter: make pctrl() affect inherited counters too Peter Zijlstra
@ 2009-05-25 13:03   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-05-25 13:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, paulus, hpa, mingo, jkacur, a.p.zijlstra,
	tglx, cjashfor, mingo

Commit-ID:  771d7cde144d87f2d1fbee4da3c6234d61f7e42a
Gitweb:     http://git.kernel.org/tip/771d7cde144d87f2d1fbee4da3c6234d61f7e42a
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 25 May 2009 14:45:26 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 25 May 2009 14:55:00 +0200

perf_counter: Make pctrl() affect inherited counters too

Paul noted that the new ptcrl() didn't work on child counters.

Reported-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090525124600.203151469@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/perf_counter.c |   48 ++++++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 6cdf824..217dbcc 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1067,30 +1067,6 @@ static void perf_counter_cpu_sched_in(struct perf_cpu_context *cpuctx, int cpu)
 	__perf_counter_sched_in(ctx, cpuctx, cpu);
 }
 
-int perf_counter_task_enable(void)
-{
-	struct perf_counter *counter;
-
-	mutex_lock(&current->perf_counter_mutex);
-	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
-		perf_counter_enable(counter);
-	mutex_unlock(&current->perf_counter_mutex);
-
-	return 0;
-}
-
-int perf_counter_task_disable(void)
-{
-	struct perf_counter *counter;
-
-	mutex_lock(&current->perf_counter_mutex);
-	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
-		perf_counter_disable(counter);
-	mutex_unlock(&current->perf_counter_mutex);
-
-	return 0;
-}
-
 static void perf_log_period(struct perf_counter *counter, u64 period);
 
 static void perf_adjust_freq(struct perf_counter_context *ctx)
@@ -1505,6 +1481,30 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
+int perf_counter_task_enable(void)
+{
+	struct perf_counter *counter;
+
+	mutex_lock(&current->perf_counter_mutex);
+	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
+		perf_counter_for_each_child(counter, perf_counter_enable);
+	mutex_unlock(&current->perf_counter_mutex);
+
+	return 0;
+}
+
+int perf_counter_task_disable(void)
+{
+	struct perf_counter *counter;
+
+	mutex_lock(&current->perf_counter_mutex);
+	list_for_each_entry(counter, &current->perf_counter_list, owner_entry)
+		perf_counter_for_each_child(counter, perf_counter_disable);
+	mutex_unlock(&current->perf_counter_mutex);
+
+	return 0;
+}
+
 /*
  * Callers need to ensure there can be no nesting of this function, otherwise
  * the seqlock logic goes bad. We can not serialize this because the arch

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

* [tip:perfcounters/core] perf_counter: Propagate inheritance failures down the fork() path
  2009-05-25 12:45 ` [PATCH 4/5] perf_counter: propagate inheritance failures down the fork() path Peter Zijlstra
@ 2009-05-25 13:04   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-05-25 13:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, paulus, hpa, mingo, jkacur, a.p.zijlstra,
	tglx, cjashfor, mingo

Commit-ID:  6ab423e0eaca827fbd201ca4ae7d4f8573a366b2
Gitweb:     http://git.kernel.org/tip/6ab423e0eaca827fbd201ca4ae7d4f8573a366b2
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 25 May 2009 14:45:27 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 25 May 2009 14:55:01 +0200

perf_counter: Propagate inheritance failures down the fork() path

Fail fork() when we fail inheritance for some reason (-ENOMEM most likely).

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090525124600.324656474@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 include/linux/perf_counter.h |    4 ++--
 kernel/fork.c                |    6 +++++-
 kernel/perf_counter.c        |   20 ++++++++++++--------
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index b1f2bac..d3e85de 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -566,7 +566,7 @@ extern void perf_counter_task_sched_in(struct task_struct *task, int cpu);
 extern void perf_counter_task_sched_out(struct task_struct *task,
 					struct task_struct *next, int cpu);
 extern void perf_counter_task_tick(struct task_struct *task, int cpu);
-extern void perf_counter_init_task(struct task_struct *child);
+extern int perf_counter_init_task(struct task_struct *child);
 extern void perf_counter_exit_task(struct task_struct *child);
 extern void perf_counter_do_pending(void);
 extern void perf_counter_print_debug(void);
@@ -631,7 +631,7 @@ perf_counter_task_sched_out(struct task_struct *task,
 			    struct task_struct *next, int cpu)		{ }
 static inline void
 perf_counter_task_tick(struct task_struct *task, int cpu)		{ }
-static inline void perf_counter_init_task(struct task_struct *child)	{ }
+static inline int perf_counter_init_task(struct task_struct *child)	{ }
 static inline void perf_counter_exit_task(struct task_struct *child)	{ }
 static inline void perf_counter_do_pending(void)			{ }
 static inline void perf_counter_print_debug(void)			{ }
diff --git a/kernel/fork.c b/kernel/fork.c
index 675e01e..c07c333 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1095,7 +1095,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 
 	/* Perform scheduler related setup. Assign this task to a CPU. */
 	sched_fork(p, clone_flags);
-	perf_counter_init_task(p);
+
+	retval = perf_counter_init_task(p);
+	if (retval)
+		goto bad_fork_cleanup_policy;
 
 	if ((retval = audit_alloc(p)))
 		goto bad_fork_cleanup_policy;
@@ -1295,6 +1298,7 @@ bad_fork_cleanup_semundo:
 bad_fork_cleanup_audit:
 	audit_free(p);
 bad_fork_cleanup_policy:
+	perf_counter_exit_task(p);
 #ifdef CONFIG_NUMA
 	mpol_put(p->mempolicy);
 bad_fork_cleanup_cgroup:
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 217dbcc..7a7a144 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -3434,18 +3434,23 @@ again:
 /*
  * Initialize the perf_counter context in task_struct
  */
-void perf_counter_init_task(struct task_struct *child)
+int perf_counter_init_task(struct task_struct *child)
 {
 	struct perf_counter_context *child_ctx, *parent_ctx;
 	struct perf_counter *counter;
 	struct task_struct *parent = current;
 	int inherited_all = 1;
+	int ret = 0;
 
 	child->perf_counter_ctxp = NULL;
 
 	mutex_init(&child->perf_counter_mutex);
 	INIT_LIST_HEAD(&child->perf_counter_list);
 
+	parent_ctx = parent->perf_counter_ctxp;
+	if (likely(!parent_ctx || !parent_ctx->nr_counters))
+		return 0;
+
 	/*
 	 * This is executed from the parent task context, so inherit
 	 * counters that have been marked for cloning.
@@ -3454,11 +3459,7 @@ void perf_counter_init_task(struct task_struct *child)
 
 	child_ctx = kmalloc(sizeof(struct perf_counter_context), GFP_KERNEL);
 	if (!child_ctx)
-		return;
-
-	parent_ctx = parent->perf_counter_ctxp;
-	if (likely(!parent_ctx || !parent_ctx->nr_counters))
-		return;
+		return -ENOMEM;
 
 	__perf_counter_init_context(child_ctx, child);
 	child->perf_counter_ctxp = child_ctx;
@@ -3482,8 +3483,9 @@ void perf_counter_init_task(struct task_struct *child)
 			continue;
 		}
 
-		if (inherit_group(counter, parent,
-				  parent_ctx, child, child_ctx)) {
+		ret = inherit_group(counter, parent, parent_ctx,
+					     child, child_ctx);
+		if (ret) {
 			inherited_all = 0;
 			break;
 		}
@@ -3505,6 +3507,8 @@ void perf_counter_init_task(struct task_struct *child)
 	}
 
 	mutex_unlock(&parent_ctx->mutex);
+
+	return ret;
 }
 
 static void __cpuinit perf_counter_init_cpu(int cpu)

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

* [tip:perfcounters/core] perf_counter: Fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters
  2009-05-25 12:45 ` [PATCH 5/5] perf_counter: fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters Peter Zijlstra
@ 2009-05-25 13:04   ` tip-bot for Peter Zijlstra
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-05-25 13:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, paulus, hpa, mingo, jkacur, a.p.zijlstra,
	tglx, cjashfor, mingo

Commit-ID:  10989fb2451763fae6f42d85fa6106c8fd010cf5
Gitweb:     http://git.kernel.org/tip/10989fb2451763fae6f42d85fa6106c8fd010cf5
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 25 May 2009 14:45:28 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 25 May 2009 14:55:01 +0200

perf_counter: Fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters

Ingo noticed that cpu counters had 0 context switches, even though
there was plenty scheduling on the cpu.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090525124600.419025548@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/perf_counter.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 7a7a144..14b1fe9 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -924,14 +924,13 @@ void perf_counter_task_sched_out(struct task_struct *task,
 	struct perf_counter_context *next_ctx;
 	struct pt_regs *regs;
 
+	regs = task_pt_regs(task);
+	perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs, 0);
+
 	if (likely(!ctx || !cpuctx->task_ctx))
 		return;
 
 	update_context_time(ctx);
-
-	regs = task_pt_regs(task);
-	perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs, 0);
-
 	next_ctx = next->perf_counter_ctxp;
 	if (next_ctx && context_equiv(ctx, next_ctx)) {
 		task->perf_counter_ctxp = next_ctx;

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

end of thread, other threads:[~2009-05-25 13:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-25 12:45 [PATCH 0/5] yet more perf counter patches Peter Zijlstra
2009-05-25 12:45 ` [PATCH 1/5] perf_counter: fix perf-$cmd invokation Peter Zijlstra
2009-05-25 13:03   ` [tip:perfcounters/core] perf_counter: Fix " tip-bot for Peter Zijlstra
2009-05-25 12:45 ` [PATCH 2/5] perf_counter: remove unused ABI bits Peter Zijlstra
2009-05-25 13:03   ` [tip:perfcounters/core] perf_counter: Remove " tip-bot for Peter Zijlstra
2009-05-25 12:45 ` [PATCH 3/5] perf_counter: make pctrl() affect inherited counters too Peter Zijlstra
2009-05-25 13:03   ` [tip:perfcounters/core] perf_counter: Make " tip-bot for Peter Zijlstra
2009-05-25 12:45 ` [PATCH 4/5] perf_counter: propagate inheritance failures down the fork() path Peter Zijlstra
2009-05-25 13:04   ` [tip:perfcounters/core] perf_counter: Propagate " tip-bot for Peter Zijlstra
2009-05-25 12:45 ` [PATCH 5/5] perf_counter: fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters Peter Zijlstra
2009-05-25 13:04   ` [tip:perfcounters/core] perf_counter: Fix " tip-bot for Peter Zijlstra

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.