[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZAC2k4I8rEPQWL/o@kernel.org>
Date: Thu, 2 Mar 2023 11:45:39 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Kan Liang <kan.liang@...ux.intel.com>,
Zhengjun Xing <zhengjun.xing@...ux.intel.com>,
Ravi Bangoria <ravi.bangoria@....com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Steinar H. Gunderson" <sesse@...gle.com>,
Qi Liu <liuqi115@...wei.com>,
Kim Phillips <kim.phillips@....com>,
Florian Fischer <florian.fischer@...q.space>,
James Clark <james.clark@....com>,
Suzuki Poulouse <suzuki.poulose@....com>,
Sean Christopherson <seanjc@...gle.com>,
Leo Yan <leo.yan@...aro.org>,
John Garry <john.g.garry@...cle.com>,
Kajol Jain <kjain@...ux.ibm.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH v1 08/10] perf parse-events: Pass ownership of the group
name
Em Wed, Mar 01, 2023 at 08:12:09PM -0800, Ian Rogers escreveu:
> Pass ownership of the group name rather than copying and freeing the
> original. This saves a memory allocation and copy.
Looks ok.
- Arnaldo
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
> tools/perf/util/parse-events.c | 3 ++-
> tools/perf/util/parse-events.y | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 0336ff27c15f..1be454697d57 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1761,6 +1761,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
>
> handled:
> ret = 1;
> + free(name);
> out:
> free(leaders);
> return ret;
> @@ -1786,7 +1787,7 @@ void parse_events__set_leader(char *name, struct list_head *list,
>
> leader = arch_evlist__leader(list);
> __perf_evlist__set_leader(list, &leader->core);
> - leader->group_name = name ? strdup(name) : NULL;
> + leader->group_name = name;
> list_move(&leader->core.node, list);
> }
>
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index be8c51770051..541b8dde2063 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -202,8 +202,8 @@ PE_NAME '{' events '}'
> struct list_head *list = $3;
>
> inc_group_count(list, _parse_state);
> + /* Takes ownership of $1. */
> parse_events__set_leader($1, list, _parse_state);
> - free($1);
> $$ = list;
> }
> |
> --
> 2.39.2.722.g9855ee24e9-goog
>
--
- Arnaldo
Powered by blists - more mailing lists