Skip to contentSkip to conversation

perf script: Lazy symbol loading

PATCH In review Alireza Haghdoost 3 participants 14 messages Nov 21 – Nov 23 perf events

lore
Share & tools
lore
#0 lore raw

v8 cover perf script: Lazy symbol loading

perf script loads the entire ELF symbol table of every DSO that appears in a sample, and keeps each symbol, with its demangled name, until process exit. Most of those symbols are never sampled. On a large profile this turns symbol loading into the main memory cost of perf script, and in a memory-constrained cgroup into an OOM kill.

With this series, perf script --lazy-load-symbols reads a symbol name only when a sample needs it. On a perf script run over a 45,073-sample callchain profile of a large C++ service (about 1M symbols), the output is identical in all three cases (medians of eleven runs):

                                      time    max RSS
  perf-tools-next                     3.70 s  319 MiB
  v8                                  3.75 s  327 MiB
  v8 --lazy-load-symbols              3.56 s  174 MiB

Eager loading remains the default, and costs 8 more bytes per symbol for the name pointer. Lazy loading covers userspace ELF .symtab and .dynsym. The kernel, modules, PPC64 .opd and .gnu_debugdata still load names eagerly.

The patches:

[1/7] Split the size, type and binding checks out of
choose_best_symbol(), so that the loader can tell which aliases need their names. No functional change. Unchanged from v7, reviewed by Ian.

[2/7] Make the symbol name a pointer instead of a flexible array, so
that a name can be set after the symbol is in the rb-tree. Unchanged from v7, reviewed by Ian.

[3/7] Add lazy symbol names to the symbol code: the DSO lookups read
the name of the symbol they return. Nothing creates such symbols yet.

[4/7] Check that the symbol table file is still the one perf loaded
before reading names from it. Nothing records a file yet.

[5/7] Add --lazy-load-symbols, which makes the ELF loader create
symbols with lazy names and record the file for the check.

[6/7] Unit tests for lazy names and for the file check.

[7/7] Shell tests, including parity with eager loading.

perf-tools-next now has the first three patches of Ian's series [1]. Its later patches replace the symbol rb-tree with an array, which would shrink each symbol further. They conflict with this series, since the name loading in 3/7 and the alias name loading in 5/7 walk that rb-tree. This series does not depend on them, and I'll rebase on them if they land first.

[1] https://lore.kernel.org/all/[email protected]/

Changes in v8:

- Rebase onto current perf-tools-next, which has Ian's annotation and ELF loader changes.
- Split v7 3/4 for review (Namhyung): 3/7 adds lazy names to the symbol code, 4/7 adds the check of the symbol table file, and 5/7 adds the option and makes the ELF loader create lazy names. The tests are in 6/7 (unit) and 7/7 (shell).
- 4/7: Also accept a file whose device, inode, size, mtime or ctime changed if it has the build ID of the DSO and its .strtab and .dynstr did not move, such as a copy of the same build (Namhyung). The identity is still checked first, since reading the build ID at each reopen more than doubles the time of the worst case.
- 4/7: Compare the ctime too, so a file copied over in place with its size and mtime kept (cp -p) is not taken for the same file. Treat a string table section that no longer exists or is compressed as another file.
- 4/7: Warn once when the file cannot be opened or checked, rather than only in debug output, and try again for later names, since the failure can be temporary.
- 5/7: Do not skip the .dynsym copies of lazy .symtab symbols. Skipping them changed the shape of the rb-tree, which broke lookups past a nested entry point and the PLT name of an exported IFUNC. This replaces the v7 fix for a zero-size symbol before a copy (Sashiko). Duplicate selection now reads the names of each copy, so on the profile above, where one binary exports most of its symbols, lazy loading keeps its memory saving but loses most of the run time it saved in v7. Most of that time goes to reading each name with its own pread(). As discussed with Namhyung, a later series will let the DSO data cache read the symbol table file, and names will be read through it. A prototype with a small read cache gets back about two thirds of the v7 speedup for about 1.5 MiB more RSS.
- 6/7: Add tests for a file overwritten in place, for a copy with the same build, with moved or missing string tables, and of another build, for a failed open, and for a copy whose build ID cannot be read.
- 7/7: Add parity cases for a zero-size symbol before a copy, nested entry points, and an exported IFUNC with aliases.

Previous versions:

v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

---
Alireza Haghdoost (7):
perf symbols: Split out name-independent duplicate symbol selection perf symbols: Point to the symbol name instead of embedding it perf symbols: Add lazy symbol names
perf symbols: Check the file before reading lazy symbol names perf script: Add --lazy-load-symbols to load symbol names lazily perf test: Add lazy symbol loading unit tests
perf test: Add lazy symbol loading shell tests

 tools/perf/Documentation/perf-script.txt           |  11 +
 tools/perf/builtin-script.c                        |   2 +
 tools/perf/tests/Build                             |   1 +
 tools/perf/tests/builtin-test.c                    |   1 +
 tools/perf/tests/shell/lazy_load_symbols_parity.sh | 447 ++++++++++
 tools/perf/tests/shell/lib/lazy_names.sh           |  20 +
 tools/perf/tests/shell/script_lazy_load_symbols.sh | 190 ++++
 tools/perf/tests/symbol-lazy.c                     | 963 +++++++++++++++++++++
 tools/perf/tests/tests.h                           |   1 +
 tools/perf/ui/browsers/map.c                       |   2 +-
 tools/perf/ui/stdio/hist.c                         |   1 +
 tools/perf/util/dso.c                              |   2 +-
 tools/perf/util/dso.h                              |  36 +-
 tools/perf/util/symbol-elf.c                       | 355 +++++++-
 tools/perf/util/symbol-minimal.c                   |   6 +
 tools/perf/util/symbol.c                           | 141 ++-
 tools/perf/util/symbol.h                           |  31 +-
 tools/perf/util/symbol_conf.h                      |   1 +
 18 files changed, 2183 insertions(+), 28 deletions(-)

---
base-commit: bb27ddbaee56536fb8df0a24f07b526766dfe131
change-id: 20260915-perf-symbol-memory-send-e7cfca1ac3d9

Best regards,

Signature · 1 line
Alireza Haghdoost <[email protected]>
#1 lore raw

PATCH v8 1/7 perf symbols: Split out name-independent duplicate symbol selection

This patch is a refactoring and does not change behavior. It moves the size, type and binding checks from choose_best_symbol() to choose_best_symbol_by_attrs(), and adds symbol__choice_needs_names() to tell whether choosing between two symbols needs their names.

symbols__fixup_duplicate() keeps one of the symbols that share a start address. It compares size, type and binding first. If those are equal, it compares leading underscores, name lengths and the result of arch__choose_best_symbol().

An unresolved lazy symbol stores a file offset instead of a name pointer, so the lazy loader cannot call choose_best_symbol() before it has read both names. The new helper lets it leave the names unread when the attributes already pick one of the symbols.

---
 tools/perf/util/symbol.c | 26 ++++++++++++++++++++++++--
 tools/perf/util/symbol.h |  1 +
 2 files changed, 25 insertions(+), 2 deletions(-)
tools/perf/util/symbol.c +24 -2
index a1ac1cd1d2e7..a5ed8a65986b 100644
@@ -157,11 +157,15 @@ int __weak arch__choose_best_symbol(struct symbol *syma,
 	return SYMBOL_A;
 }
 
-static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
+/*
+ * Choose between two symbols at the same address by size, type and binding.
+ * Returns SYMBOL_A or SYMBOL_B, or -1 if only their names can decide.
+ */
+static int choose_best_symbol_by_attrs(const struct symbol *syma,
+				       const struct symbol *symb)
 {
 	s64 a;
 	s64 b;
-	size_t na, nb;
 
 	/* Prefer a symbol with non zero length */
 	a = syma->end - syma->start;
@@ -194,6 +198,24 @@ static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
 	if (b && !a)
 		return SYMBOL_B;
 
+	return -1;
+}
+
+bool symbol__choice_needs_names(const struct symbol *syma, const struct symbol *symb)
+{
+	return choose_best_symbol_by_attrs(syma, symb) < 0;
+}
+
+static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
+{
+	int ret = choose_best_symbol_by_attrs(syma, symb);
+	s64 a;
+	s64 b;
+	size_t na, nb;
+
+	if (ret >= 0)
+		return ret;
+
 	/* Prefer a symbol with less underscores */
 	a = prefix_underscores_count(syma->name);
 	b = prefix_underscores_count(symb->name);
tools/perf/util/symbol.h +1 -0
index a6a2ab200f98..fc98fab1c8d0 100644
@@ -295,6 +295,7 @@ int arch__compare_symbol_names(const char *namea, const char *nameb);
 int arch__compare_symbol_names_n(const char *namea, const char *nameb,
 				 unsigned int n);
 int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb);
+bool symbol__choice_needs_names(const struct symbol *syma, const struct symbol *symb);
 
 enum symbol_tag_include {
 	SYMBOL_TAG_INCLUDE__NONE = 0,
Signature · 1 line
Git-157)
#2 lore raw

PATCH v8 2/7 perf symbols: Point to the symbol name instead of embedding it

In reply to Alireza Haghdoost

This patch changes the name field of struct symbol from a flexible array (char name[]) to a pointer (char *name). It does not change behavior, but each symbol allocation grows by 8 bytes on 64-bit hosts.

The next patch creates symbols whose names are read only when needed. perf does not know the length of such a name when it creates the symbol, so it cannot allocate the name after the symbol. It cannot reallocate the symbol later either, because the rb-tree and the callers hold pointers to it. With a pointer, the name is allocated separately and set when it is read.

---
 tools/perf/ui/stdio/hist.c | 1 +
 tools/perf/util/symbol.c   | 1 +
 tools/perf/util/symbol.h   | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)
tools/perf/ui/stdio/hist.c +1 -0
index 3240c39bd025..45841eac6f52 100644
@@ -106,6 +106,7 @@ static void init_rem_hits(void)
 		return;
 	}
 
+	rem_sq_bracket->name = (char *)(rem_sq_bracket + 1);
 	strcpy(rem_sq_bracket->name, "[...]");
 	rem_hits.ms.sym = rem_sq_bracket;
 }
tools/perf/util/symbol.c +1 -0
index a5ed8a65986b..ad4bf7685293 100644
@@ -354,6 +354,7 @@ struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *
 
 	pr_debug4("%s: %s %#" PRIx64 "-%#" PRIx64 "\n",
 		  __func__, name, start, sym->end);
+	sym->name = (char *)(sym + 1);
 	memcpy(sym->name, name, namelen);
 
 	return sym;
tools/perf/util/symbol.h +1 -1
index fc98fab1c8d0..a449c170d834 100644
@@ -92,7 +92,7 @@ struct symbol {
 	/** Architecture specific. Unused except on PPC where it holds st_other. */
 	u8		arch_sym;
 	/** The name of length namelen associated with the symbol. */
-	char		name[];
+	char		*name;
 };
 
 void symbol__delete(struct symbol *sym);
Signature · 1 line
Git-157)
#3 lore raw

PATCH v8 3/7 perf symbols: Add lazy symbol names

In reply to Alireza Haghdoost

This patch lets a symbol be created without its name, so that perf reads the name lazily only when it needs it and does not waste RSS memory holding symbol names that are never sampled. symbol__new_lazy() stores the file offset of the name instead, in a union with the name pointer, and SYMBOL_FLAG_LAZY_NAME tells which one is set. This is a preparatory change for a later patch in this series, which adds --lazy-load-symbols to the ELF loader.

The DSO lookups load the name of the symbol they return, and code that walks all symbols of a DSO gets them from dso__named_symbols(), which loads every name. Names are read under the DSO lock with pread() from the symbol table file, which is open only while perf reads them, and demangled as at load time. If another thread loaded them first, perf does not open the file. A name that cannot be read becomes "[unknown]", and address lookups do not return that symbol. The ELF loader looks symbols up with symbols__find(), so that it does not read names while it loads the symbols.

No functional change, since no symbol has a lazy name yet.

---
 tools/perf/ui/browsers/map.c     |   2 +-
 tools/perf/util/dso.c            |   2 +-
 tools/perf/util/dso.h            |   3 +-
 tools/perf/util/symbol-elf.c     |  97 ++++++++++++++++++++++++++++++++-
 tools/perf/util/symbol-minimal.c |   6 +++
 tools/perf/util/symbol.c         | 114 ++++++++++++++++++++++++++++++++++++---
 tools/perf/util/symbol.h         |  27 +++++++++-
 tools/perf/util/symbol_conf.h    |   1 +
 8 files changed, 237 insertions(+), 15 deletions(-)
tools/perf/ui/browsers/map.c +1 -1
index be7390156edd..b7ae2ad4126f 100644
@@ -111,7 +111,7 @@ int map__browse(struct map *map)
 {
 	struct map_browser mb = {
 		.b = {
-			.entries = dso__symbols(map__dso(map)),
+			.entries = dso__named_symbols(map__dso(map)),
 			.refresh = ui_browser__rb_tree_refresh,
 			.seek	 = ui_browser__rb_tree_seek,
 			.write	 = map_browser__write,
tools/perf/util/dso.c +1 -1
index e46cd614eb21..881603d78b4b 100644
@@ -2021,7 +2021,7 @@ size_t dso__fprintf(struct dso *dso, FILE *fp)
 	ret += fprintf(fp, "%sloaded, ", dso__loaded(dso) ? "" : "NOT ");
 	ret += dso__fprintf_buildid(dso, fp);
 	ret += fprintf(fp, ")\n");
-	for (nd = rb_first_cached(dso__symbols(dso)); nd; nd = rb_next(nd)) {
+	for (nd = rb_first_cached(dso__named_symbols(dso)); nd; nd = rb_next(nd)) {
 		struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
 		ret += symbol__fprintf(pos, fp);
 	}
tools/perf/util/dso.h +2 -1
index d5f7382d4e13..10eac0b31b7d 100644
@@ -369,7 +369,7 @@ int dso_id__cmp(const struct dso_id *a, const struct dso_id *b);
  * @n: the 'struct rb_node *' to use as a temporary storage
  */
 #define dso__for_each_symbol(dso, pos, n)	\
-	symbols__for_each_entry(dso__symbols(dso), pos, n)
+	symbols__for_each_entry(dso__named_symbols(dso), pos, n)
 
 static inline void *dso__a2l(const struct dso *dso)
 {
@@ -831,6 +831,7 @@ char *dso__filename_with_chroot(const struct dso *dso, const char *filename);
 bool dso__sorted_by_name(const struct dso *dso);
 void dso__set_sorted_by_name(struct dso *dso);
 void dso__sort_by_name(struct dso *dso);
+struct rb_root_cached *dso__named_symbols(struct dso *dso);
 
 int dso__swap_init(struct dso *dso, unsigned char eidata);
 
tools/perf/util/symbol-elf.c +95 -2

121 lines not on this page · raw message

tools/perf/util/symbol-minimal.c +6 -0
index 0a71d1463952..fa87c2d9de2a 100644
@@ -330,6 +330,12 @@ enum dso_type dso__type_fd(int fd)
 	return DSO__TYPE_32BIT;
 }
 
+void dso__load_symbol_names(struct dso *dso __maybe_unused,
+			    struct symbol **syms __maybe_unused,
+			    size_t nr __maybe_unused)
+{
+}
+
 int dso__load_sym(struct dso *dso, struct map *map __maybe_unused,
 		  struct symsrc *ss,
 		  struct symsrc *runtime_ss __maybe_unused,
tools/perf/util/symbol.c +106 -8

179 lines not on this page · raw message

tools/perf/util/symbol.h +25 -2
index a449c170d834..d690cb1d021c 100644
@@ -78,8 +78,15 @@ enum symbol_idle_kind {
 #define SYMBOL_FLAG_INLINED         (1 << 11)
 #define SYMBOL_FLAG_ANNOTATE2       (1 << 12)
 #define SYMBOL_FLAG_IFUNC_ALIAS     (1 << 13)
+#define SYMBOL_FLAG_LAZY_NAME       (1 << 14)
 /**
  * A symtab entry.
+ *
+ * The DSO lookups such as dso__find_symbol() load a lazy name before
+ * returning the symbol, and the address lookups return NULL if it cannot
+ * be read. Code that walks dso__symbols() directly must use
+ * dso__named_symbols() or not read the name of a symbol with
+ * SYMBOL_FLAG_LAZY_NAME.
  */
 struct symbol {
 	struct rb_node	rb_node;
@@ -91,13 +98,24 @@ struct symbol {
 	_Atomic uint16_t flags;
 	/** Architecture specific. Unused except on PPC where it holds st_other. */
 	u8		arch_sym;
-	/** The name of length namelen associated with the symbol. */
-	char		*name;
+	union {
+		/** The name of length namelen associated with the symbol. */
+		char	*name;
+		/** File offset of the name while SYMBOL_FLAG_LAZY_NAME is set. */
+		u64	name_off;
+	};
 };
 
 void symbol__delete(struct symbol *sym);
 void symbols__delete(struct rb_root_cached *symbols);
 
+/* Pairs with the release in symbol__set_loaded_name(). */
+static inline bool symbol__needs_lazy_name(const struct symbol *sym)
+{
+	return (atomic_load_explicit(&sym->flags, memory_order_acquire) &
+		SYMBOL_FLAG_LAZY_NAME) != 0;
+}
+
 static inline u8 symbol__type(const struct symbol *sym)
 {
 	return (atomic_load_explicit(&sym->flags, memory_order_relaxed) &
@@ -219,6 +237,9 @@ void symbol__elf_init(void);
 int symbol__annotation_init(void);
 
 struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *name);
+struct symbol *symbol__new_lazy(u64 start, u64 len, u8 binding, u8 type, u64 name_off);
+void symbol__set_loaded_name(struct symbol *sym, char *name);
+void symbol__set_unknown_name(struct symbol *sym);
 size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
 				      const struct addr_location *al,
 				      bool unknown_as_addr,
@@ -249,11 +270,13 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile);
 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 		  struct symsrc *runtime_ss, int kmodule);
 int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss);
+void dso__load_symbol_names(struct dso *dso, struct symbol **syms, size_t nr);
 
 char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name);
 
 void __symbols__insert(struct rb_root_cached *symbols, struct symbol *sym);
 void symbols__insert(struct rb_root_cached *symbols, struct symbol *sym);
+struct symbol *symbols__find(struct rb_root_cached *symbols, u64 ip);
 void symbols__fixup_duplicate(struct rb_root_cached *symbols);
 void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms);
 
tools/perf/util/symbol_conf.h +1 -0
index aaa7148c3ac1..f47482072625 100644
@@ -76,6 +76,7 @@ struct symbol_conf {
 			no_buildid_mmap2,
 			guest_code,
 			lazy_load_kernel_maps,
+			lazy_load_symbols,
 			keep_exited_threads,
 			annotate_data_member,
 			annotate_data_sample,
Signature · 1 line
Git-157)
#4 lore raw

PATCH v8 4/7 perf symbols: Check the file before reading lazy symbol names

In reply to Alireza Haghdoost

This patch makes perf check that a file is still the one it loaded before it reads lazy symbol names from it. A lazy name is read later from a file that perf opens again by path, at the offset that its string table had at load time. If the file was replaced in between, for example by a deploy, perf would read names from the wrong file and print wrong names without a warning. Eager loading rejects such a file, since symsrc__init() checks its build ID.

perf checks the file each time it opens it again. dso__set_lazy_file() records the file at load time. Nothing calls it yet: the next patch makes the ELF loader call it when it creates lazy symbols.

If the DSO has a build ID, symsrc__init() matched the file with it at load time, so accept a file with that build ID, such as a copy of the same build. The build ID alone is not enough, since the offsets are only valid if the string tables did not move: objcopy --add-gnu-debuglink keeps the build ID but moves .strtab, and strip --strip-debug removes sections. So perf also records the index, offset and size of the .symtab and .dynsym string tables, and compares them.

Reading the build ID each time is slow when most lookups load a name:
the parity test on a 524 MiB binary, which loads 260k names one at a time, takes 9.3 seconds instead of 3.9. So perf also records the device, inode, size, mtime and ctime of the file, and reads the build ID only if they changed. The ctime changes when another file is copied over this one in place, even if its size and mtime are kept, as with cp -p. Then perf keeps the identity of the accepted file for later reads. With this, the test takes 4.1 seconds. A DSO without a build ID must keep the same identity.

If the file is not the one perf loaded, perf warns and shows the remaining lazy symbols of that DSO as "[unknown]" rather than print wrong names, without opening the file again. If the file cannot be opened or checked, for example because perf ran out of file descriptors or fstat() or a read of its ELF headers failed, perf warns once and shows the symbols it was reading the names of as "[unknown]", but tries again for later names, since the failure can be temporary. A file whose build ID cannot be read counts as not checked, since perf cannot tell a failed read from a missing build ID note; perf reads no names from it either.

Like symsrc__init(), the check trusts the build ID: a file edited after linking without a new build ID, and with its string tables in place, gives the edited names.

The unit tests later in this series cover these cases.

No functional change, since no symbol has a lazy name yet.

---
 tools/perf/util/dso.h        |  33 +++++++++
 tools/perf/util/symbol-elf.c | 156 ++++++++++++++++++++++++++++++++++++++++++-
 tools/perf/util/symbol.h     |   3 +
 3 files changed, 189 insertions(+), 3 deletions(-)
tools/perf/util/dso.h +33 -0
index 10eac0b31b7d..216a9bc9366b 100644
@@ -282,6 +282,33 @@ struct dso_bpf_prog {
 	struct perf_env	*env;
 };
 
+/* A string table that lazy symbol names point into. */
+struct dso_lazy_strtab {
+	u64		shndx;
+	u64		off;
+	u64		size;
+};
+
+/* The file that lazy symbol names are read from, as it was at load time. */
+struct dso_lazy_file {
+	u64		dev;
+	u64		ino;
+	u64		size;
+	u64		mtime_sec;
+	u64		mtime_nsec;
+	/* Copying over the file in place, keeping its size and mtime, changes it. */
+	u64		ctime_sec;
+	u64		ctime_nsec;
+	/* The string tables of .symtab and .dynsym. */
+	struct dso_lazy_strtab strtab[2];
+	/* symsrc__init() matched the file with the build ID of the DSO. */
+	bool		check_build_id;
+	/* The file changed after the names were loaded. */
+	bool		rejected;
+	/* perf warned that the file could not be opened or checked again. */
+	bool		retry_warned;
+};
+
 struct auxtrace_cache;
 
 DECLARE_RC_STRUCT(dso) {
@@ -321,6 +348,7 @@ DECLARE_RC_STRUCT(dso) {
 	struct dso_bpf_prog bpf_prog;
 	/* dso data file */
 	struct dso_data	 data;
+	struct dso_lazy_file lazy_file;
 	struct dso_id	 id;
 	unsigned int	 a2l_fails;
 	int		 comp;
@@ -503,6 +531,11 @@ static inline struct dso_data *dso__data(struct dso *dso)
 	return &RC_CHK_ACCESS(dso)->data;
 }
 
+static inline struct dso_lazy_file *dso__lazy_file(struct dso *dso)
+{
+	return &RC_CHK_ACCESS(dso)->lazy_file;
+}
+
 static inline u64 dso__db_id(const struct dso *dso)
 {
 	return RC_CHK_ACCESS(dso)->db_id;
tools/perf/util/symbol-elf.c +153 -3

184 lines not on this page · raw message

tools/perf/util/symbol.h +3 -0
index d690cb1d021c..27def18f0f5c 100644
@@ -271,6 +271,9 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 		  struct symsrc *runtime_ss, int kmodule);
 int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss);
 void dso__load_symbol_names(struct dso *dso, struct symbol **syms, size_t nr);
+struct dso_lazy_strtab;
+int dso__set_lazy_file(struct dso *dso, int fd, int dynsym,
+		       const struct dso_lazy_strtab *strtab);
 
 char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name);
 
Signature · 1 line
Git-157)
maintainer
#5 lore raw

Re: [PATCH v8 4/7] perf symbols: Check the file before reading lazy symbol names

Quoted 12 lines · Alireza Haghdoost

This patch makes perf check that a file is still the one it loaded before it reads lazy symbol names from it. A lazy name is read later from a file that perf opens again by path, at the offset that its string table had at load time. If the file was replaced in between, for example by a deploy, perf would read names from the wrong file and print wrong names without a warning. Eager loading rejects such a file, since symsrc__init() checks its build ID.

perf checks the file each time it opens it again. dso__set_lazy_file() records the file at load time. Nothing calls it yet: the next patch makes the ELF loader call it when it creates lazy symbols.

Quoted 7 lines

If the DSO has a build ID, symsrc__init() matched the file with it at load time, so accept a file with that build ID, such as a copy of the same build. The build ID alone is not enough, since the offsets are only valid if the string tables did not move: objcopy --add-gnu-debuglink keeps the build ID but moves .strtab, and strip --strip-debug removes sections. So perf also records the index, offset and size of the .symtab and .dynsym string tables, and compares them.

I think it's extremely rare that the symbol file is being modified while perf is running.

Quoted 10 lines

Reading the build ID each time is slow when most lookups load a name:
the parity test on a 524 MiB binary, which loads 260k names one at a time, takes 9.3 seconds instead of 3.9. So perf also records the device, inode, size, mtime and ctime of the file, and reads the build ID only if they changed. The ctime changes when another file is copied over this one in place, even if its size and mtime are kept, as with cp -p. Then perf keeps the identity of the accepted file for later reads. With this, the test takes 4.1 seconds. A DSO without a build ID must keep the same identity.

Is ctime really needed? I think dev/inode will catch new file creation and mtime is for in-place mofifications.

Quoted 12 lines

If the file is not the one perf loaded, perf warns and shows the remaining lazy symbols of that DSO as "[unknown]" rather than print wrong names, without opening the file again. If the file cannot be opened or checked, for example because perf ran out of file descriptors or fstat() or a read of its ELF headers failed, perf warns once and shows the symbols it was reading the names of as "[unknown]", but tries again for later names, since the failure can be temporary. A file whose build ID cannot be read counts as not checked, since perf cannot tell a failed read from a missing build ID note; perf reads no names from it either.

Quoted 3 lines

Like symsrc__init(), the check trusts the build ID: a file edited after linking without a new build ID, and with its string tables in place, gives the edited names.

Right, but I don't think it's gonna be a problem in practice.

Thanks,
Namhyung

Quoted 7 lines

The unit tests later in this series cover these cases.

No functional change, since no symbol has a lazy name yet.

---

#6 lore raw

Re: [PATCH v8 4/7] perf symbols: Check the file before reading lazy symbol names

Hi Namhyung,

Quoted 2 lines · Namhyung Kim

I think it's extremely rare that the symbol file is being modified while perf is running.

Agreed, and I think this patch is too much code for such a rare case.

Quoted 2 lines

Is ctime really needed? I think dev/inode will catch new file creation and mtime is for in-place modifications.

ctime only matters when a file is overwritten in place with its mtime kept, as with cp -p. But I'd rather drop the whole check than tune it, so I suggest this for v9:

- Drop this patch and its tests.
- Document that --lazy-load-symbols gives the same names as eager loading as long as the files are not changed while perf runs.
- Keep showing "[unknown]" when the file cannot be opened or read.

I measured v8 with and without the check on seven workloads. The time and memory were the same within noise, since the check only adds one fstat() per lookup. So dropping it makes the series about 190 lines smaller (plus about 390 lines of tests) and saves nothing.

Thanks,
Alireza

#7 lore raw

PATCH v8 5/7 perf script: Add --lazy-load-symbols to load symbol names lazily

In reply to Alireza Haghdoost

This patch adds a --lazy-load-symbols option to perf script. With it, the ELF loader creates userspace .symtab and .dynsym symbols with lazy names, and perf reads a name only when a lookup returns that symbol. Eager loading stays the default.

perf script loads the whole ELF symbol table of every DSO that appears in a sample and keeps every symbol, with its demangled name, until exit. Most of those symbols are never sampled, and their names take most of the memory. On a large profile this is the main memory cost of perf script, and in a memory-limited cgroup it gets perf OOM-killed.

The loader still creates every symbol, so end fixup, duplicate selection, PLT synthesis and IFUNC marking do not change. It uses lazy names only if the string table is stored as is in the symbol table file, since names are read from it with pread().

A few names are still read at load time: aliases that duplicate selection can tell apart only by name, such as the .dynsym copies of .symtab symbols, and IFUNC symbols, whose names PLT synthesis uses.

The offsets are only valid in the file that perf loaded, so the loader records the file and its string tables with dso__set_lazy_file(), and perf checks the file, as the previous patch describes, before it reads names from it.

The kernel, modules, PPC64 .opd and .gnu_debugdata still load names eagerly.

On a 45,073-sample callchain profile of a large C++ service (about 1M symbols), lazy loading cuts max RSS from 327 MiB to 174 MiB, with identical output. It saves little run time, 3.56 seconds against 3.75, because one of the binaries exports most of its symbols, and duplicate selection reads the names of each .dynsym copy and of the .symtab symbol that it copies.

---
 tools/perf/Documentation/perf-script.txt |  11 ++++
 tools/perf/builtin-script.c              |   2 +
 tools/perf/util/symbol-elf.c             | 108 +++++++++++++++++++++++++++----
 3 files changed, 110 insertions(+), 11 deletions(-)
tools/perf/Documentation/perf-script.txt +11 -0
index f0228e784ced..4d04f5ecae8a 100644
@@ -343,6 +343,17 @@ include::itrace.txt[]
 
         Default: 127
 
+--lazy-load-symbols::
+	Read and demangle userspace ELF symbol names only when perf needs
+	them. By default, perf reads every symbol name from each binary
+	referenced by a sample. This option reduces memory use when samples
+	reference only a small fraction of a large binary's symbols. The
+	names are read while perf script runs. If a binary cannot be opened
+	then, or no longer matches the one perf loaded, perf warns and shows
+	the symbols whose names it cannot read as unknown. A binary matches
+	if it has the same build ID and string table layout or, without a
+	build ID, if it is the same unchanged file.
+
 --ns::
 	Use 9 decimal places when displaying time (i.e. show the nanoseconds)
 
tools/perf/builtin-script.c +2 -0
index b6691ebb1b4e..88aaf9cfd132 100644
@@ -4287,6 +4287,8 @@ int cmd_script(int argc, const char **argv)
 		     "Set the maximum stack depth when parsing the callchain, "
 		     "anything beyond the specified depth will be ignored. "
 		     "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
+	OPT_BOOLEAN(0, "lazy-load-symbols", &symbol_conf.lazy_load_symbols,
+		    "Read symbol names only when they are needed"),
 	OPT_BOOLEAN(0, "reltime", &reltime, "Show time stamps relative to start"),
 	OPT_BOOLEAN(0, "deltatime", &deltatime, "Show time stamps relative to previous event"),
 	OPT_BOOLEAN('I', "show-info", &show_full_info,
tools/perf/util/symbol-elf.c +97 -11

151 lines not on this page · raw message

Signature · 1 line
Git-157)
maintainer
#8 lore raw

Re: [PATCH v8 5/7] perf script: Add --lazy-load-symbols to load symbol names lazily

Quoted 35 lines · Alireza Haghdoost

This patch adds a --lazy-load-symbols option to perf script. With it, the ELF loader creates userspace .symtab and .dynsym symbols with lazy names, and perf reads a name only when a lookup returns that symbol. Eager loading stays the default.

perf script loads the whole ELF symbol table of every DSO that appears in a sample and keeps every symbol, with its demangled name, until exit. Most of those symbols are never sampled, and their names take most of the memory. On a large profile this is the main memory cost of perf script, and in a memory-limited cgroup it gets perf OOM-killed.

The loader still creates every symbol, so end fixup, duplicate selection, PLT synthesis and IFUNC marking do not change. It uses lazy names only if the string table is stored as is in the symbol table file, since names are read from it with pread().

A few names are still read at load time: aliases that duplicate selection can tell apart only by name, such as the .dynsym copies of .symtab symbols, and IFUNC symbols, whose names PLT synthesis uses.

The offsets are only valid in the file that perf loaded, so the loader records the file and its string tables with dso__set_lazy_file(), and perf checks the file, as the previous patch describes, before it reads names from it.

The kernel, modules, PPC64 .opd and .gnu_debugdata still load names eagerly.

On a 45,073-sample callchain profile of a large C++ service (about 1M symbols), lazy loading cuts max RSS from 327 MiB to 174 MiB, with identical output. It saves little run time, 3.56 seconds against 3.75, because one of the binaries exports most of its symbols, and duplicate selection reads the names of each .dynsym copy and of the .symtab symbol that it copies.

Quoted 2 lines

---

Only a few nitpicks.

Quoted 103 lines
 tools/perf/Documentation/perf-script.txt |  11 ++++
 tools/perf/builtin-script.c              |   2 +
 tools/perf/util/symbol-elf.c             | 108 +++++++++++++++++++++++++++----
 3 files changed, 110 insertions(+), 11 deletions(-)
tools/perf/Documentation/perf-script.txt +11 -0
index f0228e784ced..4d04f5ecae8a 100644
@@ -343,6 +343,17 @@ include::itrace.txt[]
 
         Default: 127
 
+--lazy-load-symbols::
+	Read and demangle userspace ELF symbol names only when perf needs
+	them. By default, perf reads every symbol name from each binary
+	referenced by a sample. This option reduces memory use when samples
+	reference only a small fraction of a large binary's symbols. The
+	names are read while perf script runs. If a binary cannot be opened
+	then, or no longer matches the one perf loaded, perf warns and shows
+	the symbols whose names it cannot read as unknown. A binary matches
+	if it has the same build ID and string table layout or, without a
+	build ID, if it is the same unchanged file.
+
 --ns::
 	Use 9 decimal places when displaying time (i.e. show the nanoseconds)
 
tools/perf/builtin-script.c +2 -0
index b6691ebb1b4e..88aaf9cfd132 100644
@@ -4287,6 +4287,8 @@ int cmd_script(int argc, const char **argv)
 		     "Set the maximum stack depth when parsing the callchain, "
 		     "anything beyond the specified depth will be ignored. "
 		     "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
+	OPT_BOOLEAN(0, "lazy-load-symbols", &symbol_conf.lazy_load_symbols,
+		    "Read symbol names only when they are needed"),
 	OPT_BOOLEAN(0, "reltime", &reltime, "Show time stamps relative to start"),
 	OPT_BOOLEAN(0, "deltatime", &deltatime, "Show time stamps relative to previous event"),
 	OPT_BOOLEAN('I', "show-info", &show_full_info,
tools/perf/util/symbol-elf.c +47 -1
index 468a0695809e..76f4aecb8632 100644
@@ -1871,6 +1871,52 @@ void dso__load_symbol_names(struct dso *dso, struct symbol **syms, size_t nr)
 	}
 }
 
+/*
+ * symbols__fixup_duplicate() compares the names of symbols at the same
+ * address only when their size, type and binding tie. Load those names.
+ */
+static int dso__load_alias_names(struct dso *dso, int fd)
+{
+	struct rb_node *nd = rb_first_cached(dso__symbols(dso));
+
+	while (nd) {
+		struct symbol *first = rb_entry(nd, struct symbol, rb_node);
+		struct rb_node *end = rb_next(nd), *a, *b;
+
+		while (end && rb_entry(end, struct symbol, rb_node)->start == first->start)
+			end = rb_next(end);
+
+		for (a = nd; a != end; a = rb_next(a)) {
+			for (b = rb_next(a); b != end; b = rb_next(b)) {
+				struct symbol *pair[2] = {
+					rb_entry(a, struct symbol, rb_node),
+					rb_entry(b, struct symbol, rb_node),
+				};
+
+				if (symbol__choice_needs_names(pair[0], pair[1]) &&
+				    read_symbol_names(dso, fd, pair, 2))
+					return -1;
+			}
+		}
+		nd = end;
+	}
+	return 0;
+}
+
+/* PLT synthesis names IRELATIVE slots after IFUNC symbols. Load those names. */
+static int dso__load_ifunc_names(struct dso *dso, int fd)
+{
+	struct symbol *pos;
+	struct rb_node *nd;
+
+	symbols__for_each_entry(dso__symbols(dso), pos, nd) {
+		if ((symbol__type(pos) == STT_GNU_IFUNC || symbol__ifunc_alias(pos)) &&
+		    read_symbol_names(dso, fd, &pos, 1))
+			return -1;
+	}
+	return 0;
+}
+
 static int
 dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 		       struct symsrc *runtime_ss, int kmodule, int dynsym)
@@ -1888,11 +1934,21 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 	GElf_Sym sym;
 	Elf_Scn *sec, *sec_strndx;
 	Elf *elf;
-	int nr = 0;
+	int nr = 0, nr_lazy = 0;

tools/perf/util/symbol-elf.c dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, · line 1947

Quoted 10 lines
tools/perf/util/symbol-elf.c +6 -0
 	bool remap_kernel = false, adjust_kernel_syms = false;
 	u64 max_text_sh_offset = 0;
 	struct elf_phdr_cache phdr_cache = {};
 	struct elf_sec_cache_entry sec_cache[ELF_SEC_CACHE_SIZE];
+	/*
+	 * Names are read later from the file of dso__symtab_type(). The
+	 * .gnu_debugdata symbol table is a temporary file.
+	 */
+	bool lazy_allowed = symbol_conf.lazy_load_symbols && !dso__kernel(dso) &&
+			  !kmodule && syms_ss->type == dso__symtab_type(dso) &&

I think kmodule has DSO_SPACE__KERNEL so it's enough to check only dso__kernel().

Quoted 61 lines
tools/perf/util/symbol-elf.c +33 -10
+			  syms_ss->type != DSO_BINARY_TYPE__GNU_DEBUGDATA &&
+			  !runtime_ss->opdsec;
+	bool lazy_names = false;
+	GElf_Shdr strshdr;
 
 	if (kmap && !kmaps)
 		return -1;
@@ -1928,6 +1984,17 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 	if (symstrs == NULL)
 		goto out_elf_end;
 
+	/*
+	 * Names are read with pread(), so the string table must be stored as
+	 * is, and later reads must find it in the same place.
+	 */
+	if (lazy_allowed && gelf_getshdr(sec, &strshdr) &&
+	    strshdr.sh_type == SHT_STRTAB && !(strshdr.sh_flags & SHF_COMPRESSED) &&
+	    !dso__set_lazy_file(dso, syms_ss->fd, dynsym,
+				&(struct dso_lazy_strtab){ shdr.sh_link, strshdr.sh_offset,
+							   strshdr.sh_size }))
+		lazy_names = true;
+
 	sec_strndx = elf_getscn(runtime_ss->elf, runtime_ss->ehdr.e_shstrndx);
 	if (sec_strndx == NULL)
 		goto out_elf_end;
@@ -2166,16 +2233,24 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 			}
 		}
 
-		if (!elf_name)
-			elf_name = elf_sym__name(&sym, symstrs);
-		demangled = dso__demangle_sym(dso, kmodule, elf_name);
-		if (demangled != NULL)
-			elf_name = demangled;
-
-		f = symbol__new(sym.st_value, sym.st_size,
-				GELF_ST_BIND(sym.st_info),
-				GELF_ST_TYPE(sym.st_info), elf_name);
-		free(demangled);
+		if (lazy_names && sym.st_name < strshdr.sh_size) {
+			f = symbol__new_lazy(sym.st_value, sym.st_size,
+					     GELF_ST_BIND(sym.st_info),
+					     GELF_ST_TYPE(sym.st_info),
+					     strshdr.sh_offset + sym.st_name);
+			nr_lazy++;
+		} else {
+			if (!elf_name)
+				elf_name = elf_sym__name(&sym, symstrs);
+			demangled = dso__demangle_sym(dso, kmodule, elf_name);
+			if (demangled != NULL)
+				elf_name = demangled;
+
+			f = symbol__new(sym.st_value, sym.st_size,
+					GELF_ST_BIND(sym.st_info),
+					GELF_ST_TYPE(sym.st_info), elf_name);
+			free(demangled);
+		}
 		if (!f)
 			goto out_elf_end;
 

tools/perf/util/symbol-elf.c dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, · line 2267

Quoted 7 lines
tools/perf/util/symbol-elf.c +4 -0
@@ -2186,6 +2261,10 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 	}
 	dso__put(curr_dso);
 	elf_phdr_cache__exit(&phdr_cache);
+
+	if (lazy_names)
+		pr_debug("%s: %d %s symbols with lazy names\n", dso__long_name(dso),
+			 nr_lazy, dynsym ? ".dynsym" : ".symtab");

I'm afraid it'd add many debug messages for -v which is often used for quick debugging. Maybe pr_debug2() would be better.

Also please put parenthesis for multi-line expressions even if it's in a statement.

Thanks,
Namhyung

Quoted 24 lines
tools/perf/util/symbol-elf.c +7 -0
 	return nr;
 out_elf_end:
 	dso__put(curr_dso);
@@ -2256,9 +2335,16 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 	if (nr > 0) {
 		struct kmap *kmap = dso__kernel(dso) ? map__kmap(map) : NULL;
 		struct maps *kmaps = kmap ? map__kmaps(map) : NULL;
+		/* Lazy names are only in syms_ss, never in the kernel or modules. */
+		bool lazy = symbol_conf.lazy_load_symbols && !dso__kernel(dso) && !kmodule;
 
 		symbols__fixup_end(dso__symbols(dso), false);
+		if (lazy && !symbol_conf.allow_aliases &&
+		    dso__load_alias_names(dso, syms_ss->fd))
+			return -1;
 		symbols__fixup_duplicate(dso__symbols(dso));
+		if (lazy && dso__load_ifunc_names(dso, syms_ss->fd))
+			return -1;
 		if (kmap) {
 			/*
 			 * We need to fixup this here too because we create new
Signature · 2 lines
-- 
Git-157)
#9 lore raw

Re: [PATCH v8 5/7] perf script: Add --lazy-load-symbols to load symbol names lazily

Hi Namhyung,

Quoted 5 lines · Namhyung Kim
Quoted 2 lines

+ bool lazy_allowed = symbol_conf.lazy_load_symbols && !dso__kernel(dso) &&
+ !kmodule && syms_ss->type == dso__symtab_type(dso) &&

I think kmodule has DSO_SPACE__KERNEL so it's enough to check only dso__kernel().

Right, module DSOs are always created as kernel DSOs. I'll drop the kmodule checks here and in dso__load_sym().

Quoted 9 lines
Quoted 3 lines

+ if (lazy_names)
+ pr_debug("%s: %d %s symbols with lazy names\n", dso__long_name(dso),
+ nr_lazy, dynsym ? ".dynsym" : ".symtab");

I'm afraid it'd add many debug messages for -v which is often used for quick debugging. Maybe pr_debug2() would be better.

Also please put parenthesis for multi-line expressions even if it's in a statement.

Will do both in v9.

Thanks,
Alireza

#10 lore raw

PATCH v8 6/7 perf test: Add lazy symbol loading unit tests

In reply to Alireza Haghdoost

Add a "Lazy symbol loading" unit test suite. It covers duplicate selection without names, lazy names that take one or more reads or cannot be read at all, lookups from several threads while another one walks the symbols, and eager and lazy parity on a real DSO (perf itself, or the one given with --dso).

It also covers the check of the file that names are read from: a file without a build ID that is replaced after the first name was read, or overwritten in place keeping its size and mtime, gives no more names. A file that cannot be opened for one name gives the next one. A copy of perf keeps every name, unless its string tables moved or are missing, or it is of another build; then perf rejects it for good. A copy whose build ID cannot be read gives no name, but a later copy that can be checked gives the next one.

---
 tools/perf/tests/Build          |   1 +
 tools/perf/tests/builtin-test.c |   1 +
 tools/perf/tests/symbol-lazy.c  | 963 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |   1 +
 4 files changed, 966 insertions(+)
tools/perf/tests/Build +1 -0
index 5eebb2ec5dde..1377dd465586 100644
@@ -69,6 +69,7 @@ perf-test-y += sigtrap.o
 perf-test-y += event_groups.o
 perf-test-y += hybrid-merge.o
 perf-test-y += symbols.o
+perf-test-y += symbol-lazy.o
 perf-test-y += util.o
 perf-test-y += hwmon_pmu.o
 perf-test-y += tool_pmu.o
tools/perf/tests/builtin-test.c +1 -0
index 01c78ef20b97..c447432dc41f 100644
@@ -189,6 +189,7 @@ static struct test_suite *generic_tests[] = {
 	&suite__event_groups,
 	&suite__hybrid_merge,
 	&suite__symbols,
+	&suite__symbol_lazy,
 	&suite__util,
 	&suite__subcmd_help,
 	&suite__kallsyms_split,
tools/perf/tests/symbol-lazy.c new file +963 -0

963 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index af822885890d..d9e0b5ad92a2 100644
@@ -199,6 +199,7 @@ DECLARE_SUITE(sigtrap);
 DECLARE_SUITE(event_groups);
 DECLARE_SUITE(hybrid_merge);
 DECLARE_SUITE(symbols);
+DECLARE_SUITE(symbol_lazy);
 DECLARE_SUITE(util);
 DECLARE_SUITE(uncore_event_sorting);
 DECLARE_SUITE(subcmd_help);
Signature · 1 line
Git-157)
#11 lore raw

PATCH v8 7/7 perf test: Add lazy symbol loading shell tests

In reply to Alireza Haghdoost

lazy_load_symbols_parity.sh runs the lazy and eager parity unit test on seven small binaries built for the loader's corner cases: split debuginfo whose function section is NOBITS in the debug file, a shared library with .dynsym-only symbols and aliases, a stripped library with .gnu_debugdata, and on x86_64 an IFUNC behind an IRELATIVE PLT slot, the same with the IFUNC and its aliases exported, an exported function followed in .symtab by a zero-size label at its address, and exported functions with nested entry points.

script_lazy_load_symbols.sh records a small callchain profile and checks that perf script prints the same output with and without --lazy-load-symbols. As root, it also checks that names are read from the build-id cache when the profiled process is in another mount namespace.

Both tests skip a case, rather than fail it, when the toolchain produced a file whose names perf loads eagerly anyway (PPC64 ELFv1 .opd, .gnu_debugdata or a compressed .strtab).

---
 tools/perf/tests/shell/lazy_load_symbols_parity.sh | 447 +++++++++++++++++++++
 tools/perf/tests/shell/lib/lazy_names.sh           |  20 +
 tools/perf/tests/shell/script_lazy_load_symbols.sh | 190 +++++++++
 3 files changed, 657 insertions(+)
tools/perf/tests/shell/lazy_load_symbols_parity.sh new file +447 -0
new file mode 100755
index 000000000000..178988a6202f
@@ -0,0 +1,447 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# lazy symbol loading parity with eager loading
+
+# Build small ELF files whose symbols are hard to get right without their
+# names, and check that lazy and eager loading agree on their address lookups,
+# ranges and names:
+#  - split debuginfo, where a function's section is NOBITS (with a different
+#    sh_offset) in the debug file and has no PT_LOAD in the runtime ELF;
+#  - a shared library with symbols that are only in .dynsym, one of them a
+#    longer-named alias of a .symtab symbol;
+#  - 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, an IRELATIVE PLT slot whose IFUNC loses duplicate selection
+#    to an alias that loses to another one in turn;
+#  - on x86_64, an exported function followed in .symtab by a zero-size
+#    label at its address, which keeps zero size only because the .dynsym
+#    copy of the function follows it;
+#  - on x86_64, a shared library of exported functions with nested entry
+#    points, where a lookup past the end of the inner one must still find
+#    the outer one;
+#  - on x86_64, an IRELATIVE PLT slot whose IFUNC and its aliases are
+#    exported, so that the .dynsym copy of the IFUNC passes on its mark.
+
+set -e
+
+shelldir=$(dirname "$0")
+# shellcheck source=lib/lazy_names.sh
+. "${shelldir}"/lib/lazy_names.sh
+
+err=0
+tmpdir=$(mktemp -d /tmp/__perf_test.lazy_parity.XXXXX)
+
+cleanup() {
+	rm -rf "${tmpdir}"
+	trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+	echo "Unexpected signal in ${FUNCNAME[1]}"
+	cleanup
+	exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
+skip() {
+	echo "Lazy-load parity [Skipped: $1]"
+	cleanup
+	exit 2
+}
+
+if ! perf check feature -q libelf; then
+	skip "no libelf support"
+fi
+
+for tool in cc objcopy strip readelf nm dd; do
+	if ! command -v "${tool}" > /dev/null; then
+		skip "${tool} not found"
+	fi
+done
+
+# check_parity NAME FILE [eager]
+# Lazy loading must leave names of FILE unread, or none if "eager" is given.
+check_parity() {
+	local out="${tmpdir}/parity.out"
+	local lazy="[0-9][0-9]* symbols with lazy names"
+
+	if [ "$3" = eager ]; then
+		lazy="no lazy names"
+	fi
+	perf test --dso "$2" -vv "Lazy and eager symbol parity" > "${out}" 2>&1 || true
+	if grep -q ': Ok$' "${out}" && grep -q "^$2: ${lazy}$" "${out}"; then
+		echo "Lazy-load parity $1 [Success]"
+		return
+	fi
+	if [ "$3" != eager ] && grep -q ': Ok$' "${out}" &&
+	   grep -q "^$2: no lazy names$" "${out}" && lazy_names_disabled "$2" "$2.debug"; then
+		echo "Lazy-load parity $1 [Skipped: names load eagerly on this toolchain]"
+		return
+	fi
+	grep -E 'symbols$|names$|mismatch|lookup|no symbols' "${out}" || true
+	echo "Lazy-load parity $1 [Failed]"
+	err=1
+}
+
+test_split_debug() {
+	local prog="${tmpdir}/split"
+
+	cat > "${prog}.c" << EOF
+__attribute__((section("splittext"), noinline, used))
+int split_func(int x)
+{
+	return x * 3 + 1;
+}
+
+int main(int argc, char **argv)
+{
+	(void)argv;
+	return split_func(argc);
+}
+EOF
+	if ! cc -O1 -g -o "${prog}" "${prog}.c" \
+		-Wl,--section-start=splittext=0x800000 2> /dev/null; then
+		echo "Lazy-load parity split debuginfo [Skipped: cannot build]"
+		return
+	fi
+	objcopy --only-keep-debug "${prog}" "${prog}.debug"
+	strip -s "${prog}"
+	objcopy --add-gnu-debuglink="${prog}.debug" "${prog}"
+
+	# The debug file must keep splittext as NOBITS at a stale offset.
+	local debug_sec run_sec debug_off run_off
+	debug_sec=$(readelf -SW "${prog}.debug" 2> /dev/null | grep ' splittext ' || true)
+	run_sec=$(readelf -SW "${prog}" | grep ' splittext ' || true)
+	if ! echo "${debug_sec}" | grep -q NOBITS; then
+		echo "Lazy-load parity split debuginfo [Skipped: splittext is not NOBITS]"
+		return
+	fi
+	debug_off=$(echo "${debug_sec}" | sed 's/.*splittext *//' | awk '{print $3}')
+	run_off=$(echo "${run_sec}" | sed 's/.*splittext *//' | awk '{print $3}')
+	if [ -z "${run_off}" ] || [ "${debug_off}" = "${run_off}" ]; then
+		echo "Lazy-load parity split debuginfo [Skipped: offsets do not differ]"
+		return
+	fi
+
+	# Drop the PT_LOAD covering splittext so program header lookup fails.
+	local phoff phentsize idx
+	phoff=$(readelf -hW "${prog}" | awk '/Start of program headers/ {print $5}')
+	phentsize=$(readelf -hW "${prog}" | awk '/Size of program headers/ {print $5}')
+	idx=$(readelf -lW "${prog}" 2> /dev/null | awk '
+		/^Program Headers:/ { in_ph = 1; next }
+		in_ph && /^  Type/ { next }
+		in_ph && /^ *$/ { exit }
+		in_ph && /^  [A-Z]/ {
+			if ($1 == "LOAD" && $3 ~ /^0x0*800000$/) { print n; exit }
+			n++
+		}')
+	if [ -z "${phoff}" ] || [ -z "${phentsize}" ] || [ -z "${idx}" ]; then
+		echo "Lazy-load parity split debuginfo [Skipped: no PT_LOAD for splittext]"
+		return
+	fi
+	dd if=/dev/zero of="${prog}" bs=1 seek=$((phoff + idx * phentsize)) \
+		count=4 conv=notrunc 2> /dev/null
+	if readelf -lW "${prog}" 2> /dev/null | grep -q 'LOAD .*0x0*800000 '; then
+		echo "Lazy-load parity split debuginfo [Failed to drop PT_LOAD]"
+		err=1
+		return
+	fi
+	check_parity "split debuginfo" "${prog}"
+}
+
+test_dynsym_only() {
+	local lib="${tmpdir}/libdyn.so"
+
+	cat > "${tmpdir}/libdyn.c" << EOF
+int dyn_only(int x)
+{
+	return x + 1;
+}
+
+int dyn_and_symtab(int x)
+{
+	return x * 2;
+}
+
+/* Same range as dyn_and_symtab; duplicate selection prefers the longer name. */
+int dyn_and_symtab_alias(int x) __attribute__((alias("dyn_and_symtab")));
+EOF
+	if ! cc -O1 -shared -fPIC -o "${lib}" "${tmpdir}/libdyn.c" 2> /dev/null; then
+		echo "Lazy-load parity .dynsym-only symbol [Skipped: cannot build]"
+		return
+	fi
+	# --strip-symbol leaves .dynsym untouched.
+	objcopy --strip-symbol=dyn_only --strip-symbol=dyn_and_symtab_alias \
+		"${lib}"
+	for sym in dyn_only dyn_and_symtab_alias; do
+		if readelf -sW "${lib}" | \
+			awk '/Symbol table .\.symtab/ { s = 1 } s' | \
+			grep -qw "${sym}" || \
+		   ! readelf --dyn-syms -W "${lib}" | grep -qw "${sym}"; then
+			echo "Lazy-load parity .dynsym-only symbol [Skipped: cannot strip]"
+			return
+		fi
+	done
+	check_parity ".dynsym-only symbol" "${lib}"
+}
+
+test_gnu_debugdata() {
+	local lib="${tmpdir}/libgdd.so"
+	local dir="${tmpdir}/gdd"
+
+	if ! perf check feature -q lzma || ! command -v xz > /dev/null; then
+		echo "Lazy-load parity .gnu_debugdata [Skipped: no lzma support or xz]"
+		return
+	fi
+	mkdir "${dir}"
+	cat > "${dir}/libgdd.c" << EOF
+int exported(int x)
+{
+	return x * 3 + 1;
+}
+
+/* Same range as exported; duplicate selection prefers the global symbol. */
+static int local_alias(int x) __attribute__((alias("exported"), used));
+
+__attribute__((noinline)) static int local_helper(int x)
+{
+	return x + 7;
+}
+
+int call_local(int x)
+{
+	return local_helper(x) * 2;
+}
+EOF
+	if ! cc -O1 -shared -fPIC -o "${lib}" "${dir}/libgdd.c" 2> /dev/null; then
+		echo "Lazy-load parity .gnu_debugdata [Skipped: cannot build]"
+		return
+	fi
+	# Build MiniDebugInfo the way distributions do: the function symbols
+	# that are not in .dynsym, xz-compressed into .gnu_debugdata.
+	nm -D --format=posix --defined-only "${lib}" | awk '{ print $1 }' | \
+		sort > "${dir}/dynsyms"
+	nm --format=posix --defined-only "${lib}" | \
+		awk '$2 == "T" || $2 == "t" { print $1 }' | sort > "${dir}/funcsyms"
+	comm -13 "${dir}/dynsyms" "${dir}/funcsyms" > "${dir}/keep"
+	if ! grep -qx local_alias "${dir}/keep" ||
+	   ! objcopy --only-keep-debug "${lib}" "${dir}/debug" ||
+	   ! objcopy -S --remove-section .comment \
+		--keep-symbols="${dir}/keep" "${dir}/debug" "${dir}/mini" ||
+	   ! xz "${dir}/mini" || ! strip --strip-all "${lib}" ||
+	   ! objcopy --add-section .gnu_debugdata="${dir}/mini.xz" "${lib}" ||
+	   readelf -SW "${lib}" | grep -qw '\.symtab'; then
+		echo "Lazy-load parity .gnu_debugdata [Skipped: cannot build MiniDebugInfo]"
+		return
+	fi
+	check_parity ".gnu_debugdata" "${lib}" eager
+}
+
+test_ifunc_alias() {
+	local prog="${tmpdir}/ifunc"
+	local order
+
+	if [ "$(uname -m)" != x86_64 ]; then
+		echo "Lazy-load parity IFUNC alias [Skipped: IRELATIVE naming is x86_64 only]"
+		return
+	fi
+	# Duplicate selection prefers fewer leading underscores, so at the
+	# resolver's address __lazy_ifunc loses to _lazy_ifunc_x, which loses
+	# to lazy_ifunc_y. Whether the PLT slot is named after lazy_ifunc_y
+	# depends on how that passes on the IFUNC mark.
+	cat > "${prog}.c" << EOF
+static int impl(void)
+{
+	return 42;
+}
+
+__attribute__((used, noinline)) static void *___lazy_ifunc_resolver(void)
+{
+	return (void *)impl;
+}
+
+asm(".type __lazy_ifunc, @gnu_indirect_function\n"
+    ".set __lazy_ifunc, ___lazy_ifunc_resolver\n"
+    ".size __lazy_ifunc, 1\n"
+    ".type _lazy_ifunc_x, @function\n"
+    ".set _lazy_ifunc_x, ___lazy_ifunc_resolver\n"
+    ".size _lazy_ifunc_x, 1\n"
+    ".type lazy_ifunc_y, @function\n"
+    ".set lazy_ifunc_y, ___lazy_ifunc_resolver\n"
+    ".size lazy_ifunc_y, 1\n");
+
+int __lazy_ifunc(void);
+
+int main(void)
+{
+	return __lazy_ifunc();
+}
+EOF
+	if ! cc -O1 -fno-pie -no-pie -o "${prog}" "${prog}.c" 2> /dev/null ||
+	   ! readelf -rW "${prog}" | grep -q R_X86_64_IRELATIVE; then
+		echo "Lazy-load parity IFUNC alias [Skipped: cannot build]"
+		return
+	fi
+	# The outcome depends on the order of the aliases in .symtab.
+	order=$(readelf -sW "${prog}" | \
+		awk '$8 ~ /^_*lazy_ifunc(_x|_y)?$/ { printf "%s ", $8 }')
+	if [ "${order}" != "__lazy_ifunc _lazy_ifunc_x lazy_ifunc_y " ]; then
+		echo "Lazy-load parity IFUNC alias [Skipped: unexpected symbol order]"
+		return
+	fi
+	check_parity "IFUNC alias" "${prog}"
+}
+
+test_dynsym_copy_zero_size() {
+	local prog="${tmpdir}/zero"
+	local order
+
+	if [ "$(uname -m)" != x86_64 ]; then
+		echo "Lazy-load parity zero-size label [Skipped: x86_64 only]"
+		return
+	fi
+	# If end fixup gave the label a size, its longer name would win
+	# duplicate selection over the function.
+	cat > "${prog}.S" << EOF
+	.text
+	.globl	lazy_sized
+	.type	lazy_sized, @function
+lazy_sized:
+	.globl	lazy_sized_label
+	.type	lazy_sized_label, @function
+lazy_sized_label:
+	nop
+	ret
+	.size	lazy_sized, .-lazy_sized
+	.p2align 4
+	.globl	main
+	.type	main, @function
+main:
+	call	lazy_sized
+	xor	%eax, %eax
+	ret
+	.size	main, .-main
+	.section .note.GNU-stack,"",@progbits
+EOF
+	if ! cc -o "${prog}" "${prog}.S" \
+		-Wl,--export-dynamic-symbol=lazy_sized 2> /dev/null ||
+	   ! readelf --dyn-syms -W "${prog}" | grep -qw lazy_sized ||
+	   readelf --dyn-syms -W "${prog}" | grep -qw lazy_sized_label; then
+		echo "Lazy-load parity zero-size label [Skipped: cannot build]"
+		return
+	fi
+	# The label must follow the function in .symtab.
+	order=$(readelf -sW "${prog}" | \
+		awk '/\.symtab/ { s = 1 } s && $8 ~ /^lazy_sized(_label)?$/ { printf "%s ", $8 }')
+	if [ "${order}" != "lazy_sized lazy_sized_label " ]; then
+		echo "Lazy-load parity zero-size label [Skipped: unexpected symbol order]"
+		return
+	fi
+	check_parity "zero-size label" "${prog}"
+}
+
+test_nested_entry() {
+	local lib="${tmpdir}/libnested.so"
+	local i
+
+	if [ "$(uname -m)" != x86_64 ]; then
+		echo "Lazy-load parity nested entry [Skipped: x86_64 only]"
+		return
+	fi
+	# The lookup at the last byte of each outer function, past the end of
+	# its inner entry point, depends on the shape of the rb-tree, which
+	# the .dynsym copies take part in.
+	{
+		echo "	.text"
+		for i in 0 1 2; do
+			echo "	.globl	lazy_pad_${i}"
+			echo "	.type	lazy_pad_${i}, @function"
+			echo "lazy_pad_${i}:"
+			echo "	ret"
+			echo "	.size	lazy_pad_${i}, .-lazy_pad_${i}"
+		done
+		for i in 0 1 2 3 4 5 6; do
+			echo "	.globl	lazy_outer_${i}, lazy_inner_${i}"
+			echo "	.type	lazy_outer_${i}, @function"
+			echo "	.type	lazy_inner_${i}, @function"
+			echo "lazy_outer_${i}:"
+			echo "	nop"
+			echo "lazy_inner_${i}:"
+			echo "	nop"
+			echo "	.size	lazy_inner_${i}, .-lazy_inner_${i}"
+			echo "	ret"
+			echo "	.size	lazy_outer_${i}, .-lazy_outer_${i}"
+		done
+		echo '	.section .note.GNU-stack,"",@progbits'
+	} > "${tmpdir}/nested.S"
+	if ! cc -shared -nostdlib -o "${lib}" "${tmpdir}/nested.S" 2> /dev/null ||
+	   ! readelf --dyn-syms -W "${lib}" | grep -qw lazy_outer_0; then
+		echo "Lazy-load parity nested entry [Skipped: cannot build]"
+		return
+	fi
+	check_parity "nested entry" "${lib}"
+}
+
+test_exported_ifunc_alias() {
+	local lib="${tmpdir}/libifunc.so"
+
+	if [ "$(uname -m)" != x86_64 ]; then
+		echo "Lazy-load parity exported IFUNC alias [Skipped: x86_64 only]"
+		return
+	fi
+	# At the resolver's address, lazy_exp_ifunc_y wins duplicate selection
+	# over __lazy_exp_ifunc and _lazy_exp_ifunc_x, and an alias that lost
+	# after it took the IFUNC mark does not pass the mark on. The PLT slot
+	# of the local IFUNC __lazy_exp_call is named after lazy_exp_ifunc_y
+	# only if the .dynsym copy of __lazy_exp_ifunc marks it.
+	cat > "${tmpdir}/libifunc.c" << EOF
+static int impl(void)
+{
+	return 42;
+}
+
+__attribute__((used, noinline)) static void *lazy_exp_resolver(void)
+{
+	return (void *)impl;
+}
+
+asm(".globl __lazy_exp_ifunc, _lazy_exp_ifunc_x, lazy_exp_ifunc_y\n"
+    ".type __lazy_exp_ifunc, @gnu_indirect_function\n"
+    ".set __lazy_exp_ifunc, lazy_exp_resolver\n"
+    ".size __lazy_exp_ifunc, 1\n"
+    ".type _lazy_exp_ifunc_x, @function\n"
+    ".set _lazy_exp_ifunc_x, lazy_exp_resolver\n"
+    ".size _lazy_exp_ifunc_x, 1\n"
+    ".type lazy_exp_ifunc_y, @function\n"
+    ".set lazy_exp_ifunc_y, lazy_exp_resolver\n"
+    ".size lazy_exp_ifunc_y, 1\n");
+asm(".local __lazy_exp_call\n"
+    ".type __lazy_exp_call, @gnu_indirect_function\n"
+    ".set __lazy_exp_call, lazy_exp_resolver\n");
+
+int __lazy_exp_call(void);
+
+int lazy_exp_main(void)
+{
+	return __lazy_exp_call();
+}
+EOF
+	if ! cc -O1 -shared -fPIC -o "${lib}" "${tmpdir}/libifunc.c" 2> /dev/null ||
+	   ! readelf -rW "${lib}" | grep -q R_X86_64_IRELATIVE ||
+	   ! readelf --dyn-syms -W "${lib}" | grep -q 'IFUNC .* __lazy_exp_ifunc$'; then
+		echo "Lazy-load parity exported IFUNC alias [Skipped: cannot build]"
+		return
+	fi
+	check_parity "exported IFUNC alias" "${lib}"
+}
+
+test_split_debug
+test_dynsym_only
+test_gnu_debugdata
+test_ifunc_alias
+test_dynsym_copy_zero_size
+test_nested_entry
+test_exported_ifunc_alias
+
+cleanup
+exit ${err}
tools/perf/tests/shell/lib/lazy_names.sh new file +20 -0
new file mode 100644
index 000000000000..0358a039b4d2
@@ -0,0 +1,20 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# lazy_names_disabled FILE...
+# Return whether one of FILE has a PPC64 ELFv1 .opd, a .gnu_debugdata symbol
+# table or a compressed .strtab, for which perf loads symbol names eagerly.
+lazy_names_disabled() {
+	local f
+
+	command -v readelf > /dev/null || return 1
+	for f in "$@"; do
+		[ -e "${f}" ] || continue
+		if readelf -SW "${f}" 2> /dev/null |
+		   grep -Eq ' \.(opd|gnu_debugdata) | \.strtab +STRTAB( +[0-9a-f]+){4} +[A-Z]*C'
+		then
+			return 0
+		fi
+	done
+	return 1
+}
tools/perf/tests/shell/script_lazy_load_symbols.sh new file +190 -0

190 lines not on this page · raw message

Signature · 1 line
Git-157)
maintainer
#13 lore raw
In reply to Alireza Haghdoost
Quoted 44 lines · On Sat, Nov 21, 2026 at 08:41:00AM -0800, Alireza Haghdoost via B4 Relay wrote:

perf script loads the entire ELF symbol table of every DSO that appears in a sample, and keeps each symbol, with its demangled name, until process exit. Most of those symbols are never sampled. On a large profile this turns symbol loading into the main memory cost of perf script, and in a memory-constrained cgroup into an OOM kill.

With this series, perf script --lazy-load-symbols reads a symbol name only when a sample needs it. On a perf script run over a 45,073-sample callchain profile of a large C++ service (about 1M symbols), the output is identical in all three cases (medians of eleven runs):

                                      time    max RSS
  perf-tools-next                     3.70 s  319 MiB
  v8                                  3.75 s  327 MiB
  v8 --lazy-load-symbols              3.56 s  174 MiB

Eager loading remains the default, and costs 8 more bytes per symbol for the name pointer. Lazy loading covers userspace ELF .symtab and .dynsym. The kernel, modules, PPC64 .opd and .gnu_debugdata still load names eagerly.

The patches:

[1/7] Split the size, type and binding checks out of
choose_best_symbol(), so that the loader can tell which aliases need their names. No functional change. Unchanged from v7, reviewed by Ian.

[2/7] Make the symbol name a pointer instead of a flexible array, so
that a name can be set after the symbol is in the rb-tree. Unchanged from v7, reviewed by Ian.

[3/7] Add lazy symbol names to the symbol code: the DSO lookups read
the name of the symbol they return. Nothing creates such symbols yet.

[4/7] Check that the symbol table file is still the one perf loaded
before reading names from it. Nothing records a file yet.

[5/7] Add --lazy-load-symbols, which makes the ELF loader create
symbols with lazy names and record the file for the check.

[6/7] Unit tests for lazy names and for the file check.

Quoted 8 lines

[7/7] Shell tests, including parity with eager loading.

perf-tools-next now has the first three patches of Ian's series [1]. Its later patches replace the symbol rb-tree with an array, which would shrink each symbol further. They conflict with this series, since the name loading in 3/7 and the alias name loading in 5/7 walk that rb-tree. This series does not depend on them, and I'll rebase on them if they land first.

I'm about to merge Ian's series first. Please rebase accordingly after it's landed. I hope it'll make your change a bit easier.

Also please add the option to the perf report and perf top too.

Thanks,
Namhyung

Quoted 89 lines

[1] https://lore.kernel.org/all/[email protected]/

Changes in v8:

- Rebase onto current perf-tools-next, which has Ian's annotation and ELF loader changes.
- Split v7 3/4 for review (Namhyung): 3/7 adds lazy names to the symbol code, 4/7 adds the check of the symbol table file, and 5/7 adds the option and makes the ELF loader create lazy names. The tests are in 6/7 (unit) and 7/7 (shell).
- 4/7: Also accept a file whose device, inode, size, mtime or ctime changed if it has the build ID of the DSO and its .strtab and .dynstr did not move, such as a copy of the same build (Namhyung). The identity is still checked first, since reading the build ID at each reopen more than doubles the time of the worst case.
- 4/7: Compare the ctime too, so a file copied over in place with its size and mtime kept (cp -p) is not taken for the same file. Treat a string table section that no longer exists or is compressed as another file.
- 4/7: Warn once when the file cannot be opened or checked, rather than only in debug output, and try again for later names, since the failure can be temporary.
- 5/7: Do not skip the .dynsym copies of lazy .symtab symbols. Skipping them changed the shape of the rb-tree, which broke lookups past a nested entry point and the PLT name of an exported IFUNC. This replaces the v7 fix for a zero-size symbol before a copy (Sashiko). Duplicate selection now reads the names of each copy, so on the profile above, where one binary exports most of its symbols, lazy loading keeps its memory saving but loses most of the run time it saved in v7. Most of that time goes to reading each name with its own pread(). As discussed with Namhyung, a later series will let the DSO data cache read the symbol table file, and names will be read through it. A prototype with a small read cache gets back about two thirds of the v7 speedup for about 1.5 MiB more RSS.
- 6/7: Add tests for a file overwritten in place, for a copy with the same build, with moved or missing string tables, and of another build, for a failed open, and for a copy whose build ID cannot be read.
- 7/7: Add parity cases for a zero-size symbol before a copy, nested entry points, and an exported IFUNC with aliases.

Previous versions:

v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

---
Alireza Haghdoost (7):
perf symbols: Split out name-independent duplicate symbol selection perf symbols: Point to the symbol name instead of embedding it perf symbols: Add lazy symbol names
perf symbols: Check the file before reading lazy symbol names perf script: Add --lazy-load-symbols to load symbol names lazily perf test: Add lazy symbol loading unit tests
perf test: Add lazy symbol loading shell tests

 tools/perf/Documentation/perf-script.txt           |  11 +
 tools/perf/builtin-script.c                        |   2 +
 tools/perf/tests/Build                             |   1 +
 tools/perf/tests/builtin-test.c                    |   1 +
 tools/perf/tests/shell/lazy_load_symbols_parity.sh | 447 ++++++++++
 tools/perf/tests/shell/lib/lazy_names.sh           |  20 +
 tools/perf/tests/shell/script_lazy_load_symbols.sh | 190 ++++
 tools/perf/tests/symbol-lazy.c                     | 963 +++++++++++++++++++++
 tools/perf/tests/tests.h                           |   1 +
 tools/perf/ui/browsers/map.c                       |   2 +-
 tools/perf/ui/stdio/hist.c                         |   1 +
 tools/perf/util/dso.c                              |   2 +-
 tools/perf/util/dso.h                              |  36 +-
 tools/perf/util/symbol-elf.c                       | 355 +++++++-
 tools/perf/util/symbol-minimal.c                   |   6 +
 tools/perf/util/symbol.c                           | 141 ++-
 tools/perf/util/symbol.h                           |  31 +-
 tools/perf/util/symbol_conf.h                      |   1 +
 18 files changed, 2183 insertions(+), 28 deletions(-)

---
base-commit: bb27ddbaee56536fb8df0a24f07b526766dfe131
change-id: 20260915-perf-symbol-memory-send-e7cfca1ac3d9

Best regards,

Signature · 1 line
Alireza Haghdoost <[email protected]>