perf tools: Save parent pid in thread struct
authorDavid Ahern <dsahern@gmail.com>
Sun, 26 May 2013 04:47:10 +0000 (22:47 -0600)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 28 May 2013 13:24:05 +0000 (16:24 +0300)
Information is available, so why not save it in case some command wants
to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1369543631-5106-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/thread.c
tools/perf/util/thread.h

index 632e40e5ceca6d301a764caab574628a6ca89c9a..40399cbcca775c253b0c691fca69346af40fe7f3 100644 (file)
@@ -14,6 +14,7 @@ struct thread *thread__new(pid_t pid)
        if (self != NULL) {
                map_groups__init(&self->mg);
                self->pid = pid;
+               self->ppid = -1;
                self->comm = malloc(32);
                if (self->comm)
                        snprintf(self->comm, 32, ":%d", self->pid);
@@ -82,5 +83,8 @@ int thread__fork(struct thread *self, struct thread *parent)
        for (i = 0; i < MAP__NR_TYPES; ++i)
                if (map_groups__clone(&self->mg, &parent->mg, i) < 0)
                        return -ENOMEM;
+
+       self->ppid = parent->pid;
+
        return 0;
 }
index 5ad266403098d18ab53e907b08a2ae8e3768930e..eeb7ac62b9e3ce99ad796a62a628010dd2dce927 100644 (file)
@@ -13,6 +13,7 @@ struct thread {
        };
        struct map_groups       mg;
        pid_t                   pid;
+       pid_t                   ppid;
        char                    shortname[3];
        bool                    comm_set;
        char                    *comm;