* [PATCH] perf inject: Keep build-ID data if no option is used
@ 2025-12-17 18:39 Namhyung Kim
2025-12-17 18:57 ` Ian Rogers
0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2025-12-17 18:39 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, James Clark
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Gabriel Marin
The keep_feat() determines which header features will be kept or
discarded. Usually perf inject will add build-IDs based on -b, -B or
other related options. But it lose build-ID when none of those options
are used. This is meaningful only when --buildid-mmap is not used.
The following example shows the impact of this change.
$ perf record --no-buildid-mmap true
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.037 MB perf.data (5 samples) ]
$ perf inject -i perf.data -o perf.data.inject
$ perf buildid-list -i perf.data
08cccc2a9388d5247ccb3e864f3063b975b0a15d /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
fd5c4d5673256cd6bda51725dba048dabb0f854e [kernel.kallsyms]
97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
$ perf buildid-list -i perf.data.inject
97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
With this change, perf.data.inject would show the same list (of course,
you need to run perf inject again).
Reported-by: Gabriel Marin <gmx@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-inject.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index aa7be4fb5838fb99..6080afec537d2178 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -2022,7 +2022,7 @@ static int save_section_info(struct perf_inject *inject)
return perf_header__process_sections(header, fd, inject, save_section_info_cb);
}
-static bool keep_feat(int feat)
+static bool keep_feat(struct perf_inject *inject, int feat)
{
switch (feat) {
/* Keep original information that describes the machine or software */
@@ -2050,6 +2050,7 @@ static bool keep_feat(int feat)
return true;
/* Information that can be updated */
case HEADER_BUILD_ID:
+ return inject->build_id_style == BID_RWS__NONE;
case HEADER_CMDLINE:
case HEADER_EVENT_DESC:
case HEADER_BRANCH_STACK:
@@ -2108,7 +2109,7 @@ static int feat_copy_cb(struct feat_copier *fc, int feat, struct feat_writer *fw
int ret;
if (!inject->secs[feat].offset ||
- !keep_feat(feat))
+ !keep_feat(inject, feat))
return 0;
ret = feat_copy(inject, feat, fw);
--
2.52.0.313.g674ac2bdf7-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf inject: Keep build-ID data if no option is used
2025-12-17 18:39 [PATCH] perf inject: Keep build-ID data if no option is used Namhyung Kim
@ 2025-12-17 18:57 ` Ian Rogers
2026-01-08 23:57 ` Namhyung Kim
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2025-12-17 18:57 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, James Clark, Jiri Olsa, Adrian Hunter,
Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users,
Gabriel Marin
On Wed, Dec 17, 2025 at 10:39 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> The keep_feat() determines which header features will be kept or
> discarded. Usually perf inject will add build-IDs based on -b, -B or
> other related options. But it lose build-ID when none of those options
> are used. This is meaningful only when --buildid-mmap is not used.
>
> The following example shows the impact of this change.
>
> $ perf record --no-buildid-mmap true
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.037 MB perf.data (5 samples) ]
>
> $ perf inject -i perf.data -o perf.data.inject
>
> $ perf buildid-list -i perf.data
> 08cccc2a9388d5247ccb3e864f3063b975b0a15d /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
> fd5c4d5673256cd6bda51725dba048dabb0f854e [kernel.kallsyms]
> 97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
>
> $ perf buildid-list -i perf.data.inject
> 97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
>
> With this change, perf.data.inject would show the same list (of course,
> you need to run perf inject again).
>
> Reported-by: Gabriel Marin <gmx@google.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/builtin-inject.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index aa7be4fb5838fb99..6080afec537d2178 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
> @@ -2022,7 +2022,7 @@ static int save_section_info(struct perf_inject *inject)
> return perf_header__process_sections(header, fd, inject, save_section_info_cb);
> }
>
> -static bool keep_feat(int feat)
> +static bool keep_feat(struct perf_inject *inject, int feat)
> {
> switch (feat) {
> /* Keep original information that describes the machine or software */
> @@ -2050,6 +2050,7 @@ static bool keep_feat(int feat)
> return true;
> /* Information that can be updated */
> case HEADER_BUILD_ID:
> + return inject->build_id_style == BID_RWS__NONE;
> case HEADER_CMDLINE:
> case HEADER_EVENT_DESC:
> case HEADER_BRANCH_STACK:
> @@ -2108,7 +2109,7 @@ static int feat_copy_cb(struct feat_copier *fc, int feat, struct feat_writer *fw
> int ret;
>
> if (!inject->secs[feat].offset ||
> - !keep_feat(feat))
> + !keep_feat(inject, feat))
> return 0;
>
> ret = feat_copy(inject, feat, fw);
> --
> 2.52.0.313.g674ac2bdf7-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf inject: Keep build-ID data if no option is used
2025-12-17 18:57 ` Ian Rogers
@ 2026-01-08 23:57 ` Namhyung Kim
2026-01-13 20:16 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2026-01-08 23:57 UTC (permalink / raw)
To: Ian Rogers, Arnaldo Carvalho de Melo
Cc: James Clark, Jiri Olsa, Adrian Hunter, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users, Gabriel Marin
Hi Ian,
On Wed, Dec 17, 2025 at 10:57:01AM -0800, Ian Rogers wrote:
> On Wed, Dec 17, 2025 at 10:39 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > The keep_feat() determines which header features will be kept or
> > discarded. Usually perf inject will add build-IDs based on -b, -B or
> > other related options. But it lose build-ID when none of those options
> > are used. This is meaningful only when --buildid-mmap is not used.
> >
> > The following example shows the impact of this change.
> >
> > $ perf record --no-buildid-mmap true
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.037 MB perf.data (5 samples) ]
> >
> > $ perf inject -i perf.data -o perf.data.inject
> >
> > $ perf buildid-list -i perf.data
> > 08cccc2a9388d5247ccb3e864f3063b975b0a15d /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
> > fd5c4d5673256cd6bda51725dba048dabb0f854e [kernel.kallsyms]
> > 97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
> >
> > $ perf buildid-list -i perf.data.inject
> > 97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
> >
> > With this change, perf.data.inject would show the same list (of course,
> > you need to run perf inject again).
> >
> > Reported-by: Gabriel Marin <gmx@google.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks for the review!
Arnaldo, any chance you can pick this up soon?
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf inject: Keep build-ID data if no option is used
2026-01-08 23:57 ` Namhyung Kim
@ 2026-01-13 20:16 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-01-13 20:16 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ian Rogers, James Clark, Jiri Olsa, Adrian Hunter, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users, Gabriel Marin
On Thu, Jan 08, 2026 at 03:57:28PM -0800, Namhyung Kim wrote:
> Hi Ian,
>
> On Wed, Dec 17, 2025 at 10:57:01AM -0800, Ian Rogers wrote:
> > On Wed, Dec 17, 2025 at 10:39 AM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > The keep_feat() determines which header features will be kept or
> > > discarded. Usually perf inject will add build-IDs based on -b, -B or
> > > other related options. But it lose build-ID when none of those options
> > > are used. This is meaningful only when --buildid-mmap is not used.
> > >
> > > The following example shows the impact of this change.
> > >
> > > $ perf record --no-buildid-mmap true
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.037 MB perf.data (5 samples) ]
> > >
> > > $ perf inject -i perf.data -o perf.data.inject
> > >
> > > $ perf buildid-list -i perf.data
> > > 08cccc2a9388d5247ccb3e864f3063b975b0a15d /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
> > > fd5c4d5673256cd6bda51725dba048dabb0f854e [kernel.kallsyms]
> > > 97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
> > >
> > > $ perf buildid-list -i perf.data.inject
> > > 97a36ce1140071be5c36b147fa0bed173e05a602 [vdso]
> > >
> > > With this change, perf.data.inject would show the same list (of course,
> > > you need to run perf inject again).
> > >
> > > Reported-by: Gabriel Marin <gmx@google.com>
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> >
> > Reviewed-by: Ian Rogers <irogers@google.com>
>
> Thanks for the review!
>
> Arnaldo, any chance you can pick this up soon?
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-13 20:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 18:39 [PATCH] perf inject: Keep build-ID data if no option is used Namhyung Kim
2025-12-17 18:57 ` Ian Rogers
2026-01-08 23:57 ` Namhyung Kim
2026-01-13 20:16 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox