mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Michal Pluta <michalpl2003@gmail.com>
Cc: acme@kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	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>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] perf symbol: Shrink the demangled Rust buffer to fit
Date: Tue, 6 Oct 2026 13:07:17 -0700	[thread overview]
Message-ID: <asVU9e4eQ3OxJ2Qd@google.com> (raw)
In-Reply-To: <20260928010227.1903673-5-michalpl2003@gmail.com>

On Mon, Sep 28, 2026 at 02:02:26AM +0100, Michal Pluta wrote:
> The buffer a demangled Rust name is returned in is sized to whatever
> attempt succeeded, which is usually larger than the string it holds.
> Shrink it to the string's exact length before returning it.

Oh, you already have the patch! :)

Thanks,
Namhyung

> 
> Signed-off-by: Michal Pluta <michalpl2003@gmail.com>
> ---
>  tools/perf/util/symbol.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 1a52bc2980a0..858a14a91f79 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -2772,8 +2772,10 @@ char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
>  				break;
>  			demangled = tmp;
>  			if (rust_demangle_display_demangle(&rust_demangle, demangled, buf_len,
> -							   /*alternate=*/true) == OverflowOk)
> -				return demangled;
> +							   /*alternate=*/true) == OverflowOk) {
> +				tmp = realloc(demangled, strlen(demangled) + 1);
> +				return tmp ?: demangled;
> +			}
>  		}
>  		/* Failure to grow output buffer or buffer exceeded sensible bounds. */
>  		free(demangled);
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-10-06 20:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  1:02 [PATCH 0/5] perf symbol: Speed up demangling of long Rust symbols Michal Pluta
2026-09-28  1:02 ` [PATCH 1/5] perf test demangle: Fail when demangling fails Michal Pluta
2026-09-28 21:31   ` Ian Rogers
2026-09-28  1:02 ` [PATCH 2/5] perf symbol: Don't return an unterminated Rust demangle buffer Michal Pluta
2026-09-28 21:33   ` Ian Rogers
2026-09-30 17:10     ` Arnaldo Carvalho de Melo
2026-09-28  1:02 ` [PATCH 3/5] perf symbol: Grow the Rust demangle buffer geometrically Michal Pluta
2026-09-28 21:43   ` Ian Rogers
2026-10-06 20:06     ` Namhyung Kim
2026-09-28  1:02 ` [PATCH 4/5] perf symbol: Shrink the demangled Rust buffer to fit Michal Pluta
2026-10-06 20:07   ` Namhyung Kim [this message]
2026-09-28  1:02 ` [PATCH 5/5] perf symbol: Move Rust demangling into its own function Michal Pluta
2026-10-06 20:10 ` [PATCH 0/5] perf symbol: Speed up demangling of long Rust symbols Namhyung Kim

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=asVU9e4eQ3OxJ2Qd@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.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=michalpl2003@gmail.com \
    --cc=mingo@redhat.com \
    --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

all inboxes | Powered by JetHome®