Re: [PATCH v6 5/5] perf test: Test lazy symbol name loading
From: Ian Rogers
Date: Fri Oct 30 2026 - 12:06:30 EST
On Wed, Oct 28, 2026 at 4:42 PM Alireza Haghdoost via B4 Relay
<devnull+haghdoost.uber.com@xxxxxxxxxx> wrote:
>
> From: Alireza Haghdoost <haghdoost@xxxxxxxx>
>
> Add a "Lazy symbol loading" unit test suite:
>
> - "Duplicate selection without names" checks which pairs of symbols
> symbol__choice_needs_names() leaves to their names.
> - "Lazy symbol names" looks up lazy symbols whose names take one, two
> and three reads, and two whose names cannot be read: one with no NUL
> before the end of the file and one past the end. Lookups do not
> return those, and dso__sort_by_name() keeps them, named "[unknown]".
> - "Lazy symbol names loaded concurrently" looks up the same lazy
> symbols, some of them with names that cannot be read, from several
> threads while another walks them with dso__for_each_symbol(), and
> checks every name.
> - "Lazy and eager symbol parity" loads a DSO (perf itself, or the one
> given with --dso) eagerly and lazily. Lookups of the first and last
> address of each eager symbol must find the same symbol before and
> after every lazy name is loaded, and then the ranges and names of all
> symbols must match.
>
> Run the parity test from a shell test on four hand-built binaries:
>
> - a split-debuginfo binary whose function section is NOBITS in the
> debug file and has no PT_LOAD in the runtime file, so both loaders
> must fall back to the runtime section header;
> - a shared library with symbols present only in .dynsym, one of them
> an alias that duplicate selection prefers over its .symtab twin;
> - a stripped shared library whose local symbols are in .gnu_debugdata,
> one of them an alias of a .dynsym symbol, which must load eagerly;
> - on x86_64, a binary with an IRELATIVE PLT slot whose IFUNC loses
> duplicate selection to an alias that loses to another one in turn,
> so the PLT symbol name depends on how the IFUNC mark is passed on.
>
> Add a perf script shell test for --lazy-load-symbols. Record a small
> callchain fixture, require evidence that the perf binary was loaded with
> lazy names, check that the controlled test_loop symbol resolves, and
> compare the eager and lazy output. When run as root, also profile perf
> in a private mount namespace whose build-id cache directory is hidden by
> a tmpfs, so that names must be read from the build-id cache in perf's
> own namespace. The test reports a skip only if neither case can run, for
> example when libelf is missing or recording is not supported.
>
> Signed-off-by: Alireza Haghdoost <haghdoost@xxxxxxxx>
Huge fan of testing, and Sashiko can be a pain about corner cases.
Thanks for working on this! I'm happy to add a tag when Sashiko is
more happy.
Ian