Re: [PATCH v1] perf stat: Expand metric+unit buffer size
From: Liang, Kan
Date: Wed Nov 06 2024 - 10:27:18 EST
On 2024-11-05 7:48 p.m., Ian Rogers wrote:
> Long metric names combined with units may exceed the metric_bf and
> lead to truncation. Double metric_bf in size to avoid this.
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/stat-shadow.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> index 8c9292aa61d3..6b531d4f58a3 100644
> --- a/tools/perf/util/stat-shadow.c
> +++ b/tools/perf/util/stat-shadow.c
> @@ -507,7 +507,7 @@ static void generic_metric(struct perf_stat_config *config,
> if (!metric_events[i]) {
> if (expr__parse(&ratio, pctx, metric_expr) == 0) {
> char *unit;
> - char metric_bf[64];
> + char metric_bf[128];
I thin there is already a MAX_EVENT_NAME.
Can we similarly define a MAX_METRIC_NAME for it?
Thanks,
Kan
>
> if (metric_threshold &&
> expr__parse(&threshold, pctx, metric_threshold) == 0 &&