* [PATCH] perf/core: fix parent pid/tid in task exit events
@ 2020-04-17 18:28 Ian Rogers
2020-04-17 18:45 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2020-04-17 18:28 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
linux-kernel, linux-perf-users
Cc: Stephane Eranian, KP Singh, Ian Rogers
Current logic yields the child task as the parent.
Before:
$ perf record bash -c "perf list > /dev/null"
$ perf script -D |grep 'FORK\|EXIT'
4387036190981094 0x5a70 [0x30]: PERF_RECORD_FORK(10472:10472):(10470:10470)
4387036606207580 0xf050 [0x30]: PERF_RECORD_EXIT(10472:10472):(10472:10472)
4387036607103839 0x17150 [0x30]: PERF_RECORD_EXIT(10470:10470):(10470:10470)
^
Note the repeated values here -------------------/
After:
383281514043 0x9d8 [0x30]: PERF_RECORD_FORK(2268:2268):(2266:2266)
383442003996 0x2180 [0x30]: PERF_RECORD_EXIT(2268:2268):(2266:2266)
383451297778 0xb70 [0x30]: PERF_RECORD_EXIT(2266:2266):(2265:2265)
Reported-by: KP Singh <kpsingh@google.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
kernel/events/core.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index bc9b98a9af9a..633b4ae72ed5 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7491,10 +7491,17 @@ static void perf_event_task_output(struct perf_event *event,
goto out;
task_event->event_id.pid = perf_event_pid(event, task);
- task_event->event_id.ppid = perf_event_pid(event, current);
-
task_event->event_id.tid = perf_event_tid(event, task);
- task_event->event_id.ptid = perf_event_tid(event, current);
+
+ if (task_event->event_id.header.type == PERF_RECORD_EXIT) {
+ task_event->event_id.ppid = perf_event_pid(event,
+ task->real_parent);
+ task_event->event_id.ptid = perf_event_pid(event,
+ task->real_parent);
+ } else { /* PERF_RECORD_FORK */
+ task_event->event_id.ppid = perf_event_pid(event, current);
+ task_event->event_id.ptid = perf_event_tid(event, current);
+ }
task_event->event_id.time = perf_event_clock(event);
--
2.26.1.301.g55bc3eb7cb9-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/core: fix parent pid/tid in task exit events
2020-04-17 18:28 [PATCH] perf/core: fix parent pid/tid in task exit events Ian Rogers
@ 2020-04-17 18:45 ` Peter Zijlstra
2020-04-17 21:31 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2020-04-17 18:45 UTC (permalink / raw)
To: Ian Rogers
Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel,
linux-perf-users, Stephane Eranian, KP Singh
On Fri, Apr 17, 2020 at 11:28:42AM -0700, Ian Rogers wrote:
> Current logic yields the child task as the parent.
>
> Before:
> $ perf record bash -c "perf list > /dev/null"
> $ perf script -D |grep 'FORK\|EXIT'
> 4387036190981094 0x5a70 [0x30]: PERF_RECORD_FORK(10472:10472):(10470:10470)
> 4387036606207580 0xf050 [0x30]: PERF_RECORD_EXIT(10472:10472):(10472:10472)
> 4387036607103839 0x17150 [0x30]: PERF_RECORD_EXIT(10470:10470):(10470:10470)
> ^
> Note the repeated values here -------------------/
>
> After:
> 383281514043 0x9d8 [0x30]: PERF_RECORD_FORK(2268:2268):(2266:2266)
> 383442003996 0x2180 [0x30]: PERF_RECORD_EXIT(2268:2268):(2266:2266)
> 383451297778 0xb70 [0x30]: PERF_RECORD_EXIT(2266:2266):(2265:2265)
>
Fixes: .... ?
> Reported-by: KP Singh <kpsingh@google.com>
> Signed-off-by: Ian Rogers <irogers@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/core: fix parent pid/tid in task exit events
2020-04-17 18:45 ` Peter Zijlstra
@ 2020-04-17 21:31 ` Ian Rogers
0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2020-04-17 21:31 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Namhyung Kim, LKML,
linux-perf-users, Stephane Eranian, KP Singh
On Fri, Apr 17, 2020 at 11:45 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Fri, Apr 17, 2020 at 11:28:42AM -0700, Ian Rogers wrote:
> > Current logic yields the child task as the parent.
> >
> > Before:
> > $ perf record bash -c "perf list > /dev/null"
> > $ perf script -D |grep 'FORK\|EXIT'
> > 4387036190981094 0x5a70 [0x30]: PERF_RECORD_FORK(10472:10472):(10470:10470)
> > 4387036606207580 0xf050 [0x30]: PERF_RECORD_EXIT(10472:10472):(10472:10472)
> > 4387036607103839 0x17150 [0x30]: PERF_RECORD_EXIT(10470:10470):(10470:10470)
> > ^
> > Note the repeated values here -------------------/
> >
> > After:
> > 383281514043 0x9d8 [0x30]: PERF_RECORD_FORK(2268:2268):(2266:2266)
> > 383442003996 0x2180 [0x30]: PERF_RECORD_EXIT(2268:2268):(2266:2266)
> > 383451297778 0xb70 [0x30]: PERF_RECORD_EXIT(2266:2266):(2265:2265)
> >
>
> Fixes: .... ?
Fixes: 94d5d1b2d891 ("perf_counter: Report the cloning task as parent
on perf_counter_fork()")
Sorry, re-sending as plain-text was disabled on the message and so it
bounced on lkml. Took some digging to find the original commit :-)
Thanks,
Ian
>
> > Reported-by: KP Singh <kpsingh@google.com>
> > Signed-off-by: Ian Rogers <irogers@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-17 21:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-17 18:28 [PATCH] perf/core: fix parent pid/tid in task exit events Ian Rogers
2020-04-17 18:45 ` Peter Zijlstra
2020-04-17 21:31 ` Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox