From: Alireza Haghdoost via B4 Relay <devnull+haghdoost.uber.com@kernel.org>
To: 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>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Alireza Haghdoost <haghdoost@uber.com>
Subject: [PATCH v9 2/7] perf symbols: Point to the symbol name instead of embedding it
Date: Tue, 24 Nov 2026 11:28:25 -0800 [thread overview]
Message-ID: <20261124-perf-symbol-memory-send-v9-2-56f298185eae@uber.com> (raw)
In-Reply-To: <20261124-perf-symbol-memory-send-v9-0-56f298185eae@uber.com>
From: Alireza Haghdoost <haghdoost@uber.com>
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 symbol array and the callers hold
pointers to it. With a pointer, the name is allocated separately and set
when it is read.
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Alireza Haghdoost <haghdoost@uber.com>
---
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(-)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 3240c39bd025..45841eac6f52 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -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;
}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index d9866916fe9a..25efc05c2c7a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -634,6 +634,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;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 41417bc85bb9..8abf6ec05bd6 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -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;
};
/**
--
Git-157)
next prev parent reply other threads:[~2026-11-24 19:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 19:28 [PATCH v9 0/7] perf script: Lazy symbol loading Alireza Haghdoost via B4 Relay
2026-11-24 19:28 ` [PATCH v9 1/7] perf symbols: Split out name-independent duplicate symbol selection Alireza Haghdoost via B4 Relay
2026-11-24 19:28 ` Alireza Haghdoost via B4 Relay [this message]
2026-11-24 19:28 ` [PATCH v9 3/7] perf symbols: Add lazy symbol names Alireza Haghdoost via B4 Relay
2026-11-24 19:28 ` [PATCH v9 4/7] perf script: Add --lazy-load-symbols to load symbol names lazily Alireza Haghdoost via B4 Relay
2026-11-24 19:28 ` [PATCH v9 5/7] perf report/top: Add --lazy-load-symbols Alireza Haghdoost via B4 Relay
2026-11-24 19:28 ` [PATCH v9 6/7] perf test: Add lazy symbol loading unit tests Alireza Haghdoost via B4 Relay
2026-11-24 19:28 ` [PATCH v9 7/7] perf test: Add lazy symbol loading shell tests Alireza Haghdoost via B4 Relay
2026-11-24 19:43 ` [PATCH v9 0/7] perf script: Lazy symbol loading sashiko-bot
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=20261124-perf-symbol-memory-send-v9-2-56f298185eae@uber.com \
--to=devnull+haghdoost.uber.com@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--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=namhyung@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox