All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Alireza Haghdoost <haghdoost@uber.com>
Cc: Ian Rogers <irogers@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@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>,
	James Clark <james.clark@linaro.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andriin@fb.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 4/5] perf script: Add --lazy-load-symbols to load symbol names lazily
Date: Sat, 14 Nov 2026 19:47:24 -0800	[thread overview]
Message-ID: <avkrTBAE08wB5Qy1@z2> (raw)
In-Reply-To: <CA+w=M=S-H4d_-KCZJqdPoUCyfYtNDsKLd8t37kT134bwpKD7qw@mail.gmail.com>

On Fri, Nov 13, 2026 at 08:00:55PM -0800, Alireza Haghdoost wrote:
> On Sat, Oct 31, 2026 at 6:58 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Fri, Oct 30, 2026 at 08:55:55AM -0700, Ian Rogers wrote:
> > > I'm thinking this option should really be the default, requiring
> > > people to opt out.
> >
> > Agreed on making it default.  I'm not sure what's the case that needs
> > eager loading.  We can change the code to load all symbols just before
> > it (oh, it seems the patch already handles the cases) then no option
> > would be needed. :)
> 
> Sorry for the slow reply. I wanted to have v7 ready before answering.
> I agree that lazy loading should become the default, but I would like
> to keep it opt-in in v7 and flip it in a separate patch later.
> 
> While checking what default-on would change, I found that a binary
> replaced during the run gave wrong names. Lazy loading reads a name
> later, at the offset the symbol table had at load time. If a deploy
> replaces the binary in between, or the path resolves to another file
> because the process of a mount namespace exited, perf read the names
> from the new file. I reproduced it by swapping the binary under gdb;
> perf printed names of the other build. Eager loading reads every name
> at load time, so it is not affected. I fixed that in v7 and kept the
> device, inode,
> size and modification time of the file and checks them whenever it opens
> the file again. If they changed, perf warns once and shows the
> remaining symbols of that DSO as [unknown].

We have struct dso_id to identify the binary.  The build-ID is the
preferred method to check it.

> 
> Also, each batch of names opens the file again, resolves its name and
> enters the mount namespace. On my test profile this is cheap (1.3 s
> lazy vs 2.9 s eager, identical output), but I have not measured it for
> containers or debuglink layouts. The type-aware data cache that we
> discussed on v5 would remove most of that cost.

Right, having a fd in the cache, would solve many problems.

> 
> So my plan is to run lazy loading in our continuous profiling at scale
> first, and then send a patch that makes it the default. By that time,
> hopefully we will have already added the type-aware data cache.
> Does that work for you?

Sounds good.  A real world testing would be great.  I'll find time to
work on the DSO access.

> 
> > > I'm curious if this is global just to avoid the expense of a mutex per
> > > symbol or it needs to be global? [...] but perhaps the dso__lock works?
> >
> > Probably.  dso__load() already takes the dso lock.
> 
> It was global because dso__named_symbols() and dso__sort_by_name()
> already hold the DSO lock when they load names, and the mutex is not
> recursive. Nothing that holds the DSO lock looks up symbols, so v7
> uses it: a lookup takes it only when the symbol it returns still needs
> its name, and the batch loader requires it held.
> 
> > Nit: I'm hesitate to argue about naming, but it seems a bit confusing.
> > Why does it skip to load when it doesn't have a (lazy) name?  Probably
> > symbol__needs_lazy_name() would be a little better...?
> 
> Agreed, renamed in v7.

Thanks,
Namhyung


  reply	other threads:[~2026-11-15  3:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 23:42 [PATCH v6 0/5] perf script: Lazy symbol loading Alireza Haghdoost via B4 Relay
2026-10-28 23:42 ` Alireza Haghdoost
2026-10-28 23:42 ` [PATCH v6 1/5] perf symbols: Fix broken ELF_C_READ_MMAP fallback guard Alireza Haghdoost via B4 Relay
2026-10-28 23:42   ` Alireza Haghdoost
2026-10-28 23:47   ` sashiko-bot
2026-11-04 20:54   ` Namhyung Kim
2026-10-28 23:42 ` [PATCH v6 2/5] perf symbols: Split out name-independent duplicate symbol selection Alireza Haghdoost via B4 Relay
2026-10-28 23:42   ` Alireza Haghdoost
2026-10-28 23:45   ` sashiko-bot
2026-10-30 15:25   ` Ian Rogers
2026-10-28 23:42 ` [PATCH v6 3/5] perf symbols: Point to the symbol name instead of embedding it Alireza Haghdoost via B4 Relay
2026-10-28 23:42   ` Alireza Haghdoost
2026-10-28 23:48   ` sashiko-bot
2026-10-30 15:34   ` Ian Rogers
2026-11-14  4:02     ` Alireza Haghdoost
2026-10-28 23:42 ` [PATCH v6 4/5] perf script: Add --lazy-load-symbols to load symbol names lazily Alireza Haghdoost via B4 Relay
2026-10-28 23:42   ` Alireza Haghdoost
2026-10-29  0:00   ` sashiko-bot
2026-10-30 15:55   ` Ian Rogers
2026-11-01  1:58     ` Namhyung Kim
2026-11-14  4:00       ` Alireza Haghdoost
2026-11-15  3:47         ` Namhyung Kim [this message]
2026-11-15  4:52           ` Alireza Haghdoost
2026-10-28 23:42 ` [PATCH v6 5/5] perf test: Test lazy symbol name loading Alireza Haghdoost via B4 Relay
2026-10-28 23:42   ` Alireza Haghdoost
2026-10-29  0:04   ` sashiko-bot
2026-10-30 16:01   ` 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=avkrTBAE08wB5Qy1@z2 \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=haghdoost@uber.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.