From: Charlie Jenkins <charlie@rivosinc.com>
To: Ian Rogers <irogers@google.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Kan Liang" <kan.liang@linux.intel.com>,
"John Garry" <john.g.garry@oracle.com>,
"Will Deacon" <will@kernel.org>,
"James Clark" <james.clark@linaro.org>,
"Mike Leach" <mike.leach@linaro.org>,
"Leo Yan" <leo.yan@linux.dev>, "Guo Ren" <guoren@kernel.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Bibo Mao" <maobibo@loongson.cn>, "Arnd Bergmann" <arnd@arndb.de>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Howard Chu" <howardchu95@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH v1 0/7] perf: Support multiple system call tables in the build
Date: Tue, 4 Feb 2025 11:05:33 -0800 [thread overview]
Message-ID: <Z6Jk_UN9i69QGqUj@ghost> (raw)
In-Reply-To: <CAP-5=fVk6N=FVXsJ9xRJZhYSh2sbmUkEPr5HqRd-pR7mbGts+w@mail.gmail.com>
On Mon, Feb 03, 2025 at 05:58:29PM -0800, Ian Rogers wrote:
> On Mon, Feb 3, 2025 at 3:02 PM Charlie Jenkins <charlie@rivosinc.com> wrote:
> > On Mon, Feb 03, 2025 at 12:54:59PM -0800, Ian Rogers wrote:
> [snip]
> > > I think it makes sense in the kernel, as the built binary doesn't have
> > > cross-platform concerns. This is probably also the reason why the perf
> > > tool has an arch directory. Let me know what you think is the right
> > > direction for the perf tool syscall table code.
> >
> > I am hesitant about moving all of the arch-specific syscall generation
> > flags into a single file.
>
> In these changes I had a single file to build up a mapping from ELF
> machine to syscall table in an array and I wanted to keep the logic to
> build the array alongside the logic to build up the components of the
> array - so the ifdefs were visually the same. As the scope is a single
> file and the variables are static, this can give useful C compiler
> "unused definition" warnings. You can trick the linker to give similar
> warnings at the scope of a file, so this isn't a deal breaker.
>
> > There is currently a really clean separation
> > between the architectures and it's possible to generate all of the
> > syscall tables for all of the architecutures based on the paths to the
> > syscall table.
>
> This doesn't happen currently as the build of the arch directory is to
> add in $(SRCARCH) only. So
> tools/perf/arch/arm64/entry/syscalls/Makefile.syscalls will only be
> included into the build if SRCARCH==arm64. As I've said I'm against
> the idea of the arch directory as it nearly always causes cross
> platform problems - not an issue in a Linux kernel build. We recently
> eliminated dwarf-regs for this reason (and hopefully fixing up cross
> platform disassembly issues as a consequence):
> https://lore.kernel.org/all/20241108234606.429459-1-irogers@google.com/
> We could have the syscall table logic not under arch and generate
> multiple files, but we'd be adding extra logic to pull things apart to
> then pull things back together again, which feels like unnecessary
> complexity.
>
> It seems in your changes the Kbuild and Makefile.syscalls are running
> in the arch directory - this feels like a lot of peculiar and
> separated build logic for just iterating over a bunch of arch
> directory names and calling a shell function on them - albeit with
> some arch specific parameters. There's also an extra C helper
> executable in your code.
Yes, I can understand why you be opposed to that and I don't have a good
counterargument.
> I kind of like that I get a single header
> that is the same across all architectures and with no more build
> system requirements than to support ifdefs - in fact the ifdefs are
> just there to keep the code size down there is a #define to make them
> all have no effect. I hear your "clean separation" but I also think
> separation across files can make things harder to read, state is in >1
> place. I've tried to cleanly separate within the script.
>
> I do think there is some tech debt in both changes. My:
> ```
> #if defined(ALL_SYSCALLTBL) || defined(__riscv)
> #if __BITS_PER_LONG != 64
> EOF
> build_tables "$tools_dir/scripts/syscall.tbl" "$outfile"
> common,32,riscv,memfd_secret EM_RISCV
> echo "#else" >> "$outfile"
> build_tables "$tools_dir/scripts/syscall.tbl" "$outfile"
> common,64,riscv,rlimit,memfd_secret EM_RISC
> V
> cat >> "$outfile" <<EOF
> #endif //__BITS_PER_LONG != 64
> ```
> means the perf binary word size determines the syscall table support.
> This is because the e_machine in the ELF header isn't unique in these
> two cases and having both tables would have no effect. You've moved
> this into the env arch name handling, but I think having >1 way to
> encode a binary type is suboptimal. There are some ELF flag ABI bits
> that resolve disassembler things on csky, so perhaps a resolution is
> to pass ELF flags along with the machine type. I'm not clear in your
> change how "32_riscv" is generated to solve the same problem. Imo,
> it'd kind of be nice not to introduce notions like "64_arm64" as we
> seem to be always mapping/normalizing/... these different notions and
> they feel inherently brittle.
Maybe it is brittle? It could be mapped to e_machine, but that just
might not be reasonable to work into the method from my patch.
>
> > What causes the arch directory to be a pain for Bazel? I
> > guess I am mostly confused why it makes sense to change the kernel
> > Makefiles in order to accomidate a rewrite of the build system in Bazel
> > that isn't planned to be used upstream.
>
> It's just software and so the issues are resolvable, ie I don't think
> bazel should be determining what happens upstream - it motivates me to
> some extent. For the bazel build I need to match the Makefile behavior
> with bits of script called genrule, the scope and quantity of these
> increase with the arch directory model, extra executables to have in
> the build etc. I also imagine cross platform stuff will add
> complexity, like mapping blaze's notions of machine type to those
> introduced in your change. It is all a lot of stuff and I think what's
> in these changes keeps things about as simple as they can be. It'd be
> nice to integrate the best features of both changes and I think some
> of the e_machine stuff here can be added onto your change to get the
> i386/x86-64 case to work. I'm not sold on the complexity of the build
> in your changes though, multiple files, Kbuild and Makefile.syscalls,
> the arch directory not optionally being built, helper executables.
> Ultimately it is the same shell logic in both changes, and your
> previous work laid out all the ground work for this (I'm very grateful
> for it :-) ).
Thanks for elaborating on this! I do wish we had more of this
conversation on the original patch so we could have molded the original
patch closer to what this one is doing. I know you did mention you would
like to get rid of the arch directory as feedback on that patch but I
hadn't realized that this was the direction you were hoping to take
this. It does seem like the changes you have made in this patch will
lead to a something that is more robust and simpler to maintain, so we
can move forward with reviewing this patch and stop reviewing the one I
wrote.
- Charlie
>
> Thanks,
> Ian
next prev parent reply other threads:[~2025-02-04 19:22 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-01 7:14 [PATCH v1 0/7] perf: Support multiple system call tables in the build Ian Rogers
2025-02-01 7:14 ` [PATCH v1 1/7] perf syscalltble: Remove syscall_table.h Ian Rogers
2025-02-01 7:14 ` [PATCH v1 2/7] perf trace: Reorganize syscalls Ian Rogers
2025-02-05 0:12 ` Howard Chu
2025-02-05 5:00 ` Ian Rogers
2025-02-01 7:14 ` [PATCH v1 3/7] perf syscalltbl: Remove struct syscalltbl Ian Rogers
2025-02-05 0:18 ` Howard Chu
2025-02-05 5:09 ` Ian Rogers
2025-02-01 7:14 ` [PATCH v1 4/7] perf thread: Add support for reading the e_machine type for a thread Ian Rogers
2025-02-01 7:14 ` [PATCH v1 5/7] perf trace beauty: Add syscalltbl.sh generating all system call tables Ian Rogers
2025-02-01 7:14 ` [PATCH v1 6/7] perf syscalltbl: Use lookup table containing multiple architectures Ian Rogers
2025-02-05 0:24 ` Howard Chu
2025-02-05 5:17 ` Ian Rogers
2025-02-01 7:14 ` [PATCH v1 7/7] perf build: Remove Makefile.syscalls Ian Rogers
2025-02-01 8:51 ` [PATCH v1 0/7] perf: Support multiple system call tables in the build Ian Rogers
2025-02-03 18:28 ` Ian Rogers
2025-02-03 19:02 ` Charlie Jenkins
2025-02-03 19:10 ` Ian Rogers
2025-02-03 19:15 ` Charlie Jenkins
2025-02-03 19:39 ` Ian Rogers
2025-02-03 20:06 ` Charlie Jenkins
2025-02-03 20:54 ` Ian Rogers
2025-02-03 23:02 ` Charlie Jenkins
2025-02-04 1:58 ` Ian Rogers
2025-02-04 19:05 ` Charlie Jenkins [this message]
2025-02-04 19:17 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z6Jk_UN9i69QGqUj@ghost \
--to=charlie@rivosinc.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=bjorn@rivosinc.com \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=guoren@kernel.org \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jirislaby@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=maobibo@loongson.cn \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox