mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* perf: FORMAT_GROUP on attached process stops working in 3.16-rc
@ 2014-07-15 14:36 Vince Weaver
  2014-07-15 14:37 ` Peter Zijlstra
  2014-07-15 15:35 ` Peter Zijlstra
  0 siblings, 2 replies; 3+ messages in thread
From: Vince Weaver @ 2014-07-15 14:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Stephane Eranian

Hello

I noticed in the 3.16-rc kernels that one of my regression tests was 
failing, specifically
	https://github.com/deater/perf_event_tests/blob/master/tests/bugs/read_group_attached.c

This test creates an event group with two events and PERF_FORMAT_GROUP
set.

It creates a child process, stops it, attaches the event group to it, 
starts the events and the child, waits for the child to finish, stops the
events, then reads the value.

In theory a subsequent read from the group leader should return values for 
*both* events (due to PERF_FORMAT_GROUP) but this stopped working, it only 
returns the value for the leader.

I've bisected it down to change: 15a2d4de0eab5 
	"perf: Always destroy groups on exit"

So is this expected behavior due to this patch, or is it a regression?

Thanks,

Vince

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

* Re: perf: FORMAT_GROUP on attached process stops working in 3.16-rc
  2014-07-15 14:36 perf: FORMAT_GROUP on attached process stops working in 3.16-rc Vince Weaver
@ 2014-07-15 14:37 ` Peter Zijlstra
  2014-07-15 15:35 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2014-07-15 14:37 UTC (permalink / raw)
  To: Vince Weaver
  Cc: linux-kernel, Ingo Molnar, Arnaldo Carvalho de Melo, Stephane Eranian

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

On Tue, Jul 15, 2014 at 10:36:33AM -0400, Vince Weaver wrote:
> Hello
> 
> I noticed in the 3.16-rc kernels that one of my regression tests was 
> failing, specifically
> 	https://github.com/deater/perf_event_tests/blob/master/tests/bugs/read_group_attached.c
> 
> This test creates an event group with two events and PERF_FORMAT_GROUP
> set.
> 
> It creates a child process, stops it, attaches the event group to it, 
> starts the events and the child, waits for the child to finish, stops the
> events, then reads the value.
> 
> In theory a subsequent read from the group leader should return values for 
> *both* events (due to PERF_FORMAT_GROUP) but this stopped working, it only 
> returns the value for the leader.
> 
> I've bisected it down to change: 15a2d4de0eab5 
> 	"perf: Always destroy groups on exit"
> 
> So is this expected behavior due to this patch, or is it a regression?

Regression, lemme try and wrap my head around it. Thanks!

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: perf: FORMAT_GROUP on attached process stops working in 3.16-rc
  2014-07-15 14:36 perf: FORMAT_GROUP on attached process stops working in 3.16-rc Vince Weaver
  2014-07-15 14:37 ` Peter Zijlstra
@ 2014-07-15 15:35 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2014-07-15 15:35 UTC (permalink / raw)
  To: Vince Weaver
  Cc: linux-kernel, Ingo Molnar, Arnaldo Carvalho de Melo, Stephane Eranian

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




Subject: perf: Revert ("perf: Always destroy groups on exit")
From: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jul 15 17:27:27 CEST 2014

Vince reported that commit 15a2d4de0eab5 ("perf: Always destroy groups
on exit") causes a regression with grouped events. In particular his
read_group_attached.c test fails.

  https://github.com/deater/perf_event_tests/blob/master/tests/bugs/read_group_attached.c

Because of the context switch optimization in
perf_event_context_sched_out() the 'original' event may end up in the
child process and when that exits the change in the patch in question
destroys the actual grouping.

Therefore revert that change and only destroy inherited groups.

Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/events/core.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7458,7 +7458,19 @@ __perf_event_exit_task(struct perf_event
 			 struct perf_event_context *child_ctx,
 			 struct task_struct *child)
 {
-	perf_remove_from_context(child_event, true);
+	/*
+	 * Do not destroy the 'original' grouping; because of the context
+	 * switch optimization the original events could've ended up in a
+	 * random child task.
+	 *
+	 * If we were to destroy the original group, all group related
+	 * operations would cease to function properly after this random
+	 * child dies.
+	 *
+	 * Do destroy all inherited groups, we don't care about those
+	 * and being thorough is better.
+	 */
+	perf_remove_from_context(child_event, !!child_event->parent);
 
 	/*
 	 * It can happen that the parent exits first, and has events

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2014-07-15 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 14:36 perf: FORMAT_GROUP on attached process stops working in 3.16-rc Vince Weaver
2014-07-15 14:37 ` Peter Zijlstra
2014-07-15 15:35 ` Peter Zijlstra

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

Powered by JetHome