mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-14 06:22:34 +02:00
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>
91 lines
1.8 KiB
C
91 lines
1.8 KiB
C
// SPDX-License-Identifier: LGPL-2.1
|
|
#include "trace/beauty/beauty.h"
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
|
|
#ifndef O_DIRECT
|
|
#define O_DIRECT 00040000
|
|
#endif
|
|
|
|
#ifndef O_DIRECTORY
|
|
#define O_DIRECTORY 00200000
|
|
#endif
|
|
|
|
#ifndef O_NOATIME
|
|
#define O_NOATIME 01000000
|
|
#endif
|
|
|
|
#ifndef O_TMPFILE
|
|
#define O_TMPFILE 020000000
|
|
#endif
|
|
|
|
#undef O_LARGEFILE
|
|
#define O_LARGEFILE 00100000
|
|
|
|
size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
|
|
{
|
|
const char *prefix = "O_";
|
|
int printed = 0;
|
|
|
|
if ((flags & O_ACCMODE) == O_RDONLY)
|
|
printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", "RDONLY");
|
|
if (flags == 0)
|
|
return printed;
|
|
#define P_FLAG(n) \
|
|
if (flags & O_##n) { \
|
|
printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
|
|
flags &= ~O_##n; \
|
|
}
|
|
|
|
P_FLAG(RDWR);
|
|
P_FLAG(APPEND);
|
|
P_FLAG(ASYNC);
|
|
P_FLAG(CLOEXEC);
|
|
P_FLAG(CREAT);
|
|
P_FLAG(DIRECT);
|
|
P_FLAG(DIRECTORY);
|
|
P_FLAG(EXCL);
|
|
P_FLAG(LARGEFILE);
|
|
P_FLAG(NOFOLLOW);
|
|
P_FLAG(TMPFILE);
|
|
P_FLAG(NOATIME);
|
|
P_FLAG(NOCTTY);
|
|
#ifdef O_NONBLOCK
|
|
P_FLAG(NONBLOCK);
|
|
#elif O_NDELAY
|
|
P_FLAG(NDELAY);
|
|
#endif
|
|
#ifdef O_PATH
|
|
P_FLAG(PATH);
|
|
#endif
|
|
#ifdef O_DSYNC
|
|
if ((flags & O_SYNC) == O_SYNC)
|
|
printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", "SYNC");
|
|
else {
|
|
P_FLAG(DSYNC);
|
|
}
|
|
#else
|
|
P_FLAG(SYNC);
|
|
#endif
|
|
P_FLAG(TRUNC);
|
|
P_FLAG(WRONLY);
|
|
#undef P_FLAG
|
|
|
|
if (flags)
|
|
printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
|
|
|
|
return printed;
|
|
}
|
|
|
|
size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg)
|
|
{
|
|
int flags = arg->val;
|
|
|
|
if (!(flags & O_CREAT))
|
|
arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */
|
|
|
|
return open__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
|
|
}
|