aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/namespaces.h
diff options
context:
space:
mode:
authorKrister Johansen <kjlx@templeofstupid.com>2017-07-05 21:48:08 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-07-18 22:14:09 -0400
commit843ff37bb59edbe51d64e77ba1b3245a15a4dd9f (patch)
tree7c1e50cb4b60af9776364ec65118c9a0db0cbcdf /tools/perf/util/namespaces.h
parent86bcdb5a43997bb02ba25a76482c7bfc652ba45b (diff)
perf symbols: Find symbols in different mount namespace
Teach perf how to resolve symbols from binaries that are in a different mount namespace from the tool. This allows perf to generate meaningful stack traces even if the binary resides in a different mount namespace from the tool. Signed-off-by: Krister Johansen <kjlx@templeofstupid.com> Tested-by: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/1499305693-1599-2-git-send-email-kjlx@templeofstupid.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/namespaces.h')
-rw-r--r--tools/perf/util/namespaces.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/perf/util/namespaces.h b/tools/perf/util/namespaces.h
index 468f1e9a1484..b20f6ead7b2d 100644
--- a/tools/perf/util/namespaces.h
+++ b/tools/perf/util/namespaces.h
@@ -11,6 +11,7 @@
11 11
12#include "../perf.h" 12#include "../perf.h"
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/refcount.h>
14 15
15struct namespaces_event; 16struct namespaces_event;
16 17
@@ -23,4 +24,36 @@ struct namespaces {
23struct namespaces *namespaces__new(struct namespaces_event *event); 24struct namespaces *namespaces__new(struct namespaces_event *event);
24void namespaces__free(struct namespaces *namespaces); 25void namespaces__free(struct namespaces *namespaces);
25 26
27struct nsinfo {
28 pid_t pid;
29 bool need_setns;
30 char *mntns_path;
31 refcount_t refcnt;
32};
33
34struct nscookie {
35 int oldns;
36 int newns;
37};
38
39void nsinfo__init(struct nsinfo *nsi);
40struct nsinfo *nsinfo__new(pid_t pid);
41void nsinfo__delete(struct nsinfo *nsi);
42
43struct nsinfo *nsinfo__get(struct nsinfo *nsi);
44void nsinfo__put(struct nsinfo *nsi);
45
46void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc);
47void nsinfo__mountns_exit(struct nscookie *nc);
48
49static inline void __nsinfo__zput(struct nsinfo **nsip)
50{
51 if (nsip) {
52 nsinfo__put(*nsip);
53 *nsip = NULL;
54 }
55}
56
57#define nsinfo__zput(nsi) __nsinfo__zput(&nsi)
58
26#endif /* __PERF_NAMESPACES_H */ 59#endif /* __PERF_NAMESPACES_H */