diff options
author | David Ahern <david.ahern@oracle.com> | 2015-04-09 12:48:27 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-10 09:10:55 -0400 |
commit | 7764a385f60bd200304a33124bdb4e684caeabdf (patch) | |
tree | aee1436f97de4571d4a490307808e736af02d6fb /tools/perf | |
parent | 51ab7155c08baf45cc2aa911961e5b78422e478f (diff) |
perf tools: Fix synthesizing fork_event.ppid for non-main thread
Commit ca6c41c59b9 sets the ppid based on what is read from the
/proc/pid/status file when synthesizing fork events.
This is correct thing to do for new processes but not threads of a
process.
Fix ppid for threads to be the main thread when synthesizing fork events
(ie., assume main thread spawned all sub-threads in a process).
Reported-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: David Ahern <david.ahern@oracle.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/1428598107-178999-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/event.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 5516236df6ab..9d0985131252 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool, | |||
183 | { | 183 | { |
184 | memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size); | 184 | memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size); |
185 | 185 | ||
186 | event->fork.ppid = ppid; | 186 | /* |
187 | event->fork.ptid = ppid; | 187 | * for main thread set parent to ppid from status file. For other |
188 | * threads set parent pid to main thread. ie., assume main thread | ||
189 | * spawns all threads in a process | ||
190 | */ | ||
191 | if (tgid == pid) { | ||
192 | event->fork.ppid = ppid; | ||
193 | event->fork.ptid = ppid; | ||
194 | } else { | ||
195 | event->fork.ppid = tgid; | ||
196 | event->fork.ptid = tgid; | ||
197 | } | ||
188 | event->fork.pid = tgid; | 198 | event->fork.pid = tgid; |
189 | event->fork.tid = pid; | 199 | event->fork.tid = pid; |
190 | event->fork.header.type = PERF_RECORD_FORK; | 200 | event->fork.header.type = PERF_RECORD_FORK; |