[PATCH v4 0/8] perf trace: Augment enum arguments with BTF

Howard Chu posted 8 patches 1 year, 7 months ago
There is a newer version of this series
tools/perf/builtin-trace.c               | 229 ++++++++++++++++++++---
tools/perf/tests/builtin-test.c          |   1 +
tools/perf/tests/shell/trace_btf_enum.sh |  61 ++++++
tools/perf/tests/tests.h                 |   1 +
tools/perf/tests/workloads/Build         |   2 +
tools/perf/tests/workloads/landlock.c    |  38 ++++
tools/perf/trace/beauty/beauty.h         |   1 +
tools/perf/util/syscalltbl.c             |   7 +
tools/perf/util/syscalltbl.h             |   1 +
9 files changed, 317 insertions(+), 24 deletions(-)
create mode 100755 tools/perf/tests/shell/trace_btf_enum.sh
create mode 100644 tools/perf/tests/workloads/landlock.c
[PATCH v4 0/8] perf trace: Augment enum arguments with BTF
Posted by Howard Chu 1 year, 7 months ago
Changes in v4:

- Fix landlock workload's build error.

Changes in v3:

- Add trace__btf_scnprintf() helper function
- Remove is_enum memeber in struct syscall_arg_fmt, replace it with 
btf_is_enum()
- Add syscall_arg_fmt__cache_btf_enum() to cache btf_type only
- Resolve NO_LIBBPF=1 build error
- Skip BTF augmentation test if landlock_add_rule syscall and LIBBPF are not
available
- Rename landlock.c workload, add a comment to landlock.c workload
- Change the way of skipping 'enum ' prefix
- Add type_name member to struct syscall_arg

Changes in v2:

- Add trace_btf_enum regression test, and landlock workload

v1:

In this patch, BTF is used to turn enum value to the corresponding
enum variable name. There is only one system call that uses enum value
as its argument, that is `landlock_add_rule()`.

Enum arguments of non-syscall tracepoints can also be augmented, for
instance timer:hrtimer_start and timer:hrtimer_init's 'mode' argument.



Arnaldo Carvalho de Melo (2):
  perf trace: Introduce trace__btf_scnprintf()
  perf trace: Remove arg_fmt->is_enum, we can get that from the BTF type

Howard Chu (6):
  perf trace: Fix iteration of syscall ids in syscalltbl->entries
  perf trace: BTF-based enum pretty printing for syscall args
  perf trace: Augment non-syscall tracepoints with enum arguments with
    BTF
  perf trace: Filter enum arguments with enum names
  perf test: Add landlock workload
  perf test trace_btf_enum: Add regression test for the BTF augmentation
    of enums in 'perf trace'

 tools/perf/builtin-trace.c               | 229 ++++++++++++++++++++---
 tools/perf/tests/builtin-test.c          |   1 +
 tools/perf/tests/shell/trace_btf_enum.sh |  61 ++++++
 tools/perf/tests/tests.h                 |   1 +
 tools/perf/tests/workloads/Build         |   2 +
 tools/perf/tests/workloads/landlock.c    |  38 ++++
 tools/perf/trace/beauty/beauty.h         |   1 +
 tools/perf/util/syscalltbl.c             |   7 +
 tools/perf/util/syscalltbl.h             |   1 +
 9 files changed, 317 insertions(+), 24 deletions(-)
 create mode 100755 tools/perf/tests/shell/trace_btf_enum.sh
 create mode 100644 tools/perf/tests/workloads/landlock.c

-- 
2.45.2
Re: [PATCH v4 0/8] perf trace: Augment enum arguments with BTF
Posted by Arnaldo Carvalho de Melo 1 year, 7 months ago
On Thu, Jul 04, 2024 at 08:43:46PM +0800, Howard Chu wrote:
> Changes in v4:
> 
> - Fix landlock workload's build error.

Can you please take a look at what is at:

https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf_trace-btf_enum

?

I have it building on my set of containers, so far:

perfbuilder@number:~$ export BUILD_TARBALL=http://192.168.86.42/perf/perf-6.10.0-rc3.tar.xz
perfbuilder@number:~$ time dm
   1    97.75 almalinux:8                   : Ok   gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22) , clang version 17.0.6 (Red Hat 17.0.6-1.module_el8.10.0+3757+fc27b834) flex 2.6.1
   2    99.92 almalinux:9                   : Ok   gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3) , clang version 17.0.6 (AlmaLinux OS Foundation 17.0.6-5.el9) flex 2.6.4
   3   116.11 alpine:3.15                   : Ok   gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027 , Alpine clang version 12.0.1 flex 2.6.4
   4   115.06 alpine:3.16                   : Ok   gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219 , Alpine clang version 13.0.1 flex 2.6.4
   5    97.46 alpine:3.17                   : Ok   gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924 , Alpine clang version 15.0.7 flex 2.6.4
   6: alpine:3.18

And that is what I'm planning to have merged into perf-tools-next, for
6.12, as soon as the next merge window closes.

Tomorrow I'll not be able to participate on the perf-tools Office hours,
I´ll be starting a two week long vacation, I'll be able to reply to some
messages occasionally and if needed do any GSoC procedure step.

Best regards,

- Arnaldo
 
> Changes in v3:
> 
> - Add trace__btf_scnprintf() helper function
> - Remove is_enum memeber in struct syscall_arg_fmt, replace it with 
> btf_is_enum()
> - Add syscall_arg_fmt__cache_btf_enum() to cache btf_type only
> - Resolve NO_LIBBPF=1 build error
> - Skip BTF augmentation test if landlock_add_rule syscall and LIBBPF are not
> available
> - Rename landlock.c workload, add a comment to landlock.c workload
> - Change the way of skipping 'enum ' prefix
> - Add type_name member to struct syscall_arg
> 
> Changes in v2:
> 
> - Add trace_btf_enum regression test, and landlock workload
> 
> v1:
> 
> In this patch, BTF is used to turn enum value to the corresponding
> enum variable name. There is only one system call that uses enum value
> as its argument, that is `landlock_add_rule()`.
> 
> Enum arguments of non-syscall tracepoints can also be augmented, for
> instance timer:hrtimer_start and timer:hrtimer_init's 'mode' argument.
> 
> 
> 
> Arnaldo Carvalho de Melo (2):
>   perf trace: Introduce trace__btf_scnprintf()
>   perf trace: Remove arg_fmt->is_enum, we can get that from the BTF type
> 
> Howard Chu (6):
>   perf trace: Fix iteration of syscall ids in syscalltbl->entries
>   perf trace: BTF-based enum pretty printing for syscall args
>   perf trace: Augment non-syscall tracepoints with enum arguments with
>     BTF
>   perf trace: Filter enum arguments with enum names
>   perf test: Add landlock workload
>   perf test trace_btf_enum: Add regression test for the BTF augmentation
>     of enums in 'perf trace'
> 
>  tools/perf/builtin-trace.c               | 229 ++++++++++++++++++++---
>  tools/perf/tests/builtin-test.c          |   1 +
>  tools/perf/tests/shell/trace_btf_enum.sh |  61 ++++++
>  tools/perf/tests/tests.h                 |   1 +
>  tools/perf/tests/workloads/Build         |   2 +
>  tools/perf/tests/workloads/landlock.c    |  38 ++++
>  tools/perf/trace/beauty/beauty.h         |   1 +
>  tools/perf/util/syscalltbl.c             |   7 +
>  tools/perf/util/syscalltbl.h             |   1 +
>  9 files changed, 317 insertions(+), 24 deletions(-)
>  create mode 100755 tools/perf/tests/shell/trace_btf_enum.sh
>  create mode 100644 tools/perf/tests/workloads/landlock.c
> 
> -- 
> 2.45.2
Re: [PATCH v4 0/8] perf trace: Augment enum arguments with BTF
Posted by Howard Chu 1 year, 7 months ago
Hello Arnaldo,

Thanks for the review and improvements.

On Fri, Jul 5, 2024 at 3:52 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> On Thu, Jul 04, 2024 at 08:43:46PM +0800, Howard Chu wrote:
> > Changes in v4:
> >
> > - Fix landlock workload's build error.
>
> Can you please take a look at what is at:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf_trace-btf_enum

I think it looks good. I don't know the side effects of a fixed
landlock_add_rule syscall number but I'm sure you've taken all
circumstances into consideration.

>
> ?
>
> I have it building on my set of containers, so far:
>
> perfbuilder@number:~$ export BUILD_TARBALL=http://192.168.86.42/perf/perf-6.10.0-rc3.tar.xz
> perfbuilder@number:~$ time dm
>    1    97.75 almalinux:8                   : Ok   gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22) , clang version 17.0.6 (Red Hat 17.0.6-1.module_el8.10.0+3757+fc27b834) flex 2.6.1
>    2    99.92 almalinux:9                   : Ok   gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3) , clang version 17.0.6 (AlmaLinux OS Foundation 17.0.6-5.el9) flex 2.6.4
>    3   116.11 alpine:3.15                   : Ok   gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027 , Alpine clang version 12.0.1 flex 2.6.4
>    4   115.06 alpine:3.16                   : Ok   gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219 , Alpine clang version 13.0.1 flex 2.6.4
>    5    97.46 alpine:3.17                   : Ok   gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924 , Alpine clang version 15.0.7 flex 2.6.4
>    6: alpine:3.18
>
> And that is what I'm planning to have merged into perf-tools-next, for
> 6.12, as soon as the next merge window closes.

:)

>
> Tomorrow I'll not be able to participate on the perf-tools Office hours,
> I´ll be starting a two week long vacation, I'll be able to reply to some
> messages occasionally and if needed do any GSoC procedure step.

Got it, Enjoy.

Thanks,
Howard
>
> Best regards,
>
> - Arnaldo
>
> > Changes in v3:
> >
> > - Add trace__btf_scnprintf() helper function
> > - Remove is_enum memeber in struct syscall_arg_fmt, replace it with
> > btf_is_enum()
> > - Add syscall_arg_fmt__cache_btf_enum() to cache btf_type only
> > - Resolve NO_LIBBPF=1 build error
> > - Skip BTF augmentation test if landlock_add_rule syscall and LIBBPF are not
> > available
> > - Rename landlock.c workload, add a comment to landlock.c workload
> > - Change the way of skipping 'enum ' prefix
> > - Add type_name member to struct syscall_arg
> >
> > Changes in v2:
> >
> > - Add trace_btf_enum regression test, and landlock workload
> >
> > v1:
> >
> > In this patch, BTF is used to turn enum value to the corresponding
> > enum variable name. There is only one system call that uses enum value
> > as its argument, that is `landlock_add_rule()`.
> >
> > Enum arguments of non-syscall tracepoints can also be augmented, for
> > instance timer:hrtimer_start and timer:hrtimer_init's 'mode' argument.
> >
> >
> >
> > Arnaldo Carvalho de Melo (2):
> >   perf trace: Introduce trace__btf_scnprintf()
> >   perf trace: Remove arg_fmt->is_enum, we can get that from the BTF type
> >
> > Howard Chu (6):
> >   perf trace: Fix iteration of syscall ids in syscalltbl->entries
> >   perf trace: BTF-based enum pretty printing for syscall args
> >   perf trace: Augment non-syscall tracepoints with enum arguments with
> >     BTF
> >   perf trace: Filter enum arguments with enum names
> >   perf test: Add landlock workload
> >   perf test trace_btf_enum: Add regression test for the BTF augmentation
> >     of enums in 'perf trace'
> >
> >  tools/perf/builtin-trace.c               | 229 ++++++++++++++++++++---
> >  tools/perf/tests/builtin-test.c          |   1 +
> >  tools/perf/tests/shell/trace_btf_enum.sh |  61 ++++++
> >  tools/perf/tests/tests.h                 |   1 +
> >  tools/perf/tests/workloads/Build         |   2 +
> >  tools/perf/tests/workloads/landlock.c    |  38 ++++
> >  tools/perf/trace/beauty/beauty.h         |   1 +
> >  tools/perf/util/syscalltbl.c             |   7 +
> >  tools/perf/util/syscalltbl.h             |   1 +
> >  9 files changed, 317 insertions(+), 24 deletions(-)
> >  create mode 100755 tools/perf/tests/shell/trace_btf_enum.sh
> >  create mode 100644 tools/perf/tests/workloads/landlock.c
> >
> > --
> > 2.45.2