From: "Jin, Yao" <yao.jin@linux.intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com,
Linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com,
rickyman7@gmail.com, Kan Liang <kan.liang@linux.intel.com>
Subject: Re: [PATCH v4 1/2] perf pmu: Add PMU alias support
Date: Thu, 12 Aug 2021 12:32:49 +0800 [thread overview]
Message-ID: <6401ef3a-1a59-4575-7c1d-8065e8a2b5c6@linux.intel.com> (raw)
In-Reply-To: <YRQjreot69DL0xVV@krava>
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
next prev parent reply other threads:[~2021-08-12 4:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 2:48 [PATCH v4 0/2] perf tools: Add PMU alias support Jin Yao
2021-08-11 2:48 ` [PATCH v4 1/2] perf pmu: " Jin Yao
2021-08-11 13:27 ` Andi Kleen
2021-08-12 4:39 ` Jin, Yao
2021-08-11 19:23 ` Jiri Olsa
2021-08-12 4:32 ` Jin, Yao [this message]
2021-08-12 12:14 ` John Garry
2021-08-13 1:59 ` Jin, Yao
2021-08-11 2:48 ` [PATCH v4 2/2] perf tests: Test for PMU alias Jin Yao
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=6401ef3a-1a59-4575-7c1d-8065e8a2b5c6@linux.intel.com \
--to=yao.jin@linux.intel.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.com \
--cc=yao.jin@intel.com \
/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