[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <49025439-f9e3-0d32-b0a3-ff9f9ff71835@huawei.com>
Date: Tue, 6 Apr 2021 14:21:11 +0100
From: John Garry <john.garry@...wei.com>
To: Jiri Olsa <jolsa@...hat.com>
CC: <will@...nel.org>, <mathieu.poirier@...aro.org>,
<leo.yan@...aro.org>, <peterz@...radead.org>, <mingo@...hat.com>,
<acme@...nel.org>, <mark.rutland@....com>,
<alexander.shishkin@...ux.intel.com>, <namhyung@...nel.org>,
<irogers@...gle.com>, <linuxarm@...wei.com>, <kjain@...ux.ibm.com>,
<kan.liang@...ux.intel.com>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<zhangshaokun@...ilicon.com>, <pc@...ibm.com>
Subject: Re: [PATCH v2 2/6] perf test: Handle metric reuse in pmu-events
parsing test
On 06/04/2021 13:55, Jiri Olsa wrote:
>>>> So expr__find_other() may add a new item to pctx->ids, and we always iterate
>>>> again, and try to lookup any pmu_events, *, above. If none exist, then we
>>> hm, I don't see that.. so, what you do is:
>>>
>>> hashmap__for_each_entry_safe((&pctx->ids) ....) {
>>>
>>> rc = expr__find_other(pe->metric_expr, NULL, pctx, 0);
>>> }
>>>
>>> and what I think we need to do is:
>>>
>>> hashmap__for_each_entry_safe((&pctx->ids) ....) {
>>>
>>> rc = expr__find_other(pe->metric_expr, NULL, pctx, 0);
>>>
>>> break;
>>> }
>>>
>>> each time you resolve another metric, you need to restart
>>> the pctx->ids iteration, because there will be new items,
>>> and we are in the middle of it
>> Sure, but we will restart anyway.
> hum, where? you call expr__find_other and continue to next
> pctx->ids item
We have:
resolve_metric_simple()
{
bool all;
do {
all = true;
hashmap__for_each_entry_safe(&pctx->ids, ...) {
pe = metricgroup_find_metric(cur->key, map);
if (!pe)
continue;
...
all = false;
expr_del_id(pctx, cur->key);
...
rc = expr__find_other(pe->metric_expr, pctx);
if (rc)
goto out_err;
}
} while (!all);
}
So once we evaluate a pmu_event in pctx->ids in @pe, @all is set false,
and we would loop again in the do-while loop, regardless of what
expr__find_other() does (apart from erroring), and so call
hashmap__for_each_entry_safe(&pctx->ids, ) again.
This is really what is done in __resolve_metric() - indeed, I would use
that function directly, but it looks hard to extract that from
metricgroup.c .
Thanks,
John
>
>> Regardless of this, I don't think what I am doing is safe, i.e. adding new
>> items in the middle of the iter, so I will change in the way you suggest.
> it'll always add items in the middle of the iteration
Powered by blists - more mailing lists