diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-18 16:15:29 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-18 22:14:08 -0400 |
| commit | 86bcdb5a43997bb02ba25a76482c7bfc652ba45b (patch) | |
| tree | 60737d10e15be7e8dbff4d7da4ba1f80f72ea5e0 /tools/perf | |
| parent | 59291f19824200b5a9046b79d37f02fb415335b0 (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.config | 5 | ||||
| -rw-r--r-- | tools/perf/util/Build | 4 | ||||
| -rw-r--r-- | tools/perf/util/setns.c | 8 | ||||
| -rw-r--r-- | tools/perf/util/util.h | 4 |
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 |
| 331 | endif | 331 | endif |
| 332 | 332 | ||
| 333 | ifeq ($(feature-setns), 1) | ||
| 334 | CFLAGS += -DHAVE_SETNS_SUPPORT | ||
| 335 | $(call detected,CONFIG_SETNS) | ||
| 336 | endif | ||
| 337 | |||
| 333 | ifndef NO_LIBELF | 338 | ifndef 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 | |||
| 104 | libperf-y += symbol-minimal.o | 104 | libperf-y += symbol-minimal.o |
| 105 | endif | 105 | endif |
| 106 | 106 | ||
| 107 | ifndef CONFIG_SETNS | ||
| 108 | libperf-y += setns.o | ||
| 109 | endif | ||
| 110 | |||
| 107 | libperf-$(CONFIG_DWARF) += probe-finder.o | 111 | libperf-$(CONFIG_DWARF) += probe-finder.o |
| 108 | libperf-$(CONFIG_DWARF) += dwarf-aux.o | 112 | libperf-$(CONFIG_DWARF) += dwarf-aux.o |
| 109 | libperf-$(CONFIG_DWARF) += dwarf-regs.o | 113 | libperf-$(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 | |||
| 5 | int 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); | |||
| 58 | int sched_getcpu(void); | 58 | int sched_getcpu(void); |
| 59 | #endif | 59 | #endif |
| 60 | 60 | ||
| 61 | #ifndef HAVE_SETNS_SUPPORT | ||
| 62 | int setns(int fd, int nstype); | ||
| 63 | #endif | ||
| 64 | |||
| 61 | #endif /* GIT_COMPAT_UTIL_H */ | 65 | #endif /* GIT_COMPAT_UTIL_H */ |
