Skip to content

Commit 49f550e

Browse files
namhyungacmel
authored andcommitted
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 <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] [ split from a larger patch, removed blank line at EOF ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 460c3ed commit 49f550e

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

tools/build/Makefile.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ FEATURE_TESTS_BASIC := \
7272
setns \
7373
libaio \
7474
libzstd \
75-
disassembler-four-args
75+
disassembler-four-args \
76+
file-handle
7677

7778
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
7879
# of all feature tests

tools/build/feature/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ FILES= \
6767
test-llvm.bin \
6868
test-llvm-version.bin \
6969
test-libaio.bin \
70-
test-libzstd.bin
70+
test-libzstd.bin \
71+
test-file-handle.bin
7172

7273
FILES := $(addprefix $(OUTPUT),$(FILES))
7374

@@ -321,6 +322,9 @@ $(OUTPUT)test-libaio.bin:
321322
$(OUTPUT)test-libzstd.bin:
322323
$(BUILD) -lzstd
323324

325+
$(OUTPUT)test-file-handle.bin:
326+
$(BUILD)
327+
324328
###############################
325329

326330
clean:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

tools/perf/Makefile.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ ifeq ($(feature-gettid), 1)
348348
CFLAGS += -DHAVE_GETTID
349349
endif
350350

351+
ifeq ($(feature-file-handle), 1)
352+
CFLAGS += -DHAVE_FILE_HANDLE
353+
endif
354+
351355
ifdef NO_LIBELF
352356
NO_DWARF := 1
353357
NO_DEMANGLE := 1

0 commit comments

Comments
 (0)