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

perf tools: Remove dependency on libaudit

All architectures now support HAVE_SYSCALL_TABLE_SUPPORT, so the flag is
no longer needed. With the removal of the flag, the related
GENERIC_SYSCALL_TABLE can also be removed.

libaudit was only used as a fallback for when HAVE_SYSCALL_TABLE_SUPPORT
was not defined, so libaudit is also no longer needed for any
architecture.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mickaël Salaün <mic@digikod.net>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250108-perf_syscalltbl-v6-16-7543b5293098@rivosinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Charlie Jenkins and committed by
Arnaldo Carvalho de Melo
3cc550f5 00d1bfae

+11 -164
+1 -1
Documentation/admin-guide/workload-tracing.rst
··· 83 83 the necessary tools:: 84 84 85 85 sudo apt-get build-essentials flex bison yacc 86 - sudo apt install libelf-dev systemtap-sdt-dev libaudit-dev libslang2-dev libperl-dev libdw-dev 86 + sudo apt install libelf-dev systemtap-sdt-dev libslang2-dev libperl-dev libdw-dev 87 87 88 88 cscope is a good tool to browse kernel sources. Let's install it now:: 89 89
-4
tools/build/feature/Makefile
··· 13 13 test-gtk2.bin \ 14 14 test-gtk2-infobar.bin \ 15 15 test-hello.bin \ 16 - test-libaudit.bin \ 17 16 test-libbfd.bin \ 18 17 test-libbfd-buildid.bin \ 19 18 test-disassembler-four-args.bin \ ··· 230 231 231 232 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin: 232 233 $(BUILD) -lelf -llzma -lunwind-aarch64 233 - 234 - $(OUTPUT)test-libaudit.bin: 235 - $(BUILD) -laudit 236 234 237 235 $(OUTPUT)test-libslang.bin: 238 236 $(BUILD) -lslang
-11
tools/build/feature/test-libaudit.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <libaudit.h> 3 - 4 - extern int printf(const char *format, ...); 5 - 6 - int main(void) 7 - { 8 - printf("error message: %s\n", audit_errno_to_name(0)); 9 - 10 - return audit_open(); 11 - }
-2
tools/perf/Documentation/perf-check.txt
··· 51 51 dwarf_getlocations / HAVE_LIBDW_SUPPORT 52 52 dwarf-unwind / HAVE_DWARF_UNWIND_SUPPORT 53 53 auxtrace / HAVE_AUXTRACE_SUPPORT 54 - libaudit / HAVE_LIBAUDIT_SUPPORT 55 54 libbfd / HAVE_LIBBFD_SUPPORT 56 55 libcapstone / HAVE_LIBCAPSTONE_SUPPORT 57 56 libcrypto / HAVE_LIBCRYPTO_SUPPORT ··· 66 67 libunwind / HAVE_LIBUNWIND_SUPPORT 67 68 lzma / HAVE_LZMA_SUPPORT 68 69 numa_num_possible_cpus / HAVE_LIBNUMA_SUPPORT 69 - syscall_table / HAVE_SYSCALL_TABLE_SUPPORT 70 70 zlib / HAVE_ZLIB_SUPPORT 71 71 zstd / HAVE_ZSTD_SUPPORT 72 72
+2 -29
tools/perf/Makefile.config
··· 28 28 29 29 $(call detected_var,SRCARCH) 30 30 31 - ifneq ($(NO_SYSCALL_TABLE),1) 32 - NO_SYSCALL_TABLE := 1 33 - 34 - # architectures that use the generic syscall table scripts 35 - ifneq ($(filter $(SRCARCH), $(generic_syscall_table_archs)),) 36 - NO_SYSCALL_TABLE := 0 37 - CFLAGS += -DGENERIC_SYSCALL_TABLE 38 - CFLAGS += -I$(OUTPUT)arch/$(SRCARCH)/include/generated 39 - endif 40 - 41 - ifneq ($(NO_SYSCALL_TABLE),1) 42 - CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT 43 - endif 44 - endif 31 + CFLAGS += -I$(OUTPUT)arch/$(SRCARCH)/include/generated 45 32 46 33 # Additional ARCH settings for ppc 47 34 ifeq ($(SRCARCH),powerpc) ··· 763 776 endif 764 777 765 778 ifneq ($(NO_LIBTRACEEVENT),1) 766 - ifeq ($(NO_SYSCALL_TABLE),0) 767 - $(call detected,CONFIG_TRACE) 768 - else 769 - ifndef NO_LIBAUDIT 770 - $(call feature_check,libaudit) 771 - ifneq ($(feature-libaudit), 1) 772 - $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev) 773 - NO_LIBAUDIT := 1 774 - else 775 - CFLAGS += -DHAVE_LIBAUDIT_SUPPORT 776 - EXTLIBS += -laudit 777 - $(call detected,CONFIG_TRACE) 778 - endif 779 - endif 780 - endif 779 + $(call detected,CONFIG_TRACE) 781 780 endif 782 781 783 782 ifndef NO_LIBCRYPTO
-15
tools/perf/Makefile.perf
··· 59 59 # 60 60 # Define NO_LIBNUMA if you do not want numa perf benchmark 61 61 # 62 - # Define NO_LIBAUDIT if you do not want libaudit support 63 - # 64 62 # Define NO_LIBBIONIC if you do not want bionic support 65 63 # 66 64 # Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support ··· 116 118 # Define TCMALLOC to enable tcmalloc heap profiling. 117 119 # 118 120 # Define LIBBPF_DYNAMIC to enable libbpf dynamic linking. 119 - # 120 - # Define NO_SYSCALL_TABLE=1 to disable the use of syscall id to/from name tables 121 - # generated from the kernel .tbl or unistd.h files and use, if available, libaudit 122 - # for doing the conversions to/from strings/id. 123 121 # 124 122 # Define NO_LIBPFM4 to disable libpfm4 events extension. 125 123 # ··· 304 310 FEATURE_TESTS := all 305 311 endif 306 312 endif 307 - # architectures that use the generic syscall table 308 - generic_syscall_table_archs := riscv arc csky arm sh sparc xtensa x86 alpha parisc arm64 loongarch mips powerpc s390 309 - ifneq ($(filter $(SRCARCH), $(generic_syscall_table_archs)),) 310 313 include $(srctree)/tools/perf/scripts/Makefile.syscalls 311 - endif 312 314 include Makefile.config 313 315 endif 314 316 ··· 1092 1102 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 1093 1103 $(call QUIET_INSTALL, perf-iostat) \ 1094 1104 $(INSTALL) $(OUTPUT)perf-iostat -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 1095 - ifndef NO_LIBAUDIT 1096 - $(call QUIET_INSTALL, strace/groups) \ 1097 - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \ 1098 - $(INSTALL) trace/strace/groups/* -m 644 -t '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)' 1099 - endif 1100 1105 ifndef NO_LIBPERL 1101 1106 $(call QUIET_INSTALL, perl-scripts) \ 1102 1107 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
-2
tools/perf/builtin-check.c
··· 31 31 FEATURE_STATUS("dwarf_getlocations", HAVE_LIBDW_SUPPORT), 32 32 FEATURE_STATUS("dwarf-unwind", HAVE_DWARF_UNWIND_SUPPORT), 33 33 FEATURE_STATUS("auxtrace", HAVE_AUXTRACE_SUPPORT), 34 - FEATURE_STATUS("libaudit", HAVE_LIBAUDIT_SUPPORT), 35 34 FEATURE_STATUS("libbfd", HAVE_LIBBFD_SUPPORT), 36 35 FEATURE_STATUS("libcapstone", HAVE_LIBCAPSTONE_SUPPORT), 37 36 FEATURE_STATUS("libcrypto", HAVE_LIBCRYPTO_SUPPORT), ··· 46 47 FEATURE_STATUS("libunwind", HAVE_LIBUNWIND_SUPPORT), 47 48 FEATURE_STATUS("lzma", HAVE_LZMA_SUPPORT), 48 49 FEATURE_STATUS("numa_num_possible_cpus", HAVE_LIBNUMA_SUPPORT), 49 - FEATURE_STATUS("syscall_table", HAVE_SYSCALL_TABLE_SUPPORT), 50 50 FEATURE_STATUS("zlib", HAVE_ZLIB_SUPPORT), 51 51 FEATURE_STATUS("zstd", HAVE_ZSTD_SUPPORT), 52 52
-2
tools/perf/builtin-help.c
··· 447 447 #ifdef HAVE_LIBELF_SUPPORT 448 448 "probe", 449 449 #endif 450 - #if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT) 451 450 "trace", 452 - #endif 453 451 NULL }; 454 452 const char *builtin_help_usage[] = { 455 453 "perf help [--all] [--man|--web|--info] [command]",
-30
tools/perf/builtin-trace.c
··· 2073 2073 const char *name = syscalltbl__name(trace->sctbl, id); 2074 2074 int err; 2075 2075 2076 - #ifdef HAVE_SYSCALL_TABLE_SUPPORT 2077 2076 if (trace->syscalls.table == NULL) { 2078 2077 trace->syscalls.table = calloc(trace->sctbl->syscalls.max_id + 1, sizeof(*sc)); 2079 2078 if (trace->syscalls.table == NULL) 2080 2079 return -ENOMEM; 2081 2080 } 2082 - #else 2083 - if (id > trace->sctbl->syscalls.max_id || (id == 0 && trace->syscalls.table == NULL)) { 2084 - // When using libaudit we don't know beforehand what is the max syscall id 2085 - struct syscall *table = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc)); 2086 - 2087 - if (table == NULL) 2088 - return -ENOMEM; 2089 - 2090 - // Need to memset from offset 0 and +1 members if brand new 2091 - if (trace->syscalls.table == NULL) 2092 - memset(table, 0, (id + 1) * sizeof(*sc)); 2093 - else 2094 - memset(table + trace->sctbl->syscalls.max_id + 1, 0, (id - trace->sctbl->syscalls.max_id) * sizeof(*sc)); 2095 - 2096 - trace->syscalls.table = table; 2097 - trace->sctbl->syscalls.max_id = id; 2098 - } 2099 - #endif 2100 2081 sc = trace->syscalls.table + id; 2101 2082 if (sc->nonexistent) 2102 2083 return -EEXIST; ··· 2428 2447 2429 2448 err = -EINVAL; 2430 2449 2431 - #ifdef HAVE_SYSCALL_TABLE_SUPPORT 2432 2450 if (id > trace->sctbl->syscalls.max_id) { 2433 - #else 2434 - if (id >= trace->sctbl->syscalls.max_id) { 2435 - /* 2436 - * With libaudit we don't know beforehand what is the max_id, 2437 - * so we let trace__read_syscall_info() figure that out as we 2438 - * go on reading syscalls. 2439 - */ 2440 - err = trace__read_syscall_info(trace, id); 2441 - if (err) 2442 - #endif 2443 2451 goto out_cant_read; 2444 2452 } 2445 2453
+1 -5
tools/perf/perf.c
··· 84 84 #endif 85 85 { "kvm", cmd_kvm, 0 }, 86 86 { "test", cmd_test, 0 }, 87 - #if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT)) 87 + #if defined(HAVE_LIBTRACEEVENT) 88 88 { "trace", cmd_trace, 0 }, 89 89 #endif 90 90 { "inject", cmd_inject, 0 }, ··· 513 513 #ifndef HAVE_LIBTRACEEVENT 514 514 fprintf(stderr, 515 515 "trace command not available: missing libtraceevent devel package at build time.\n"); 516 - goto out; 517 - #elif !defined(HAVE_LIBAUDIT_SUPPORT) && !defined(HAVE_SYSCALL_TABLE_SUPPORT) 518 - fprintf(stderr, 519 - "trace command not available: missing audit-libs devel package at build time.\n"); 520 516 goto out; 521 517 #else 522 518 setup_path();
+2 -5
tools/perf/tests/make
··· 86 86 make_no_backtrace := NO_BACKTRACE=1 87 87 make_no_libcapstone := NO_CAPSTONE=1 88 88 make_no_libnuma := NO_LIBNUMA=1 89 - make_no_libaudit := NO_LIBAUDIT=1 90 89 make_no_libbionic := NO_LIBBIONIC=1 91 90 make_no_auxtrace := NO_AUXTRACE=1 92 91 make_no_libbpf := NO_LIBBPF=1 ··· 96 97 make_with_babeltrace:= LIBBABELTRACE=1 97 98 make_with_coresight := CORESIGHT=1 98 99 make_no_sdt := NO_SDT=1 99 - make_no_syscall_tbl := NO_SYSCALL_TABLE=1 100 100 make_no_libpfm4 := NO_LIBPFM4=1 101 101 make_with_gtk2 := GTK2=1 102 102 make_refcnt_check := EXTRA_CFLAGS="-DREFCNT_CHECKING=1" ··· 120 122 # all the NO_* variable combined 121 123 make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_GTK2=1 122 124 make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_BACKTRACE=1 123 - make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 125 + make_minimal += NO_LIBNUMA=1 NO_LIBBIONIC=1 124 126 make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 125 127 make_minimal += NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 126 - make_minimal += NO_LIBCAP=1 NO_SYSCALL_TABLE=1 NO_CAPSTONE=1 128 + make_minimal += NO_LIBCAP=1 NO_CAPSTONE=1 127 129 128 130 # $(run) contains all available tests 129 131 run := make_pure ··· 156 158 run += make_no_backtrace 157 159 run += make_no_libcapstone 158 160 run += make_no_libnuma 159 - run += make_no_libaudit 160 161 run += make_no_libbionic 161 162 run += make_no_auxtrace 162 163 run += make_no_libbpf
+3 -3
tools/perf/util/env.c
··· 480 480 return normalize_arch(arch_name); 481 481 } 482 482 483 - #if defined(HAVE_SYSCALL_TABLE_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 483 + #if defined(HAVE_LIBTRACEEVENT) 484 484 #include "trace/beauty/arch_errno_names.c" 485 485 #endif 486 486 487 487 const char *perf_env__arch_strerrno(struct perf_env *env __maybe_unused, int err __maybe_unused) 488 488 { 489 - #if defined(HAVE_SYSCALL_TABLE_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 489 + #if defined(HAVE_LIBTRACEEVENT) 490 490 if (env->arch_strerrno == NULL) 491 491 env->arch_strerrno = arch_syscalls__strerrno_function(perf_env__arch(env)); 492 492 493 493 return env->arch_strerrno ? env->arch_strerrno(err) : "no arch specific strerrno function"; 494 494 #else 495 - return "!(HAVE_SYSCALL_TABLE_SUPPORT && HAVE_LIBTRACEEVENT)"; 495 + return "!HAVE_LIBTRACEEVENT"; 496 496 #endif 497 497 } 498 498
+2 -2
tools/perf/util/generate-cmdlist.sh
··· 38 38 done 39 39 echo "#endif /* HAVE_LIBELF_SUPPORT */" 40 40 41 - echo "#if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT))" 41 + echo "#if defined(HAVE_LIBTRACEEVENT)" 42 42 sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt | 43 43 sort | 44 44 while read cmd ··· 51 51 p 52 52 }' "Documentation/perf-$cmd.txt" 53 53 done 54 - echo "#endif /* HAVE_LIBTRACEEVENT && (HAVE_LIBAUDIT_SUPPORT || HAVE_SYSCALL_TABLE_SUPPORT) */" 54 + echo "#endif /* HAVE_LIBTRACEEVENT */" 55 55 56 56 echo "#ifdef HAVE_LIBTRACEEVENT" 57 57 sed -n -e 's/^perf-\([^ ]*\)[ ].* traceevent.*/\1/p' command-list.txt |
-52
tools/perf/util/syscalltbl.c
··· 10 10 #include <linux/compiler.h> 11 11 #include <linux/zalloc.h> 12 12 13 - #ifdef HAVE_SYSCALL_TABLE_SUPPORT 14 13 #include <string.h> 15 14 #include "string2.h" 16 15 17 - #if defined(GENERIC_SYSCALL_TABLE) 18 16 #include <syscall_table.h> 19 17 const int syscalltbl_native_max_id = SYSCALLTBL_MAX_ID; 20 18 static const char *const *syscalltbl_native = syscalltbl; 21 - #else 22 - const int syscalltbl_native_max_id = 0; 23 - static const char *const syscalltbl_native[] = { 24 - [0] = "unknown", 25 - }; 26 - #endif 27 19 28 20 struct syscall { 29 21 int id; ··· 123 131 *idx = -1; 124 132 return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx); 125 133 } 126 - 127 - #else /* HAVE_SYSCALL_TABLE_SUPPORT */ 128 - 129 - #include <libaudit.h> 130 - 131 - struct syscalltbl *syscalltbl__new(void) 132 - { 133 - struct syscalltbl *tbl = zalloc(sizeof(*tbl)); 134 - if (tbl) 135 - tbl->audit_machine = audit_detect_machine(); 136 - return tbl; 137 - } 138 - 139 - void syscalltbl__delete(struct syscalltbl *tbl) 140 - { 141 - free(tbl); 142 - } 143 - 144 - const char *syscalltbl__name(const struct syscalltbl *tbl, int id) 145 - { 146 - return audit_syscall_to_name(id, tbl->audit_machine); 147 - } 148 - 149 - int syscalltbl__id(struct syscalltbl *tbl, const char *name) 150 - { 151 - return audit_name_to_syscall(name, tbl->audit_machine); 152 - } 153 - 154 - int syscalltbl__id_at_idx(struct syscalltbl *tbl __maybe_unused, int idx) 155 - { 156 - return idx; 157 - } 158 - 159 - int syscalltbl__strglobmatch_next(struct syscalltbl *tbl __maybe_unused, 160 - const char *syscall_glob __maybe_unused, int *idx __maybe_unused) 161 - { 162 - return -1; 163 - } 164 - 165 - int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx) 166 - { 167 - return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx); 168 - } 169 - #endif /* HAVE_SYSCALL_TABLE_SUPPORT */
-1
tools/perf/util/syscalltbl.h
··· 3 3 #define __PERF_SYSCALLTBL_H 4 4 5 5 struct syscalltbl { 6 - int audit_machine; 7 6 struct { 8 7 int max_id; 9 8 int nr_entries;