[PATCH 12/19] perf metric: Add events for the current list

2020-07-29 Thread Jiri Olsa
There's no need to iterate the whole list of groups, when adding new
events. The currently created groups are the ones we want to add.

Signed-off-by: Jiri Olsa 
Reviewed-by: Kajol Jain 
Acked-by: Ian Rogers 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: John Garry 
Cc: Michael Petlan 
Cc: Namhyung Kim 
Cc: Paul Clarke 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lore.kernel.org/lkml/20200719181320.785305-13-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/metricgroup.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index a9f101948e1f..caec3696e52b 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
 {
struct pmu_event *pe;
struct egroup *eg;
+   LIST_HEAD(list);
int i, ret;
bool has_match = false;
 
@@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
has_match = true;
eg = NULL;
 
-   ret = add_metric(group_list, pe, metric_no_group, );
+   ret = add_metric(, pe, metric_no_group, );
if (ret)
return ret;
 
@@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
 * included in the expression.
 */
ret = resolve_metric(eg, metric_no_group,
-group_list, map);
+, map);
if (ret)
return ret;
}
@@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
if (!has_match)
return -EINVAL;
 
-   list_for_each_entry(eg, group_list, nd) {
+   list_for_each_entry(eg, , nd) {
if (events->len > 0)
strbuf_addf(events, ",");
 
@@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
   >pctx);
}
}
+
+   list_splice(, group_list);
return 0;
 }
 
-- 
2.25.4



Re: [PATCH 12/19] perf metric: Add events for the current list

2020-07-28 Thread Arnaldo Carvalho de Melo
Em Sun, Jul 19, 2020 at 03:34:48PM -0700, Ian Rogers escreveu:
> On Sun, Jul 19, 2020 at 11:14 AM Jiri Olsa  wrote:
> >
> > There's no need to iterate the whole list of groups,
> > when adding new events. The currently created groups
> > are the ones we want to add.
> >
> > Signed-off-by: Jiri Olsa 
> 
> Acked-by: Ian Rogers 

Thanks, applied.

- Arnaldo
 
> Thanks,
> Ian
> 
> > ---
> >  tools/perf/util/metricgroup.c | 9 ++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> > index bb5757b9419d..332414d93f7a 100644
> > --- a/tools/perf/util/metricgroup.c
> > +++ b/tools/perf/util/metricgroup.c
> > @@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, 
> > bool metric_no_group,
> >  {
> > struct pmu_event *pe;
> > struct egroup *eg;
> > +   LIST_HEAD(list);
> > int i, ret;
> > bool has_match = false;
> >
> > @@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, 
> > bool metric_no_group,
> > has_match = true;
> > eg = NULL;
> >
> > -   ret = add_metric(group_list, pe, metric_no_group, );
> > +   ret = add_metric(, pe, metric_no_group, );
> > if (ret)
> > return ret;
> >
> > @@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, 
> > bool metric_no_group,
> >  * included in the expression.
> >  */
> > ret = resolve_metric(eg, metric_no_group,
> > -group_list, map);
> > +, map);
> > if (ret)
> > return ret;
> > }
> > @@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, 
> > bool metric_no_group,
> > if (!has_match)
> > return -EINVAL;
> >
> > -   list_for_each_entry(eg, group_list, nd) {
> > +   list_for_each_entry(eg, , nd) {
> > if (events->len > 0)
> > strbuf_addf(events, ",");
> >
> > @@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, 
> > bool metric_no_group,
> >>pctx);
> > }
> > }
> > +
> > +   list_splice(, group_list);
> > return 0;
> >  }
> >
> > --
> > 2.25.4
> >

-- 

- Arnaldo


Re: [PATCH 12/19] perf metric: Add events for the current list

2020-07-26 Thread kajoljain



On 7/20/20 4:04 AM, Ian Rogers wrote:
> On Sun, Jul 19, 2020 at 11:14 AM Jiri Olsa  wrote:
>>
>> There's no need to iterate the whole list of groups,
>> when adding new events. The currently created groups
>> are the ones we want to add.
>>
>> Signed-off-by: Jiri Olsa 
> 
> Acked-by: Ian Rogers 
> 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> Thanks,
> Ian
> 
>> ---
>>  tools/perf/util/metricgroup.c | 9 ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
>> index bb5757b9419d..332414d93f7a 100644
>> --- a/tools/perf/util/metricgroup.c
>> +++ b/tools/perf/util/metricgroup.c
>> @@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>>  {
>> struct pmu_event *pe;
>> struct egroup *eg;
>> +   LIST_HEAD(list);
>> int i, ret;
>> bool has_match = false;
>>
>> @@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>> has_match = true;
>> eg = NULL;
>>
>> -   ret = add_metric(group_list, pe, metric_no_group, );
>> +   ret = add_metric(, pe, metric_no_group, );
>> if (ret)
>> return ret;
>>
>> @@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>>  * included in the expression.
>>  */
>> ret = resolve_metric(eg, metric_no_group,
>> -group_list, map);
>> +, map);
>> if (ret)
>> return ret;
>> }
>> @@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>> if (!has_match)
>> return -EINVAL;
>>
>> -   list_for_each_entry(eg, group_list, nd) {
>> +   list_for_each_entry(eg, , nd) {
>> if (events->len > 0)
>> strbuf_addf(events, ",");
>>
>> @@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>>>pctx);
>> }
>> }
>> +
>> +   list_splice(, group_list);
>> return 0;
>>  }
>>
>> --
>> 2.25.4
>>


Re: [PATCH 12/19] perf metric: Add events for the current list

2020-07-19 Thread Ian Rogers
On Sun, Jul 19, 2020 at 11:14 AM Jiri Olsa  wrote:
>
> There's no need to iterate the whole list of groups,
> when adding new events. The currently created groups
> are the ones we want to add.
>
> Signed-off-by: Jiri Olsa 

Acked-by: Ian Rogers 

Thanks,
Ian

> ---
>  tools/perf/util/metricgroup.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index bb5757b9419d..332414d93f7a 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
>  {
> struct pmu_event *pe;
> struct egroup *eg;
> +   LIST_HEAD(list);
> int i, ret;
> bool has_match = false;
>
> @@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
> has_match = true;
> eg = NULL;
>
> -   ret = add_metric(group_list, pe, metric_no_group, );
> +   ret = add_metric(, pe, metric_no_group, );
> if (ret)
> return ret;
>
> @@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
>  * included in the expression.
>  */
> ret = resolve_metric(eg, metric_no_group,
> -group_list, map);
> +, map);
> if (ret)
> return ret;
> }
> @@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
> if (!has_match)
> return -EINVAL;
>
> -   list_for_each_entry(eg, group_list, nd) {
> +   list_for_each_entry(eg, , nd) {
> if (events->len > 0)
> strbuf_addf(events, ",");
>
> @@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
>>pctx);
> }
> }
> +
> +   list_splice(, group_list);
> return 0;
>  }
>
> --
> 2.25.4
>


[PATCH 12/19] perf metric: Add events for the current list

2020-07-19 Thread Jiri Olsa
There's no need to iterate the whole list of groups,
when adding new events. The currently created groups
are the ones we want to add.

Signed-off-by: Jiri Olsa 
---
 tools/perf/util/metricgroup.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index bb5757b9419d..332414d93f7a 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
 {
struct pmu_event *pe;
struct egroup *eg;
+   LIST_HEAD(list);
int i, ret;
bool has_match = false;
 
@@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
has_match = true;
eg = NULL;
 
-   ret = add_metric(group_list, pe, metric_no_group, );
+   ret = add_metric(, pe, metric_no_group, );
if (ret)
return ret;
 
@@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
 * included in the expression.
 */
ret = resolve_metric(eg, metric_no_group,
-group_list, map);
+, map);
if (ret)
return ret;
}
@@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
if (!has_match)
return -EINVAL;
 
-   list_for_each_entry(eg, group_list, nd) {
+   list_for_each_entry(eg, , nd) {
if (events->len > 0)
strbuf_addf(events, ",");
 
@@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, bool 
metric_no_group,
   >pctx);
}
}
+
+   list_splice(, group_list);
return 0;
 }
 
-- 
2.25.4