From: Adrian Hunter <adrian.hunter@intel.com>
To: Leo Yan <leo.yan@arm.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
John Garry <john.g.garry@oracle.com>,
Will Deacon <will@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 4/6] perf auxtrace: Iterate all AUX events when finish reading
Date: Mon, 22 Jul 2024 18:59:42 +0300 [thread overview]
Message-ID: <1cb6fdfc-0405-4bfb-acd4-ed3b24744c8b@intel.com> (raw)
In-Reply-To: <9f301b09-e040-456c-9bd3-6d5e96ebc8f4@arm.com>
On 22/07/24 18:09, Leo Yan wrote:
> On 7/22/24 12:13, Adrian Hunter wrote:
>
> [...]
>
>> On 21/07/24 23:21, Leo Yan wrote:
>>> When finished to read AUX trace data from mmaped buffer, based on the
>>> AUX buffer index the core layer needs to search the corresponding PMU
>>> event and re-enable it to continue tracing.
>>>
>>> However, current code only searches the first AUX event. It misses to
>>> search other enabled AUX events, thus, it returns failure if the buffer
>>> index does not belong to the first AUX event.
>>>
>>> This patch extends the auxtrace_record__read_finish() function to
>>> search for every enabled AUX events, so all the mmaped buffer indexes
>>> can be covered.
>>>
>>> Signed-off-by: Leo Yan <leo.yan@arm.com>
>>> ---
>>> tools/perf/util/auxtrace.c | 15 +++++++++++----
>>> 1 file changed, 11 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
>>> index e2f317063eec..95be330d7e10 100644
>>> --- a/tools/perf/util/auxtrace.c
>>> +++ b/tools/perf/util/auxtrace.c
>>> @@ -670,18 +670,25 @@ static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel,
>>> int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx)
>>> {
>>> struct evsel *evsel;
>>> + int ret = -EINVAL;
>>>
>>> if (!itr->evlist || !itr->pmu)
>>> return -EINVAL;
>>>
>>> evlist__for_each_entry(itr->evlist, evsel) {
>>> - if (evsel->core.attr.type == itr->pmu->type) {
>>> + if (evsel__is_aux_event(evsel)) {
>>
>> If the type is the same, then there is no need to
>> change the logic here?
>
> No, the type is not same for AUX events. Every event has its own type
> value, this is likely related to recent refactoring.
>
> As a result, 'itr->pmu' only maintains the first registered AUX event,
> comparing to it the tool will find _only_ one AUX event. This is why here
> changes to use the evsel__is_aux_event() to detect AUX event.
>
>> Otherwise, maybe that should be a separate patch
>
> Could you explain what is a separate patch for?
No need.
>
> After this change, the field 'itr->pmu' will be redundant (at least this
> is the case for Arm SPE). I am preparing a refactoring patches for cleaning up
> and see if can totally remove the field 'itr->pmu' (if all AUX events
> have no issue.
For this function, 'itr->pmu' could be removed in this patch
since it is not used anymore.
>
>>
>>> if (evsel->disabled)
>>> - return 0;
>>> - return evlist__enable_event_idx(itr->evlist, evsel, idx);
>>> + continue;
>>> + ret = evlist__enable_event_idx(itr->evlist, evsel, idx);
>>> + if (ret >= 0)
>>
>> Should this be:
>>
>> if (ret < 0)
>
> Here the logic is to iterate all AUX events, even if an AUX event fails to
> find the buffer index, it will continue to next AUX event.
>
> So it directly bails out for success (as we have found the matched AUX
> event and enabled it). For the failure cause, it will continue for checking
> next event - until all events have been checked and no event is matched
> for buffer index, the failure will be handled at the end of the function.
Thanks for the explanation. Could probably use a small comment.
>
> Thanks,
> Leo
>
>>
>>> + return ret;
>>
>> And will need a common error path for the pr_err() below.
>>
>>> }
>>> }
>>> - return -EINVAL;
>>> +
>>> + if (ret < 0)
>>> + pr_err("Failed to event enable event (idx=%d): %d\n", idx, ret);
>>> +
>>> + return ret;
>>> }
>>>
>>> /*
>>
next prev parent reply other threads:[~2024-07-22 15:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-21 20:21 [PATCH v1 0/6] perf auxtrace: Support multiple AUX events Leo Yan
2024-07-21 20:21 ` [PATCH v1 1/6] perf pmu: Directly use evsel's PMU pointer Leo Yan
2024-07-22 10:40 ` Adrian Hunter
2024-07-22 14:34 ` Leo Yan
2024-07-22 16:16 ` Ian Rogers
2024-07-22 21:11 ` Leo Yan
2024-07-21 20:21 ` [PATCH v1 2/6] perf auxtrace arm: Set the 'auxtrace' flag for AUX events Leo Yan
2024-07-22 10:49 ` Adrian Hunter
2024-07-22 14:36 ` Leo Yan
2024-07-21 20:21 ` [PATCH v1 3/6] perf auxtrace s390: " Leo Yan
2024-07-22 10:54 ` Adrian Hunter
2024-07-22 14:48 ` Leo Yan
2024-07-21 20:21 ` [PATCH v1 4/6] perf auxtrace: Iterate all AUX events when finish reading Leo Yan
2024-07-22 11:13 ` Adrian Hunter
2024-07-22 15:09 ` Leo Yan
2024-07-22 15:59 ` Adrian Hunter [this message]
2024-07-22 20:52 ` Leo Yan
2024-08-01 1:38 ` Ian Rogers
2024-08-01 15:04 ` Arnaldo Carvalho de Melo
2024-08-03 15:51 ` Leo Yan
2024-07-21 20:21 ` [PATCH v1 5/6] perf arm-spe: Extract evsel setting up Leo Yan
2024-07-21 20:21 ` [PATCH v1 6/6] perf arm-spe: Support multiple Arm SPE events Leo Yan
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=1cb6fdfc-0405-4bfb-acd4-ed3b24744c8b@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=coresight@lists.linaro.org \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=namhyung@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).