aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-07-18 16:15:29 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-07-18 22:14:08 -0400
commit86bcdb5a43997bb02ba25a76482c7bfc652ba45b (patch)
tree60737d10e15be7e8dbff4d7da4ba1f80f72ea5e0 /tools/perf
parent59291f19824200b5a9046b79d37f02fb415335b0 (diff)
tools build: Add test for setns()
And provide an alternative implementation to keep perf building on older distros as we're about to add initial support for namespaces. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Krister Johansen <kjlx@templeofstupid.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-bqdwijunhjlvps1ardykhw1i@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Makefile.config5
-rw-r--r--tools/perf/util/Build4
-rw-r--r--tools/perf/util/setns.c8
-rw-r--r--tools/perf/util/util.h4
4 files changed, 21 insertions, 0 deletions
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index bdf0e87f9b29..37d203c4cd1f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -330,6 +330,11 @@ ifeq ($(feature-sched_getcpu), 1)
330 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT 330 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
331endif 331endif
332 332
333ifeq ($(feature-setns), 1)
334 CFLAGS += -DHAVE_SETNS_SUPPORT
335 $(call detected,CONFIG_SETNS)
336endif
337
333ifndef NO_LIBELF 338ifndef NO_LIBELF
334 CFLAGS += -DHAVE_LIBELF_SUPPORT 339 CFLAGS += -DHAVE_LIBELF_SUPPORT
335 EXTLIBS += -lelf 340 EXTLIBS += -lelf
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 79dea95a7f68..7580fe4d5d30 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -104,6 +104,10 @@ ifndef CONFIG_LIBELF
104libperf-y += symbol-minimal.o 104libperf-y += symbol-minimal.o
105endif 105endif
106 106
107ifndef CONFIG_SETNS
108libperf-y += setns.o
109endif
110
107libperf-$(CONFIG_DWARF) += probe-finder.o 111libperf-$(CONFIG_DWARF) += probe-finder.o
108libperf-$(CONFIG_DWARF) += dwarf-aux.o 112libperf-$(CONFIG_DWARF) += dwarf-aux.o
109libperf-$(CONFIG_DWARF) += dwarf-regs.o 113libperf-$(CONFIG_DWARF) += dwarf-regs.o
diff --git a/tools/perf/util/setns.c b/tools/perf/util/setns.c
new file mode 100644
index 000000000000..ce8fc290fce8
--- /dev/null
+++ b/tools/perf/util/setns.c
@@ -0,0 +1,8 @@
1#include "util.h"
2#include <unistd.h>
3#include <sys/syscall.h>
4
5int setns(int fd, int nstype)
6{
7 return syscall(__NR_setns, fd, nstype);
8}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 2c9e58a45310..1e5fe1d9ec32 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -58,4 +58,8 @@ const char *perf_tip(const char *dirpath);
58int sched_getcpu(void); 58int sched_getcpu(void);
59#endif 59#endif
60 60
61#ifndef HAVE_SETNS_SUPPORT
62int setns(int fd, int nstype);
63#endif
64
61#endif /* GIT_COMPAT_UTIL_H */ 65#endif /* GIT_COMPAT_UTIL_H */