Messages in this thread Patch in this message |  | | From | David Ahern <> | Subject | [PATCH] perf tools: Fix ppid for non-main thread | Date | Thu, 9 Apr 2015 12:48:27 -0400 |
| |
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> Cc: Don Zickus <dzickus@redhat.com> --- 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 186929a..ff866c4 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, { memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size); - event->fork.ppid = ppid; - event->fork.ptid = ppid; + /* + * for main thread set parent to ppid from status file. For other + * threads set parent pid to main thread. ie., assume main thread + * spawns all threads in a process + */ + if (tgid == pid) { + event->fork.ppid = ppid; + event->fork.ptid = ppid; + } else { + event->fork.ppid = tgid; + event->fork.ptid = tgid; + } event->fork.pid = tgid; event->fork.tid = pid; event->fork.header.type = PERF_RECORD_FORK; -- 1.7.1
|  |