Inherit bit is useless for a system wide evsel [1]. Further kernel
improvements are giving more constrain [2] on inherit events. This
patch set inherit bit to 0 to avoid potential constrains.

[1] 
http://lkml.kernel.org/r/20151022124142.gq17...@twins.programming.kicks-ass.net
[2] http://lkml.kernel.org/r/1445559014-4667-1-git-send-email-...@kernel.org

Signed-off-by: Wang Nan <wangn...@huawei.com>
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Alexei Starovoitov <a...@plumgrid.com>
Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
Cc: Li Zefan <lize...@huawei.com>
Cc: pi3or...@163.com
Link: http://lkml.kernel.org/n/ebpf-0tgilipxoo6fiebcxu3ft...@git.kernel.org
---

evsel->system_wide doesn't correct reflect whether this evsel is system
wide or not, so checks pid when invoking perf_event_open, and it is
always correct.

---
 tools/perf/util/evsel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 5566b16..e2d6c9a 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1337,6 +1337,7 @@ retry_sample_id:
 
                for (thread = 0; thread < nthreads; thread++) {
                        int group_fd;
+                       struct perf_event_attr attr;
 
                        if (!evsel->cgrp && !evsel->system_wide)
                                pid = thread_map__pid(threads, thread);
@@ -1346,7 +1347,10 @@ retry_open:
                        pr_debug2("sys_perf_event_open: pid %d  cpu %d  
group_fd %d  flags %#lx\n",
                                  pid, cpus->map[cpu], group_fd, flags);
 
-                       FD(evsel, cpu, thread) = 
sys_perf_event_open(&evsel->attr,
+                       attr = evsel->attr;
+                       if (pid == -1)
+                               attr.inherit = 0;
+                       FD(evsel, cpu, thread) = sys_perf_event_open(&attr,
                                                                     pid,
                                                                     
cpus->map[cpu],
                                                                     group_fd, 
flags);
-- 
1.8.3.4

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

Reply via email to