Re: [PATCH/RFT] Re: [PATCH v5 1/8] perf trace: Fix iteration of syscall ids in syscalltbl->entries

From: Howard Chu
Date: Wed Oct 09 2024 - 02:58:24 EST


[Resending due to a mailing list error]

Hello Jiri,

If Namhyung's fix alone does not solve the problem please try this:

Thanks,
Howard

======

diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index 7c15dec6900d..8dff317a3d79 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -46,6 +46,11 @@ static const char *const *syscalltbl_native =
syscalltbl_mips_n64;
#include <asm/syscalls.c>
const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
static const char *const *syscalltbl_native = syscalltbl_loongarch;
+#else
+const int syscalltbl_native_max_id = 1;
+static const char *const syscalltbl_native[] = {
+ [0] = "unknown",
+};
#endif

struct syscall {
@@ -182,6 +187,11 @@ int syscalltbl__id(struct syscalltbl *tbl, const
char *name)
return audit_name_to_syscall(name, tbl->audit_machine);
}

+int syscalltbl__id_at_idx(struct syscalltbl *tbl __maybe_unused, int idx)
+{
+ return idx;
+}
+
int syscalltbl__strglobmatch_next(struct syscalltbl *tbl __maybe_unused,
const char *syscall_glob
__maybe_unused, int *idx __maybe_unused)
{

On Tue, Oct 8, 2024 at 11:54 PM Howard Chu <howardchu95@xxxxxxxxx> wrote:
>
> Hello Jiri,
>
> If Namhyung's fix alone does not solve the problem please try this:
>
> Thanks,
> Howard
>
> ======
>
> diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
> index 7c15dec6900d..8dff317a3d79 100644
> --- a/tools/perf/util/syscalltbl.c
> +++ b/tools/perf/util/syscalltbl.c
> @@ -46,6 +46,11 @@ static const char *const *syscalltbl_native = syscalltbl_mips_n64;
> #include <asm/syscalls.c>
> const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
> static const char *const *syscalltbl_native = syscalltbl_loongarch;
> +#else
> +const int syscalltbl_native_max_id = 1;
> +static const char *const syscalltbl_native[] = {
> + [0] = "unknown",
> +};
> #endif
>
> struct syscall {
> @@ -182,6 +187,11 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name)
> return audit_name_to_syscall(name, tbl->audit_machine);
> }
>
> +int syscalltbl__id_at_idx(struct syscalltbl *tbl __maybe_unused, int idx)
> +{
> + return idx;
> +}
> +
> int syscalltbl__strglobmatch_next(struct syscalltbl *tbl __maybe_unused,
> const char *syscall_glob __maybe_unused, int *idx __maybe_unused)
> {
>
> On Tue, Oct 8, 2024 at 10:57 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>>
>> Hello,
>>
>> On Tue, Oct 08, 2024 at 11:09:31AM +0200, Jiri Slaby wrote:
>> > On 27. 09. 24, 7:09, Jiri Slaby wrote:
>> > > On 02. 09. 24, 20:54, Arnaldo Carvalho de Melo wrote:
>> > > > On Mon, Sep 02, 2024 at 07:25:17AM +0200, Jiri Slaby wrote:
>> > > > > On 31. 08. 24, 1:30, Arnaldo Carvalho de Melo wrote:
>> > > > > > From 174899051e54ecdab06c07652a3d04ad000ab301 Mon Sep 17
>> > > > > > 00:00:00 2001
>> > > > > > From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>> > > > > > Date: Fri, 30 Aug 2024 19:53:47 -0300
>> > > > > > Subject: [PATCH 1/1] perf tools: Build x86 32-bit syscall table from
>> > > > > > arch/x86/entry/syscalls/syscall_32.tbl
>> > > > > >
>> > > > > > To remove one more use of the audit libs and address a problem reported
>> > > > > > with a recent change where a function isn't available when using the
>> > > > > > audit libs method, that should really go away, this being one step in
>> > > > > > that direction.
>> > > > > >
>> > > > > > The script used to generate the 64-bit syscall table was already
>> > > > > > parametrized to generate for both 64-bit and 32-bit, so just use it and
>> > > > > > wire the generated table to the syscalltbl.c routines.
>> > > > > >
>> > > > > > Reported-by: Jiri Slaby <jirislaby@xxxxxxxxxx>
>> > > > > > Suggested-by: Ian Rogers <irogers@xxxxxxxxxx>
>> > > > > > Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
>> > > > > > Cc: Howard Chu <howardchu95@xxxxxxxxx>
>> > > > > > Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
>> > > > > > Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
>> > > > > > Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
>> > > > > > Link: https://lore.kernel.org/lkml/6fe63fa3-6c63-4b75-ac09-884d26f6fb95@xxxxxxxxxx
>> > > > > > Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>> > > > >
>> > > > > Tested-by: Jiri Slaby <jirislaby@xxxxxxxxxx>
>> > > >
>> > > > Thanks a lot! Added to the cset.
>> > >
>> > > Oh, 32bit arm still affected:
>> > > /usr/lib/gcc/armv7hl-suse-linux-gnueabi/14/../../../../armv7hl-suse-linux-gnueabi/bin/ld: perf-in.o: in function `trace__init_syscalls_bpf_prog_array_maps':
>> > > tools/perf/builtin-trace.c:3461:(.text+0x899a0): undefined reference to
>> > > `syscalltbl__id_at_idx'
>> >
>> > Ping -- any input/fix for this?
>>
>> As a quick fix, we may add a dummy syscall table for other archs like
>> below. Can you please test this?
>>
>> Thanks,
>> Namhyung
>>
>> ---8<---
>> diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
>> index 7c15dec6900d8aaa..b7465a879d8bf416 100644
>> --- a/tools/perf/util/syscalltbl.c
>> +++ b/tools/perf/util/syscalltbl.c
>> @@ -46,6 +46,11 @@ static const char *const *syscalltbl_native = syscalltbl_mips_n64;
>> #include <asm/syscalls.c>
>> const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
>> static const char *const *syscalltbl_native = syscalltbl_loongarch;
>> +#else
>> +const int syscalltbl_native_max_id = 1;
>> +static const char *const syscalltbl_native[] = {
>> + [0] = "unknown",
>> +};
>> #endif
>>
>> struct syscall {
>>