From: James Clark <james.clark@linaro.org>
To: linux-perf-users@vger.kernel.org,
gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org,
leo.yan@arm.com, scclevenger@os.amperecomputing.com
Cc: James Clark <james.clark@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
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>, Leo Yan <leo.yan@linux.dev>,
Ben Gainey <ben.gainey@arm.com>,
Ruidong Tian <tianruidong@linux.alibaba.com>,
Benjamin Gray <bgray@linux.ibm.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] perf cs-etm: Remove cs_etm__flush()
Date: Thu, 5 Sep 2024 11:50:34 +0100 [thread overview]
Message-ID: <20240905105043.160225-4-james.clark@linaro.org> (raw)
In-Reply-To: <20240905105043.160225-1-james.clark@linaro.org>
This is only called on a discontinuity, and it generates a normal
sample and then clears the branch buffer. I'm not convinced that any
of the subtle differences between cs_etm__flush() and cs_etm__sample()
weren't actual bugs or potential sources of them.
Replace it with a call to the existing sample function and then a clear
of the branch buffer.
One obvious difference is that it now generates a range of instructions
based on instructions_sample_period, rather than only a single
instruction sample. I think this is actually the correct thing to do.
Signed-off-by: James Clark <james.clark@linaro.org>
---
tools/perf/util/cs-etm.c | 62 ++++------------------------------------
1 file changed, 5 insertions(+), 57 deletions(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 602e791ff5ba..cdda8403af2b 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -1908,60 +1908,6 @@ static int cs_etm__exception(struct cs_etm_traceid_queue *tidq)
return 0;
}
-static int cs_etm__flush(struct cs_etm_queue *etmq,
- struct cs_etm_traceid_queue *tidq)
-{
- int err = 0;
- struct cs_etm_auxtrace *etm = etmq->etm;
-
- /* Handle start tracing packet */
- if (tidq->prev_packet->sample_type == CS_ETM_EMPTY)
- goto swap_packet;
-
- if (etmq->etm->synth_opts.last_branch &&
- etmq->etm->synth_opts.instructions &&
- tidq->prev_packet->sample_type == CS_ETM_RANGE) {
- u64 addr;
-
- /* Prepare last branches for instruction sample */
- cs_etm__copy_last_branch_rb(etmq, tidq);
-
- /*
- * Generate a last branch event for the branches left in the
- * circular buffer at the end of the trace.
- *
- * Use the address of the end of the last reported execution
- * range
- */
- addr = cs_etm__last_executed_instr(tidq->prev_packet);
-
- err = cs_etm__synth_instruction_sample(
- etmq, tidq, addr,
- tidq->period_instructions);
- if (err)
- return err;
-
- tidq->period_instructions = 0;
-
- }
-
- if (etm->synth_opts.branches &&
- tidq->prev_packet->sample_type == CS_ETM_RANGE) {
- err = cs_etm__synth_branch_sample(etmq, tidq);
- if (err)
- return err;
- }
-
-swap_packet:
- cs_etm__packet_swap(etm, tidq);
-
- /* Reset last branches after flush the trace */
- if (etm->synth_opts.last_branch)
- cs_etm__reset_last_branch_rb(tidq);
-
- return err;
-}
-
static int cs_etm__end_block(struct cs_etm_queue *etmq,
struct cs_etm_traceid_queue *tidq)
{
@@ -2457,10 +2403,12 @@ static int cs_etm__process_traceid_queue(struct cs_etm_queue *etmq,
break;
case CS_ETM_DISCONTINUITY:
/*
- * Discontinuity in trace, flush
- * previous branch stack
+ * Discontinuity in trace, generate a sample then
+ * clear the branch stack.
*/
- cs_etm__flush(etmq, tidq);
+ cs_etm__sample(etmq, tidq);
+ if (etmq->etm->synth_opts.last_branch)
+ cs_etm__reset_last_branch_rb(tidq);
break;
case CS_ETM_EMPTY:
/*
--
2.34.1
next prev parent reply other threads:[~2024-09-05 10:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 10:50 [PATCH 0/8] perf: cs-etm: Coresight decode and disassembly improvements James Clark
2024-09-05 10:50 ` [PATCH 1/8] perf cs-etm: Don't flush when packet_queue fills up James Clark
2024-09-10 20:28 ` Leo Yan
2024-09-11 8:14 ` Leo Yan
2024-09-12 15:22 ` James Clark
2024-09-05 10:50 ` [PATCH 2/8] perf cs-etm: Use new OpenCSD consistency checks James Clark
2024-09-05 10:50 ` James Clark [this message]
2024-09-05 10:50 ` [PATCH 4/8] perf scripting python: Add function to get a config value James Clark
2024-09-05 10:50 ` [PATCH 5/8] perf scripts python cs-etm: Update to use argparse James Clark
2024-09-05 10:50 ` [PATCH 6/8] perf scripts python cs-etm: Improve arguments James Clark
2024-09-05 10:50 ` [PATCH 7/8] perf scripts python cs-etm: Add start and stop arguments James Clark
2024-09-05 10:50 ` [PATCH 8/8] perf test: cs-etm: Test Coresight disassembly script James Clark
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=20240905105043.160225-4-james.clark@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ben.gainey@arm.com \
--cc=bgray@linux.ibm.com \
--cc=coresight@lists.linaro.org \
--cc=gankulkarni@os.amperecomputing.com \
--cc=irogers@google.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=leo.yan@linux.dev \
--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=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=scclevenger@os.amperecomputing.com \
--cc=suzuki.poulose@arm.com \
--cc=tianruidong@linux.alibaba.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
all inboxes | Powered by JetHome®