From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org, llvm@lists.linux.dev
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>,
Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas.schier@linux.dev>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v5 2/3] tracing: Add a tracepoint verification check at build time
Date: Fri, 25 Jul 2025 09:15:34 -0400 [thread overview]
Message-ID: <a1f2f201-61f9-4564-b0c8-45c4d912bd00@efficios.com> (raw)
In-Reply-To: <20250725025213.342188378@kernel.org>
On 2025-07-24 22:51, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> If a tracepoint is defined via DECLARE_TRACE() or TRACE_EVENT() but never
> called (via the trace_<tracepoint>() function), its metadata is still
> around in memory and not discarded.
>
> When created via TRACE_EVENT() the situation is worse because the
> TRACE_EVENT() creates metadata that can be around 5k per trace event.
> Having unused trace events causes several thousand of wasted bytes.
>
> Add a verifier that injects a string of the name of the tracepoint it
> calls that is added to the discarded section "__tracepoint_check".
> For every builtin tracepoint, it's
its
[...]
> +
> +#define for_each_shdr_str(len, ehdr, sec) \
> + for (const char *str = (void *)(ehdr) + shdr_offset(sec), \
> + *end = (str) + shdr_size(sec); \
> + len = strlen(str), (str) < end; \
> + str += (len) + 1, len = strlen(str))
> +
> +static void make_trace_array(struct elf_tracepoint *etrace)
> +{
> + Elf_Ehdr *ehdr = etrace->ehdr;
> + const char **vals = NULL;
> + int count = 0;
> + int len;
> +
> + etrace->array = NULL;
> +
> + /*
> + * The __tracepoint_check section is filled with strings of the
> + * names of tracepoints (in tracepoint_strings). Create an array
> + * that points to each string and then sort the array.
> + */
> + for_each_shdr_str(len, ehdr, check_data_sec) {
> + if (!len)
> + continue;
The len==0 case would be when this skips section alignment padding when
the linker decides to align the beginning of each .o sections, which
ends up appearing as zeroed padding within the resulting vmlinux.o
section after the individual sections have been stitched together, am I
correct ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2025-07-25 13:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-25 2:51 [PATCH v5 0/3] tracepoints: Add warnings for unused tracepoints and trace events Steven Rostedt
2025-07-25 2:51 ` [PATCH v5 1/3] sorttable: Move ELF parsing into scripts/elf-parse.[ch] Steven Rostedt
2025-07-25 2:51 ` [PATCH v5 2/3] tracing: Add a tracepoint verification check at build time Steven Rostedt
2025-07-25 13:15 ` Mathieu Desnoyers [this message]
2025-07-25 13:41 ` Steven Rostedt
2025-07-25 13:49 ` Steven Rostedt
2025-07-26 10:36 ` kernel test robot
2025-07-25 2:51 ` [PATCH v5 3/3] tracepoint: Do not warn for unused event that is exported Steven Rostedt
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=a1f2f201-61f9-4564-b0c8-45c4d912bd00@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=mhiramat@kernel.org \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nicolas.schier@linux.dev \
--cc=rostedt@kernel.org \
--cc=torvalds@linux-foundation.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).