[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6401ef3a-1a59-4575-7c1d-8065e8a2b5c6@linux.intel.com>
Date: Thu, 12 Aug 2021 12:32:49 +0800
From: "Jin, Yao" <yao.jin@...ux.intel.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: acme@...nel.org, jolsa@...nel.org, peterz@...radead.org,
mingo@...hat.com, alexander.shishkin@...ux.intel.com,
Linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
ak@...ux.intel.com, kan.liang@...el.com, yao.jin@...el.com,
rickyman7@...il.com, Kan Liang <kan.liang@...ux.intel.com>
Subject: Re: [PATCH v4 1/2] perf pmu: Add PMU alias support
Hi Jiri,
On 8/12/2021 3:23 AM, Jiri Olsa wrote:
> On Wed, Aug 11, 2021 at 10:48:26AM +0800, Jin Yao wrote:
>
> SNIP
>
>> if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false))
>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>> index fc683bc41715..796a4be752f4 100644
>> --- a/tools/perf/util/pmu.c
>> +++ b/tools/perf/util/pmu.c
>> @@ -946,6 +946,18 @@ perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
>> return NULL;
>> }
>>
>> +char * __weak
>> +pmu_find_real_name(const char *name)
>> +{
>> + return strdup(name);
>> +}
> hm, why does this need to return already strdup? it forces you
> to add all those goto below.. could just return name and keep
> the 'pmu->name = strdup(name);' below?
>
> that should make the change simpler
>
> jirka
>
In x86 specific __pmu_find_real_name,
static char *__pmu_find_real_name(const char *name)
{
struct perf_pmu_alias_name *pmu;
list_for_each_entry(pmu, &pmu_alias_name_list, list) {
if (!strcmp(name, pmu->alias))
return strdup(pmu->name);
}
return strdup(name);
}
We have returned with strdup(name).
OK, I will change the code to:
static char *__pmu_find_real_name(const char *name)
{
struct perf_pmu_alias_name *pmu;
list_for_each_entry(pmu, &pmu_alias_name_list, list) {
if (!strcmp(name, pmu->alias))
return pmu->name;
}
return name;
}
And keep 'pmu->name = strdup(name);' in pmu_lookup().
Thanks
Jin Yao
Powered by blists - more mailing lists