linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach <mike.leach@linaro.org>,
	James Clark <james.clark@linaro.org>,
	John Garry <john.g.garry@oracle.com>,
	Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
	coresight@lists.linaro.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 1/4] perf auxtrace: Iterate all AUX events when finish reading
Date: Thu, 25 Jul 2024 18:40:40 +0300	[thread overview]
Message-ID: <bb8e5202-bffa-4cd6-b49c-6372d51b405b@intel.com> (raw)
In-Reply-To: <20240725064620.1651819-2-leo.yan@arm.com>

On 25/07/24 09:46, Leo Yan wrote:
> When finished to read AUX trace data from mmaped buffer, based on the

Here and elsewhere 'mmapped' is more common than 'mmaped' so maybe:

	mmaped -> mmapped

> 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.

Looking at this again, a couple more things came to mind - see below.

> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>  tools/perf/util/auxtrace.c | 25 ++++++++++++++++++++-----
>  1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index b99e72f7da88..61835a6a9ea3 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -670,18 +670,33 @@ 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)
> +	if (!itr->evlist)
>  		return -EINVAL;
>  
>  	evlist__for_each_entry(itr->evlist, evsel) {
> -		if (evsel->core.attr.type == itr->pmu->type) {
> +		if (evsel__is_aux_event(evsel)) {
>  			if (evsel->disabled)
> -				return 0;
> -			return evlist__enable_event_idx(itr->evlist, evsel, idx);
> +				continue;

That will make the evsel->disabled case an error, which
might be a problem. Possibly the event can be disabled
(e.g. via control fifo) but still have data to read out.

> +			/*
> +			 * Multiple AUX events might be opened in a session.
> +			 * Bail out for success case as the AUX event has been
> +			 * found and enabled, otherwise, continue to check if
> +			 * the next AUX event can cover the mmaped buffer with
> +			 * 'idx'.
> +			 */

Thinking about this some more, raised some questions:

How do we know there is only one AUX event per mmap?  They
would have to be on different CPUs for that to be true?
And wouldn't --per-thread have all AUX events in every mmap?

> +			ret = evlist__enable_event_idx(itr->evlist, evsel, idx);
> +			if (ret >= 0)
> +				return ret;
>  		}
>  	}
> -	return -EINVAL;
> +
> +	/* Failed to find an event for the buffer 'idx' */
> +	if (ret < 0)
> +		pr_err("Failed to enable event (idx=%d): %d\n", idx, ret);
> +
> +	return ret;
>  }
>  
>  /*


  reply	other threads:[~2024-07-25 15:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-25  6:46 [PATCH v2 0/4] perf auxtrace: Support multiple AUX events Leo Yan
2024-07-25  6:46 ` [PATCH v2 1/4] perf auxtrace: Iterate all AUX events when finish reading Leo Yan
2024-07-25 15:40   ` Adrian Hunter [this message]
2024-07-29  8:48     ` Leo Yan
2024-07-30 19:28       ` Arnaldo Carvalho de Melo
2024-07-25  6:46 ` [PATCH v2 2/4] perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record Leo Yan
2024-07-25 15:51   ` Adrian Hunter
2024-07-25  6:46 ` [PATCH v2 3/4] perf arm-spe: Extract evsel setting up Leo Yan
2024-07-25  6:46 ` [PATCH v2 4/4] perf arm-spe: Support multiple Arm SPE events Leo Yan
2024-07-25  7:06 ` [PATCH v2 0/4] perf auxtrace: Support multiple AUX 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=bb8e5202-bffa-4cd6-b49c-6372d51b405b@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-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@linaro.org \
    --cc=namhyung@kernel.org \
    --cc=suzuki.poulose@arm.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;
as well as URLs for NNTP newsgroup(s).