* [PATCH 1/2] perf: save parent pid in thread struct
@ 2013-05-26 4:47 David Ahern
2013-05-26 4:47 ` [PATCH 2/2] perf script: add option to dump parent pid David Ahern
2013-05-31 11:52 ` [tip:perf/core] perf tools: Save parent pid in thread struct tip-bot for David Ahern
0 siblings, 2 replies; 3+ messages in thread
From: David Ahern @ 2013-05-26 4:47 UTC (permalink / raw)
To: acme, linux-kernel
Cc: David Ahern, Frederic Weisbecker, Ingo Molnar, Jiri Olsa,
Namhyung Kim, Peter Zijlstra, Stephane Eranian
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>
---
tools/perf/util/thread.c | 4 ++++
tools/perf/util/thread.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 632e40e..40399cb 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -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;
}
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 735b343..bdec685 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -13,6 +13,7 @@ struct thread {
};
struct map_groups mg;
pid_t pid;
+ pid_t ppid;
char shortname[3];
bool comm_set;
char *comm;
--
1.7.10.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] perf script: add option to dump parent pid
2013-05-26 4:47 [PATCH 1/2] perf: save parent pid in thread struct David Ahern
@ 2013-05-26 4:47 ` David Ahern
2013-05-31 11:52 ` [tip:perf/core] perf tools: Save parent pid in thread struct tip-bot for David Ahern
1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2013-05-26 4:47 UTC (permalink / raw)
To: acme, linux-kernel
Cc: David Ahern, Frederic Weisbecker, Ingo Molnar, Jiri Olsa,
Namhyung Kim, Peter Zijlstra, Stephane Eranian
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>
---
tools/perf/Documentation/perf-script.txt | 2 +-
tools/perf/builtin-script.c | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index e9cbfcd..3cca420 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -115,7 +115,7 @@ OPTIONS
-f::
--fields::
Comma separated list of fields to print. Options are:
- comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff.
+ comm, tid, pid, ppid, time, cpu, event, trace, ip, sym, dso, addr, symoff.
Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.
e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 2e07c70..9e400e6 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -41,6 +41,7 @@ enum perf_output_field {
PERF_OUTPUT_DSO = 1U << 9,
PERF_OUTPUT_ADDR = 1U << 10,
PERF_OUTPUT_SYMOFFSET = 1U << 11,
+ PERF_OUTPUT_PPID = 1U << 12,
};
struct output_option {
@@ -50,6 +51,7 @@ struct output_option {
{.str = "comm", .field = PERF_OUTPUT_COMM},
{.str = "tid", .field = PERF_OUTPUT_TID},
{.str = "pid", .field = PERF_OUTPUT_PID},
+ {.str = "ppid", .field = PERF_OUTPUT_PPID},
{.str = "time", .field = PERF_OUTPUT_TIME},
{.str = "cpu", .field = PERF_OUTPUT_CPU},
{.str = "event", .field = PERF_OUTPUT_EVNAME},
@@ -208,7 +210,7 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
return -EINVAL;
}
- if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) &&
+ if ((PRINT_FIELD(PID) || PRINT_FIELD(TID) || PRINT_FIELD(PPID)) &&
perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID",
PERF_OUTPUT_TID|PERF_OUTPUT_PID))
return -EINVAL;
@@ -283,6 +285,9 @@ static void print_sample_start(struct perf_sample *sample,
else if (PRINT_FIELD(TID))
printf("%5d ", sample->tid);
+ if (PRINT_FIELD(PPID))
+ printf("%5d ", thread->ppid);
+
if (PRINT_FIELD(CPU)) {
if (latency_format)
printf("%3d ", sample->cpu);
@@ -1274,7 +1279,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK('f', "fields", NULL, "str",
"comma separated output fields prepend with 'type:'. "
"Valid types: hw,sw,trace,raw. "
- "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
+ "Fields: comm,tid,pid,ppid,time,cpu,event,trace,ip,sym,dso,"
"addr,symoff", parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", &system_wide,
"system-wide collection from all CPUs"),
--
1.7.10.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip:perf/core] perf tools: Save parent pid in thread struct
2013-05-26 4:47 [PATCH 1/2] perf: save parent pid in thread struct David Ahern
2013-05-26 4:47 ` [PATCH 2/2] perf script: add option to dump parent pid David Ahern
@ 2013-05-31 11:52 ` tip-bot for David Ahern
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for David Ahern @ 2013-05-31 11:52 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, eranian, hpa, mingo, peterz, namhyung, jolsa,
fweisbec, dsahern, tglx
Commit-ID: 70c57efb6118bff7426a6086026a4a8f3bd3c9e3
Gitweb: http://git.kernel.org/tip/70c57efb6118bff7426a6086026a4a8f3bd3c9e3
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 25 May 2013 22:47:10 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2013 16:24:05 +0300
perf tools: Save parent pid in thread struct
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 | 4 ++++
tools/perf/util/thread.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 632e40e..40399cb 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -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;
}
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 5ad2664..eeb7ac6 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -13,6 +13,7 @@ struct thread {
};
struct map_groups mg;
pid_t pid;
+ pid_t ppid;
char shortname[3];
bool comm_set;
char *comm;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-31 11:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-26 4:47 [PATCH 1/2] perf: save parent pid in thread struct David Ahern
2013-05-26 4:47 ` [PATCH 2/2] perf script: add option to dump parent pid David Ahern
2013-05-31 11:52 ` [tip:perf/core] perf tools: Save parent pid in thread struct tip-bot for David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox