linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: acme@kernel.org
Cc: suzuki.poulose@arm.com, mingo@redhat.com, peterz@infradead.org,
	jolsa@redhat.com, leo.yan@linaro.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 13/13] perf tools: Modularize auxtrace_buffer fetch function
Date: Tue, 12 Feb 2019 10:16:18 -0700	[thread overview]
Message-ID: <20190212171618.25355-14-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org>

Making the auxtrace_buffer fetch function modular so that it can be called
from different decoding context (timeless vs. non-timeless), avoiding to
repeat code.

No change in functionality is introduced by this patch.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index f607bc58bd03..110804936fc3 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -1152,6 +1152,32 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq)
 
 	return 0;
 }
+/*
+ * cs_etm__get_data_block: Fetch a block from the auxtrace_buffer queue
+ *			   if need be.
+ * Returns:	< 0	if error
+ *		= 0	if no more auxtrace_buffer to read
+ *		> 0	if the current buffer isn't empty yet
+ */
+static int cs_etm__get_data_block(struct cs_etm_queue *etmq)
+{
+	int ret;
+
+	if (!etmq->buf_len) {
+		ret = cs_etm__get_trace(etmq);
+		if (ret <= 0)
+			return ret;
+		/*
+		 * We cannot assume consecutive blocks in the data file
+		 * are contiguous, reset the decoder to force re-sync.
+		 */
+		ret = cs_etm_decoder__reset(etmq->decoder);
+		if (ret)
+			return ret;
+	}
+
+	return etmq->buf_len;
+}
 
 static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq,
 				 struct cs_etm_packet *packet,
@@ -1591,18 +1617,9 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
 
 	/* Go through each buffer in the queue and decode them one by one */
 	while (1) {
-		if (!etmq->buf_len) {
-			err = cs_etm__get_trace(etmq);
-			if (err <= 0)
-				return err;
-			/*
-			 * We cannot assume consecutive blocks in the data file
-			 * are contiguous, reset the decoder to force re-sync.
-			 */
-			err = cs_etm_decoder__reset(etmq->decoder);
-			if (err != 0)
-				return err;
-		}
+		err = cs_etm__get_data_block(etmq);
+		if (err <= 0)
+			return err;
 
 		/* Run trace decoder until buffer consumed or end of trace */
 		do {
-- 
2.17.1


  parent reply	other threads:[~2019-02-12 17:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 17:16 [PATCH 00/13] perf tools: CoreSight code cleanup and refactoring Mathieu Poirier
2019-02-12 17:16 ` [PATCH 01/13] perf tools: Remove unused structure field "state" Mathieu Poirier
2019-02-15  9:39   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 02/13] perf tools: Remove unused structure field "time" and "timestamp" Mathieu Poirier
2019-02-15  9:40   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 03/13] perf tools: Fix wrong return values in error path Mathieu Poirier
2019-02-15  9:40   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 04/13] perf tools: Introducing function cs_etm_decoder__init_dparams() Mathieu Poirier
2019-02-15  9:41   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 05/13] perf tools: Fix memory leak in error path Mathieu Poirier
2019-02-15  9:42   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 06/13] perf tools: Introducing function cs_etm__init_trace_params() Mathieu Poirier
2019-02-15  9:42   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 07/13] perf tools: Fix erroneous comment Mathieu Poirier
2019-02-15  9:43   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 08/13] perf tools: Cleaning up function cs_etm__alloc_queue() Mathieu Poirier
2019-02-15  9:43   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 09/13] perf tools: Rethink kernel address initialisation Mathieu Poirier
2019-02-15  9:44   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 10/13] perf tools: Make cs_etm__run_decoder() queue independent Mathieu Poirier
2019-02-15  9:45   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 11/13] perf tools: Modularize main decoder function Mathieu Poirier
2019-02-15  9:45   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` [PATCH 12/13] perf tools: Modularize main packet processing loop Mathieu Poirier
2019-02-15  9:46   ` [tip:perf/core] perf cs-etm: " tip-bot for Mathieu Poirier
2019-02-12 17:16 ` Mathieu Poirier [this message]
2019-02-15  9:47   ` [tip:perf/core] perf cs-etm: Modularize auxtrace_buffer fetch function tip-bot for Mathieu Poirier

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=20190212171618.25355-14-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).