[2/2,fyi] perf bench sched-seccomp-notify: Use the tools copy of seccomp.h UAPI

Message ID ZQGhjaojgOGtSNk6@kernel.org
State New
Headers
Series [1/2,fyi] tools headers UAPI: Copy seccomp.h to be able to build 'perf bench' in older systems |

Commit Message

Arnaldo Carvalho de Melo Sept. 13, 2023, 11:48 a.m. UTC
  To keep perf building in systems where types and defines used in this
new benchmark are not available, such as:

  12    13.46 centos:stream                 : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-20) (GCC)
    bench/sched-seccomp-notify.c: In function 'user_notif_syscall':
    bench/sched-seccomp-notify.c:55:27: error: 'SECCOMP_RET_USER_NOTIF' undeclared (first use in this function); did you mean 'SECCOMP_RET_ERRNO'?
       BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_USER_NOTIF),
                               ^~~~~~~~~~~~~~~~~~~~~~
    /git/perf-6.6.0-rc1/tools/include/uapi/linux/filter.h:49:59: note: in definition of macro 'BPF_STMT'
     #define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
                                                               ^
    bench/sched-seccomp-notify.c:55:27: note: each undeclared identifier is reported only once for each function it appears in
       BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_USER_NOTIF),
                               ^~~~~~~~~~~~~~~~~~~~~~
    /git/perf-6.6.0-rc1/tools/include/uapi/linux/filter.h:49:59: note: in definition of macro 'BPF_STMT'
     #define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
                                                               ^
    bench/sched-seccomp-notify.c:55:3: error: missing initializer for field 'k' of 'struct sock_filter' [-Werror=missing-field-initializers]
       BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_USER_NOTIF),
       ^~~~~~~~
    In file included from bench/sched-seccomp-notify.c:5:
    /git/perf-6.6.0-rc1/tools/include/uapi/linux/filter.h:28:8: note: 'k' declared here
      __u32 k;      /* Generic multiuse field */
            ^
    bench/sched-seccomp-notify.c: In function 'user_notification_sync_loop':
    bench/sched-seccomp-notify.c:70:28: error: storage size of 'resp' isn't known
      struct seccomp_notif_resp resp;
                                ^~~~
    bench/sched-seccomp-notify.c:71:23: error: storage size of 'req' isn't known
      struct seccomp_notif req;
                           ^~~
    bench/sched-seccomp-notify.c:76:23: error: 'SECCOMP_IOCTL_NOTIF_RECV' undeclared (first use in this function); did you mean 'SECCOMP_MODE_STRICT'?
       if (ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req))
                           ^~~~~~~~~~~~~~~~~~~~~~~~
                           SECCOMP_MODE_STRICT
    bench/sched-seccomp-notify.c:86:23: error: 'SECCOMP_IOCTL_NOTIF_SEND' undeclared (first use in this function); did you mean 'SECCOMP_RET_ACTION'?
       if (ioctl(listener, SECCOMP_IOCTL_NOTIF_SEND, &resp))
                           ^~~~~~~~~~~~~~~~~~~~~~~~
                           SECCOMP_RET_ACTION
    bench/sched-seccomp-notify.c:71:23: error: unused variable 'req' [-Werror=unused-variable]
      struct seccomp_notif req;
                           ^~~
    bench/sched-seccomp-notify.c:70:28: error: unused variable 'resp' [-Werror=unused-variable]
      struct seccomp_notif_resp resp;
                                ^~~~

  14    11.31 debian:10                     : FAIL gcc version 8.3.0 (Debian 8.3.0-6)

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andrei Vagin <avagin@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kees Kook <keescook@chromium.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/lkml/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bench/sched-seccomp-notify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/tools/perf/bench/sched-seccomp-notify.c b/tools/perf/bench/sched-seccomp-notify.c
index b04ebcde40361636..a01c40131493b76d 100644
--- a/tools/perf/bench/sched-seccomp-notify.c
+++ b/tools/perf/bench/sched-seccomp-notify.c
@@ -9,7 +9,7 @@ 
 #include <sys/syscall.h>
 #include <sys/ioctl.h>
 #include <linux/time64.h>
-#include <linux/seccomp.h>
+#include <uapi/linux/seccomp.h>
 #include <sys/prctl.h>
 
 #include <unistd.h>