Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add file-handle feature test

The file handle (FHANDLE) support is configurable so some systems might not
have it. So add a config feature item to check it on build time so that we
don't add the cgroup tracking feature based on that.

Committer notes:

Had to make the test use the same construct as its later use in
synthetic-events.c, in the next patch in this series. i.e. make it be:

struct {
struct file_handle fh;
uint64_t cgroup_id;
} handle;

To cope with:

CC /tmp/build/perf/util/cloexec.o
util/synthetic-events.c:428:22: error: field 'fh' with CC /tmp/build/perf/util/call-path.o
variable sized type 'struct file_handle' not at the end of a struct or class is a GNU
extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
struct file_handle fh;
^
1 error generated.

Deal with this at some point, i.e. investigate if the right thing is to
remove that -Wgnu-variable-sized-type-not-at-end from our CFLAGS, for
now do the test the same way as it is used looks more sensible.

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200402015249.3800462-1-namhyung@kernel.org
[ split from a larger patch, removed blank line at EOF ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
49f550ea 460c3ed9

+28 -2
+2 -1
tools/build/Makefile.feature
··· 72 72 setns \ 73 73 libaio \ 74 74 libzstd \ 75 - disassembler-four-args 75 + disassembler-four-args \ 76 + file-handle 76 77 77 78 # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list 78 79 # of all feature tests
+5 -1
tools/build/feature/Makefile
··· 67 67 test-llvm.bin \ 68 68 test-llvm-version.bin \ 69 69 test-libaio.bin \ 70 - test-libzstd.bin 70 + test-libzstd.bin \ 71 + test-file-handle.bin 71 72 72 73 FILES := $(addprefix $(OUTPUT),$(FILES)) 73 74 ··· 321 320 322 321 $(OUTPUT)test-libzstd.bin: 323 322 $(BUILD) -lzstd 323 + 324 + $(OUTPUT)test-file-handle.bin: 325 + $(BUILD) 324 326 325 327 ############################### 326 328
+17
tools/build/feature/test-file-handle.c
··· 1 + #define _GNU_SOURCE 2 + #include <sys/types.h> 3 + #include <sys/stat.h> 4 + #include <fcntl.h> 5 + #include <inttypes.h> 6 + 7 + int main(void) 8 + { 9 + struct { 10 + struct file_handle fh; 11 + uint64_t cgroup_id; 12 + } handle; 13 + int mount_id; 14 + 15 + name_to_handle_at(AT_FDCWD, "/", &handle.fh, &mount_id, 0); 16 + return 0; 17 + }
+4
tools/perf/Makefile.config
··· 348 348 CFLAGS += -DHAVE_GETTID 349 349 endif 350 350 351 + ifeq ($(feature-file-handle), 1) 352 + CFLAGS += -DHAVE_FILE_HANDLE 353 + endif 354 + 351 355 ifdef NO_LIBELF 352 356 NO_DWARF := 1 353 357 NO_DEMANGLE := 1