From: "liwei (GF)" <liwei391@huawei.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, "Ian Rogers" <irogers@google.com>,
Kajol Jain <kjain@linux.ibm.com>,
Kan Liang <kan.liang@linux.intel.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
"Li Bin" <huawei.libin@huawei.com>, <guohanjun@huawei.com>
Subject: Re: [PATCH] perf metric: Code cleanup with map_for_each_event()
Date: Thu, 17 Sep 2020 19:53:29 +0800 [thread overview]
Message-ID: <6fca1006-f7a6-160a-e6ef-17701dfe9d4c@huawei.com> (raw)
In-Reply-To: <CAM9d7cgDK6n1=k+45PmdjtFf48oPRYx+rjMKWx0aiVWjyD3trg@mail.gmail.com>
Hi Namhyung,
On 2020/9/17 13:19, Namhyung Kim wrote:
> Hello,
>
> On Thu, Sep 17, 2020 at 11:45 AM Wei Li <liwei391@huawei.com> wrote:
>>
>> Since we have introduced map_for_each_event() to walk the 'pmu_events_map',
>> clean up metricgroup__print() and metricgroup__has_metric() with it.
>>
>> Signed-off-by: Wei Li <liwei391@huawei.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
>
> A nit-pick below:
>
>
>> ---
>> tools/perf/util/metricgroup.c | 33 +++++++++++++--------------------
>> 1 file changed, 13 insertions(+), 20 deletions(-)
>>
>> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
>> index 8831b964288f..3734cbb2c456 100644
>> --- a/tools/perf/util/metricgroup.c
>> +++ b/tools/perf/util/metricgroup.c
>> @@ -26,6 +26,17 @@
>> #include "util.h"
>> #include <asm/bug.h>
>>
>> +#define map_for_each_event(__pe, __idx, __map) \
>> + for (__idx = 0, __pe = &__map->table[__idx]; \
>> + __pe->name || __pe->metric_group || __pe->metric_name; \
>> + __pe = &__map->table[++__idx])
>> +
>> +#define map_for_each_metric(__pe, __idx, __map, __metric) \
>> + map_for_each_event(__pe, __idx, __map) \
>> + if (__pe->metric_expr && \
>> + (match_metric(__pe->metric_group, __metric) || \
>> + match_metric(__pe->metric_name, __metric)))
>> +
>
> You may consider adding a declaration of match_metric() here.
> Right now, all users are below the function so it's ok but
> having the macro here can enable future addition above IMHO.
>
Thanks for spotting that.
I'd like to move them just below match_metric() for now, when we really need
to use them somewhere else, we may move them to header file then.
Thanks,
Wei
prev parent reply other threads:[~2020-09-17 11:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 2:44 Wei Li
2020-09-17 5:19 ` Namhyung Kim
2020-09-17 11:53 ` liwei (GF) [this message]
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=6fca1006-f7a6-160a-e6ef-17701dfe9d4c@huawei.com \
--to=liwei391@huawei.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=guohanjun@huawei.com \
--cc=huawei.libin@huawei.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=namhyung@kernel.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®