From: Robert Walker <robert.walker@arm.com>
To: Leo Yan <leo.yan@linaro.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Coresight ML <coresight@lists.linaro.org>
Subject: Re: [PATCH v2 1/4] perf cs-etm: Continuously record last branches
Date: Fri, 1 Nov 2019 15:30:19 +0000 [thread overview]
Message-ID: <3dd30190-b266-826d-3e2d-91f1446cc5fc@arm.com> (raw)
In-Reply-To: <20191101020750.29063-2-leo.yan@linaro.org>
On 01/11/2019 02:07, Leo Yan wrote:
> Every time synthesize instruction sample, the last branches recording
> will be reset. This would be fine if the instruction period is big
> enough, for example if we use the option '--itrace=i100000', the last
> branch array is reset for every instruction sample (10000 instructions
> per period); before generate the next instruction sample, there has the
> enough packets coming to fill last branch array. On the other hand,
> if set a very small period, the packets will be significantly reduced
> between two continuous instruction samples, thus if the last branch
> array is reset for the previous instruction sample, it's almost empty
> for the next instruction sample.
>
> To allow the last branches to work for any instruction periods, this
> patch avoids to reset the last branches for every instruction sample
> and only reset it when flush the trace data. The last branches will
> be reset only for two cases, one is for trace starting, another case
> is for discontinuous trace; thus it can continuously record last
> branches.
Is this the right thing to do? This would cause profiling tools to
count the same branch several times if it appears in multiple
instruction samples, which could result in a biased profile.
The current implementation matches the behavior of intel_pt where the
branch buffer is reset after each sample, so the instruction sample
only includes branches since the previous sample.
However x86 lbr (perf record -b) does appear to repeat the same full
branch stack on several samples until a new stack is captured.
I'm not sure what the right or wrong answer is here. For AutoFDO, we're
likely to use a much bigger period (>10000 instructions) so won't be
affected, but other tools might be.
Regards
Rob
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
> tools/perf/util/cs-etm.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index f5f855fff412..8be6d010ae84 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -1153,9 +1153,6 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq,
> "CS ETM Trace: failed to deliver instruction event, error %d\n",
> ret);
>
> - if (etm->synth_opts.last_branch)
> - cs_etm__reset_last_branch_rb(tidq);
> -
> return ret;
> }
>
> @@ -1486,6 +1483,10 @@ static int cs_etm__flush(struct cs_etm_queue *etmq,
> tidq->prev_packet = tmp;
> }
>
> + /* Reset last branches after flush the trace */
> + if (etm->synth_opts.last_branch)
> + cs_etm__reset_last_branch_rb(tidq);
> +
> return err;
> }
>
next prev parent reply other threads:[~2019-11-01 15:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-01 2:07 [PATCH v2 0/4] perf cs-etm: Fix synthesizing instruction samples Leo Yan
2019-11-01 2:07 ` [PATCH v2 1/4] perf cs-etm: Continuously record last branches Leo Yan
2019-11-01 15:30 ` Robert Walker [this message]
2019-11-02 6:11 ` Leo Yan
2019-11-01 2:07 ` [PATCH v2 2/4] perf cs-etm: Correct synthesizing instruction samples Leo Yan
2019-11-01 2:07 ` [PATCH v2 3/4] perf cs-etm: Optimize copying last branches Leo Yan
2019-11-01 2:07 ` [PATCH v2 4/4] perf cs-etm: Fix unsigned variable comparison to zero 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=3dd30190-b266-826d-3e2d-91f1446cc5fc@arm.com \
--to=robert.walker@arm.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=jolsa@redhat.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®