]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
perf trace beauty: Make beauty generated C code standalone .o files
authorIan Rogers <irogers@google.com>
Mon, 18 May 2026 15:46:26 +0000 (08:46 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 May 2026 20:46:45 +0000 (17:46 -0300)
commit537609924c43715e39a41762d3e3d3c7c534bb71
tree4f57bb6862b5eb64074f1d1e8850a6397b6e64cc
parent35c9fb22000f1ce10c0f3627d30fa8763e721719
perf trace beauty: Make beauty generated C code standalone .o files

Previously, builtin-trace.c directly included 15 embedded C files
(e.g. trace/beauty/mmap.c and fsconfig_arrays.c), which in turn depend
on dozens of generated beauty script arrays. To satisfy these embedded
inclusions, the global Makefile.perf would define all the generator
variables/rules and include them in the prepare umbrella target, choking
parallel build startup.

Furthermore, tools/perf/util/syscalltbl.c included its own generated mapper,
and util/env.c conditionally included arch_errno_names.c inline, splitting
consumers across directories and preventing clean Make encapsulation.

Refactor the framework to achieve better encapsulation:
1. Move util/syscalltbl.[ch] into trace/beauty/ to co-locate with all
   generated code consumers.
2. Create fsconfig.c and flatten embedded beauty .c files to compile as
   independent standalone objects via trace/beauty/Build, exporting their
   formatting functions via beauty.h and env.h. Switch arch_errno_names.o
   and syscalltbl.o assignments directly to perf-util-y and add an
   unconditional top-level recursive kbuild hook (perf-util-y += trace/beauty/)
   to compile them into libperf-util.a, resolving remote linkage for util/env.c,
   util/bpf-trace-summary.c, and standalone python extensions.
3. Bridge private opaque references (struct trace) securely via accessors
   trace__show_zeros() and trace__host(), avoiding header entanglements.
4. Consolidate all generator variables, script paths, and array generation
   rules entirely out of Makefile.perf and place them directly inside the
   exact local Build files where their output objects are compiled
   (trace/beauty/Build and trace/beauty/tracepoints/Build), binding
   prerequisites locally. Use  directly inside
   generator recipes to guarantee dynamic directory creation before script
   redirection, and append  across all rules to print
   clean, standardized GEN ... file.c output during compilation.
5. Clean up clean target to recursively remove the generated directory
   instead of relying on dozens of individual variables.

This unchokes the "prepare" target parallel barrier, allows make to evaluate
generation scripts purely locally where consumed, and flattens the tracepoint
formatting architecture.

Testing a parallel build (make -j28 all from scratch) shows improvements:
  Before:
    real    0m28.689s
    user    2m38.490s
    sys     0m30.148s

  After:
    real    0m27.642s
    user    2m32.356s
    sys     0m26.683s

So reclaiming ~9.6 seconds of raw CPU time and over 1 full second off
overall real-world build latency, by overlapping sub-make startup and
avoiding top-level double-parsing overhead.

Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Assisted-by: Gemini:gemini-3.1-pro-preview
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Chartre <alexandre.chartre@oracle.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Ankur Arora <ankur.a.arora@oracle.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: Costa Shulyupin <costa.shul@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Markus Mayer <mmayer@broadcom.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Monnet <qmo@kernel.org>
Cc: Ricky Ringler <ricky.ringler@proton.me>
Cc: Song Liu <song@kernel.org>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Tomas Glozar <tglozar@redhat.com>
Cc: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
29 files changed:
tools/perf/Build
tools/perf/Makefile.perf
tools/perf/builtin-trace.c
tools/perf/trace/beauty/Build
tools/perf/trace/beauty/arch_errno_names.c
tools/perf/trace/beauty/arch_errno_names.sh
tools/perf/trace/beauty/beauty.h
tools/perf/trace/beauty/eventfd.c
tools/perf/trace/beauty/fsconfig.c [new file with mode: 0644]
tools/perf/trace/beauty/futex_op.c
tools/perf/trace/beauty/futex_val3.c
tools/perf/trace/beauty/mmap.c
tools/perf/trace/beauty/mode_t.c
tools/perf/trace/beauty/msg_flags.c
tools/perf/trace/beauty/open_flags.c
tools/perf/trace/beauty/perf_event_open.c
tools/perf/trace/beauty/pid.c
tools/perf/trace/beauty/sched_policy.c
tools/perf/trace/beauty/seccomp.c
tools/perf/trace/beauty/signum.c
tools/perf/trace/beauty/socket_type.c
tools/perf/trace/beauty/syscalltbl.c [moved from tools/perf/util/syscalltbl.c with 100% similarity]
tools/perf/trace/beauty/syscalltbl.h [moved from tools/perf/util/syscalltbl.h with 100% similarity]
tools/perf/trace/beauty/tracepoints/Build
tools/perf/trace/beauty/waitid_options.c
tools/perf/util/Build
tools/perf/util/bpf-trace-summary.c
tools/perf/util/env.c
tools/perf/util/env.h