[PATCH] Fix inhert with perf record --pid

From: Sukadev Bhattiprolu
Date: Fri Nov 08 2013 - 20:14:06 EST


If a target process is identified by its pid:

perf record --pid 1234

perf record does not follow any _newly_ created children of the
process. perf_evlist__config() clears the ->inherit flag.

if (evlist->cpus->map[0] < 0)
opts->no_inherit = true;

It can be fixed and descendants can be followed, by this change
below, but is this behavior by design ?

We do follow the children if the same process is started by perf:

perf record ./a.out

This was reported by Maynard Johnson <mpjohn@xxxxxxxxxx>

On a related note, perf_target__validate() has this:

/* CPU and PID are mutually exclusive */
if (target->tid && target->cpu_list) {
target->cpu_list = NULL;
if (ret == PERF_ERRNO_TARGET__SUCCESS)
ret = PERF_ERRNO_TARGET__PID_OVERRIDE_CPU;
}

Again, its not clear why pid and cpu are exclusive in this case:

perf record --pid 1234 -C 0,1,2

The system call allows the both pid and cpu to be specified.

Looking at commit, I see that this check was pulled in from builtin-top.c.

commit 4bd0f2d2c0cf14de9c84c2fe689120c6b0f667c8
Author: Namhyung Kim <namhyung.kim@xxxxxxx>
Date: Thu Apr 26 14:15:18 2012 +0900

Does that check apply to 'perf record' or only 'perf top' ?

Appreciate any comments.

---
tools/perf/util/evlist.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e584cd3..c81d01a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -742,7 +742,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist,
return -1;

if (perf_target__has_task(target))
- evlist->cpus = cpu_map__dummy_new();
+ evlist->cpus = cpu_map__new(target->cpu_list);
else if (!perf_target__has_cpu(target) && !target->uses_mmap)
evlist->cpus = cpu_map__dummy_new();
else
--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/