[PATCH v6 00/13] perf: Support multiple system call tables in the build

2025-03-17 Thread Ian Rogers
This work builds on the clean up of system call tables and removal of libaudit by Charlie Jenkins . The system call table in perf trace is used to map system call numbers to names and vice versa. Prior to these changes, a single table matching the perf binary's build was present. The table would b

[PATCH v6 02/13] perf dso: kernel-doc for enum dso_binary_type

2025-03-17 Thread Ian Rogers
There are many and non-obvious meanings to the dso_binary_type enum values. Add kernel-doc to speed interpretting their meanings. Acked-by: Arnaldo Carvalho de Melo Signed-off-by: Ian Rogers --- tools/perf/util/dso.h | 57 +++ 1 file changed, 57 insertion

[PATCH v6 06/13] perf dso: Add support for reading the e_machine type for a dso

2025-03-17 Thread Ian Rogers
For ELF file dsos read the e_machine from the ELF header. For kernel types assume the e_machine matches the perf tool. In other cases return EM_NONE. When reading from the ELF header use DSO__SWAP that may need dso->needs_swap initializing. Factor out dso__swap_init to allow this. Signed-off-by:

[PATCH v6 07/13] perf thread: Add support for reading the e_machine type for a thread

2025-03-17 Thread Ian Rogers
First try to read the e_machine from the dsos associated with the thread's maps. If live use the executable from /proc/pid/exe and read the e_machine from the ELF header. On failure use EM_HOST. Change builtin-trace syscall functions to pass e_machine from the thread rather than EM_HOST, so that in

[PATCH v6 13/13] perf trace: Fix BTF memory leak

2025-03-17 Thread Ian Rogers
Add missing btf__free in trace__exit. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index a5f31472980b..d4bbb6a1e817 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/pe

[PATCH v6 12/13] perf trace: Make syscall table stable

2025-03-17 Thread Ian Rogers
Namhyung fixed the syscall table being reallocated and moving by reloading the system call pointer after a move: https://lore.kernel.org/lkml/z9yhcziniu4ub...@google.com/ This could be brittle so this patch changes the syscall table to be an array of pointers of "struct syscall" that don't move. Re

[PATCH v6 09/13] perf syscalltbl: Use lookup table containing multiple architectures

2025-03-17 Thread Ian Rogers
Switch to use the lookup table containing all architectures rather than tables matching the perf binary. This fixes perf trace when executed on a 32-bit i386 binary on an x86-64 machine. Note in the following the system call names of the 32-bit i386 binary as seen by an x86-64 perf. Before: ```

[PATCH v6 08/13] perf trace beauty: Add syscalltbl.sh generating all system call tables

2025-03-17 Thread Ian Rogers
Rather than generating individual syscall header files generate a single trace/beauty/generated/syscalltbl.c. In a syscalltbls array have references to each architectures tables along with the corresponding e_machine. When the 32-bit or 64-bit table is ambiguous, match the perf binary's type. For A

[PATCH v6 05/13] perf syscalltbl: Remove struct syscalltbl

2025-03-17 Thread Ian Rogers
The syscalltbl held entries of system call name and number pairs, generated from a native syscalltbl at start up. As there are gaps in the system call number there is a notion of index into the table. Going forward we want the system call table to be identifiable by a machine type, for example, i38

[PATCH v6 04/13] perf trace: Reorganize syscalls

2025-03-17 Thread Ian Rogers
Identify struct syscall information in the syscalls table by a machine type and syscall number, not just system call number. Having the machine type means that 32-bit system calls can be differentiated from 64-bit ones on a machine capable of both. Having a table for all machine types and all syste

[PATCH v6 03/13] perf syscalltbl: Remove syscall_table.h

2025-03-17 Thread Ian Rogers
The definition of "static const char *const syscalltbl[] = {" is done in a generated syscalls_32.h or syscalls_64.h that is architecture dependent. In order to include the appropriate file a syscall_table.h is found via the perf include path and it includes the syscalls_32.h or syscalls_64.h as app

[PATCH v6 01/13] perf dso: Move libunwind dso_data variables into ifdef

2025-03-17 Thread Ian Rogers
The variables elf_base_addr, debug_frame_offset, eh_frame_hdr_addr and eh_frame_hdr_offset are only accessed in unwind-libunwind-local.c which is conditionally built on having libunwind support. Make the variables conditional on libunwind support too. Reviewed-by: Arnaldo Carvalho de Melo Signed-

Re: [PATCH v5 00/11] perf: Support multiple system call tables in the build

2025-03-17 Thread Arnaldo Carvalho de Melo
On Mon, Mar 17, 2025 at 05:48:10PM -0300, Arnaldo Carvalho de Melo wrote: > On Fri, Mar 14, 2025 at 02:10:54PM -0300, Arnaldo Carvalho de Melo wrote: > > On Thu, Mar 13, 2025 at 10:45:49PM -0700, Namhyung Kim wrote: > > > On Thu, Mar 13, 2025 at 05:47:27PM -0300, Arnaldo Carvalho de Melo wrote: > >

Re: [PATCH v5 00/11] perf: Support multiple system call tables in the build

2025-03-17 Thread Arnaldo Carvalho de Melo
On Fri, Mar 14, 2025 at 02:10:54PM -0300, Arnaldo Carvalho de Melo wrote: > On Thu, Mar 13, 2025 at 10:45:49PM -0700, Namhyung Kim wrote: > > On Thu, Mar 13, 2025 at 05:47:27PM -0300, Arnaldo Carvalho de Melo wrote: > > > On Thu, Mar 13, 2025 at 05:20:09PM -0300, Arnaldo Carvalho de Melo wrote: > >

Re: [PATCH 00/11] Always call constructor for kernel page tables

2025-03-17 Thread Ryan Roberts
On 17/03/2025 14:16, Kevin Brodsky wrote: > The complications in those special pgtable allocators beg the question: > does it really make sense to treat efi_mm and init_mm differently in > e.g. apply_to_pte_range()? Maybe what we really need is a way to tell if > an mm corresponds to user memory or

Re: [PATCH v5 00/11] perf: Support multiple system call tables in the build

2025-03-17 Thread Ian Rogers
On Sat, Mar 15, 2025 at 4:02 PM Namhyung Kim wrote: > > On Fri, Mar 14, 2025 at 05:48:12PM -0300, Arnaldo Carvalho de Melo wrote: > > On Fri, Mar 14, 2025 at 02:26:41PM -0300, Arnaldo Carvalho de Melo wrote: > > > it finds the pair, but then its sc->args has a bogus pointer... I'll see > > > where

[PATCH 01/11] mm: Pass mm down to pagetable_{pte,pmd}_ctor

2025-03-17 Thread Kevin Brodsky
In preparation for calling constructors for all kernel page tables while eliding unnecessary ptlock initialisation, let's pass down the associated mm to the PTE/PMD level ctors. (These are the two levels where ptlocks are used.) In most cases the mm is already around at the point of calling the ct

[PATCH 05/11] sparc64: mm: Call ctor/dtor for kernel PTEs

2025-03-17 Thread Kevin Brodsky
The generic implementation of pte_{alloc_one,free}_kernel now calls the [cd]tor, without initialising the ptlock needlessly as pagetable_pte_ctor() skips it for init_mm. Align sparc64 with the generic implementation by ensuring pagetable_pte_[cd]tor() are called for kernel PTEs. As a result the ke

[PATCH 11/11] riscv: mm: Call PUD/P4D ctor in special kernel pgtable alloc

2025-03-17 Thread Kevin Brodsky
Constructors for PUD/P4D-level pgtables were recently introduced. They should be called for all pgtables; make sure they are called for special kernel mappings created by create_pgd_mapping() too. While at it also switch to using pagetable_alloc() like in alloc_{pte,pmd}_late(). Signed-off-by: Ke

[PATCH 10/11] arm64: mm: Call PUD/P4D ctor in __create_pgd_mapping()

2025-03-17 Thread Kevin Brodsky
Constructors for PUD/P4D-level pgtables were recently introduced. They should be called for all pgtables; make sure they are called for special kernel mappings created by __create_pgd_mapping() too. Signed-off-by: Kevin Brodsky --- arch/arm64/mm/mmu.c | 6 +- 1 file changed, 5 insertions(+),

[PATCH 09/11] riscv: mm: Clarify ctor mm argument in alloc_{pte,pmd}_late

2025-03-17 Thread Kevin Brodsky
pagetable_{pte,pmd}_ctor(mm, ptdesc) skip the ptlock initialisation if mm is &init_mm. To avoid unnecessary overhead, it is therefore preferable to pass the actual mm associated to the PTE/PMD. Unfortunately, this proves challenging for alloc_{pte,pmd}_late() as the associated mm is not available

[PATCH 07/11] arm64: mm: Use enum to identify pgtable level instead of *_SHIFT

2025-03-17 Thread Kevin Brodsky
Commit 90292aca9854 ("arm64: mm: use appropriate ctors for page tables") introduced pgtable ctor calls in pgd_pgtable_alloc(). To identify the pgtable level and call the appropriate ctor, the *_SHIFT value associated with the pgtable level is used. However, those values do not unambiguously identif

[PATCH 08/11] arm64: mm: Always call PTE/PMD ctor in __create_pgd_mapping()

2025-03-17 Thread Kevin Brodsky
TL;DR: always call the PTE/PMD ctor, passing the appropriate mm to skip ptlock_init() if unneeded. __create_pgd_mapping() is used for creating different kinds of mappings, and may allocate page table pages if passed an allocator callback. There are currently three such cases: 1. create_pgd_mappin

[PATCH 06/11] mm: Skip ptlock_init() for kernel PMDs

2025-03-17 Thread Kevin Brodsky
Split page table locks are not used for pgtables associated to init_mm, at any level. pte_alloc_kernel() does not call ptlock_init() as a result. There is however no separate alloc/free functions for kernel PMDs, and pmd_ptlock_init() is called unconditionally. When ALLOC_SPLIT_PTLOCKS is true (e.g

[PATCH 04/11] powerpc: mm: Call ctor/dtor for kernel PTEs

2025-03-17 Thread Kevin Brodsky
The generic implementation of pte_{alloc_one,free}_kernel now calls the [cd]tor, without initialising the ptlock needlessly as pagetable_pte_ctor() skips it for init_mm. On powerpc, all functions related to PTE allocation are implemented by common helpers, which are passed a boolean to differentia

[PATCH 03/11] m68k: mm: Call ctor/dtor for kernel PTEs

2025-03-17 Thread Kevin Brodsky
The generic implementation of pte_{alloc_one,free}_kernel now calls the [cd]tor. Align the m68k/ColdFire implementation of those functions by calling the [cd]tor explicitly. Signed-off-by: Kevin Brodsky --- arch/m68k/include/asm/mcf_pgalloc.h | 6 +- 1 file changed, 5 insertions(+), 1 deleti

[PATCH 02/11] mm: Call ctor/dtor for kernel PTEs

2025-03-17 Thread Kevin Brodsky
Since [1], constructors/destructors are expected to be called for all page table pages, at all levels and for both user and kernel pgtables. There is however one glaring exception: kernel PTEs are managed via separate helpers (pte_alloc_kernel/pte_free_kernel), which do not call the [cd]tor, at lea

[PATCH 00/11] Always call constructor for kernel page tables

2025-03-17 Thread Kevin Brodsky
There has been much confusion around exactly when page table constructors/destructors (pagetable_*_[cd]tor) are supposed to be called. They were initially introduced for user PTEs only (to support split page table locks), then at the PMD level for the same purpose. Accounting was added later on, st

Re: [PATCH v2 06/13] nios2: move pr_debug() about memory start and end to setup_arch()

2025-03-17 Thread Dinh Nguyen
On 3/13/25 08:49, Mike Rapoport wrote: From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/nios2/kernel/setup.c | 2 ++ arch/nios2/mm/i