tools/perf/Makefile.config | 103 ++++++++++++------------ tools/perf/builtin-kwork.c | 151 ++++++++++++++++++++++++++++-------- tools/perf/util/bpf_kwork.c | 14 +++- tools/perf/util/kwork.h | 9 +++ 4 files changed, 188 insertions(+), 89 deletions(-)
The combination of the libunwind refactoring and build system changes
exposed a build-test regression for the libunwind build using a cached
feature dump. Re-send kwork fixes [1] moving a definition to kwork.h
to avoid breaking no libbpf builds.
1. Build Fix for libunwind:
"make feature-dump" runs without LIBUNWIND=1, skipping the setup of
libunwind LDFLAGS. When Makefile.feature is included to generate the
cached FEATURE-DUMP, the local test-libunwind.bin compiles without
arch-specific link flags (-lunwind-x86_64) and fails, caching a false
negative ("feature-libunwind=0"). Later builds (such as make_libunwind_O
reusing the dump) compile the unwinder based on CONFIG_LIBUNWIND (remote)
but disable HAVE_LIBUNWIND_SUPPORT (local), breaking compilation due to
missing maps__e_machine declarations in maps.h. Fixed by unconditionally
setting up libunwind feature build flags in Makefile.config.
2. kwork ASAN Double-Free & Leaks:
- Solves double-free in the record command argument array due to
parse_options mutation, by preserving original pointers in a calloc'ed
to_free buffer.
- Ensures kwork_usage string is freed on all exit paths.
3. kwork Unified Memory Lifecycle:
- Establishes a unified memory ownership model for kwork_work by
ensuring work names are dynamically duplicated via strdup() and
consistently freed using work_exit() and a central perf_kwork__exit()
teardown path.
[1] https://lore.kernel.org/linux-perf-users/20260520190538.142018-32-irogers@google.com/
Ian Rogers (3):
perf build: Unconditionally set up libunwind feature build flags
perf kwork: Fix address sanitizer issues
perf kwork: Fix memory management of kwork_work
tools/perf/Makefile.config | 103 ++++++++++++------------
tools/perf/builtin-kwork.c | 151 ++++++++++++++++++++++++++++--------
tools/perf/util/bpf_kwork.c | 14 +++-
tools/perf/util/kwork.h | 9 +++
4 files changed, 188 insertions(+), 89 deletions(-)
--
2.54.0.746.g67dd491aae-goog
On Thu, May 21, 2026 at 12:24 AM Ian Rogers <irogers@google.com> wrote:
>
> The combination of the libunwind refactoring and build system changes
> exposed a build-test regression for the libunwind build using a cached
> feature dump. Re-send kwork fixes [1] moving a definition to kwork.h
> to avoid breaking no libbpf builds.
>
> 1. Build Fix for libunwind:
> "make feature-dump" runs without LIBUNWIND=1, skipping the setup of
> libunwind LDFLAGS. When Makefile.feature is included to generate the
> cached FEATURE-DUMP, the local test-libunwind.bin compiles without
> arch-specific link flags (-lunwind-x86_64) and fails, caching a false
> negative ("feature-libunwind=0"). Later builds (such as make_libunwind_O
> reusing the dump) compile the unwinder based on CONFIG_LIBUNWIND (remote)
> but disable HAVE_LIBUNWIND_SUPPORT (local), breaking compilation due to
> missing maps__e_machine declarations in maps.h. Fixed by unconditionally
> setting up libunwind feature build flags in Makefile.config.
>
> 2. kwork ASAN Double-Free & Leaks:
> - Solves double-free in the record command argument array due to
> parse_options mutation, by preserving original pointers in a calloc'ed
> to_free buffer.
> - Ensures kwork_usage string is freed on all exit paths.
>
> 3. kwork Unified Memory Lifecycle:
> - Establishes a unified memory ownership model for kwork_work by
> ensuring work names are dynamically duplicated via strdup() and
> consistently freed using work_exit() and a central perf_kwork__exit()
> teardown path.
It would be nice to land these fixes. Thomas reported the kwork crashes in:
https://lore.kernel.org/linux-perf-users/314df838-4c38-4f03-9515-ae1dabd09a54@linux.ibm.com/
Thanks,
Ian
> [1] https://lore.kernel.org/linux-perf-users/20260520190538.142018-32-irogers@google.com/
>
> Ian Rogers (3):
> perf build: Unconditionally set up libunwind feature build flags
> perf kwork: Fix address sanitizer issues
> perf kwork: Fix memory management of kwork_work
>
> tools/perf/Makefile.config | 103 ++++++++++++------------
> tools/perf/builtin-kwork.c | 151 ++++++++++++++++++++++++++++--------
> tools/perf/util/bpf_kwork.c | 14 +++-
> tools/perf/util/kwork.h | 9 +++
> 4 files changed, 188 insertions(+), 89 deletions(-)
>
> --
> 2.54.0.746.g67dd491aae-goog
>
On Fri, May 22, 2026 at 02:33:05PM -0700, Ian Rogers wrote:
> On Thu, May 21, 2026 at 12:24 AM Ian Rogers <irogers@google.com> wrote:
> >
> > The combination of the libunwind refactoring and build system changes
> > exposed a build-test regression for the libunwind build using a cached
> > feature dump. Re-send kwork fixes [1] moving a definition to kwork.h
> > to avoid breaking no libbpf builds.
> >
> > 1. Build Fix for libunwind:
> > "make feature-dump" runs without LIBUNWIND=1, skipping the setup of
> > libunwind LDFLAGS. When Makefile.feature is included to generate the
> > cached FEATURE-DUMP, the local test-libunwind.bin compiles without
> > arch-specific link flags (-lunwind-x86_64) and fails, caching a false
> > negative ("feature-libunwind=0"). Later builds (such as make_libunwind_O
> > reusing the dump) compile the unwinder based on CONFIG_LIBUNWIND (remote)
> > but disable HAVE_LIBUNWIND_SUPPORT (local), breaking compilation due to
> > missing maps__e_machine declarations in maps.h. Fixed by unconditionally
> > setting up libunwind feature build flags in Makefile.config.
> >
> > 2. kwork ASAN Double-Free & Leaks:
> > - Solves double-free in the record command argument array due to
> > parse_options mutation, by preserving original pointers in a calloc'ed
> > to_free buffer.
> > - Ensures kwork_usage string is freed on all exit paths.
> >
> > 3. kwork Unified Memory Lifecycle:
> > - Establishes a unified memory ownership model for kwork_work by
> > ensuring work names are dynamically duplicated via strdup() and
> > consistently freed using work_exit() and a central perf_kwork__exit()
> > teardown path.
>
> It would be nice to land these fixes. Thomas reported the kwork crashes in:
> https://lore.kernel.org/linux-perf-users/314df838-4c38-4f03-9515-ae1dabd09a54@linux.ibm.com/
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo
© 2016 - 2026 Red Hat, Inc.