linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Jiri Olsa <jolsa@redhat.com>, Leo Yan <leo.yan@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Suzuki K Poulouse <suzuki.poulose@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 32/43] perf cs-etm: Make cs_etm__run_decoder() queue independent
Date: Thu, 14 Feb 2019 21:45:28 -0300	[thread overview]
Message-ID: <20190215004539.23571-33-acme@kernel.org> (raw)
In-Reply-To: <20190215004539.23571-1-acme@kernel.org>

From: Mathieu Poirier <mathieu.poirier@linaro.org>

This patch makes decoding of auxtrace buffer centered around a struct
cs_etm_queue.  This eliminates surperflous variables and is a precursor
for work that simplifies the main decoder loop.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20190212171618.25355-11-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../perf/util/cs-etm-decoder/cs-etm-decoder.h |  7 ---
 tools/perf/util/cs-etm.c                      | 52 +++++++++----------
 2 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
index 663309486784..3ab11dfa92ae 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
@@ -15,13 +15,6 @@
 
 struct cs_etm_decoder;
 
-struct cs_etm_buffer {
-	const unsigned char *buf;
-	size_t len;
-	u64 offset;
-	u64 ref_timestamp;
-};
-
 enum cs_etm_sample_type {
 	CS_ETM_EMPTY,
 	CS_ETM_RANGE,
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 2d2de898ea68..d2c90b369e7c 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -76,6 +76,8 @@ struct cs_etm_queue {
 	size_t last_branch_pos;
 	struct cs_etm_packet *prev_packet;
 	struct cs_etm_packet *packet;
+	const unsigned char *buf;
+	size_t buf_len, buf_used;
 };
 
 static int cs_etm__update_queues(struct cs_etm_auxtrace *etm);
@@ -683,7 +685,7 @@ static int cs_etm__inject_event(union perf_event *event,
 
 
 static int
-cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq)
+cs_etm__get_trace(struct cs_etm_queue *etmq)
 {
 	struct auxtrace_buffer *aux_buffer = etmq->buffer;
 	struct auxtrace_buffer *old_buffer = aux_buffer;
@@ -697,7 +699,7 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq)
 	if (!aux_buffer) {
 		if (old_buffer)
 			auxtrace_buffer__drop_data(old_buffer);
-		buff->len = 0;
+		etmq->buf_len = 0;
 		return 0;
 	}
 
@@ -717,13 +719,11 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq)
 	if (old_buffer)
 		auxtrace_buffer__drop_data(old_buffer);
 
-	buff->offset = aux_buffer->offset;
-	buff->len = aux_buffer->size;
-	buff->buf = aux_buffer->data;
+	etmq->buf_used = 0;
+	etmq->buf_len = aux_buffer->size;
+	etmq->buf = aux_buffer->data;
 
-	buff->ref_timestamp = aux_buffer->reference;
-
-	return buff->len;
+	return etmq->buf_len;
 }
 
 static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm,
@@ -1493,24 +1493,23 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq)
 
 static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
 {
-	struct cs_etm_buffer buffer;
-	size_t buffer_used, processed;
+	size_t processed;
 	int err = 0;
 
 	/* Go through each buffer in the queue and decode them one by one */
 	while (1) {
-		buffer_used = 0;
-		memset(&buffer, 0, sizeof(buffer));
-		err = cs_etm__get_trace(&buffer, 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;
+		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;
+		}
 
 		/* Run trace decoder until buffer consumed or end of trace */
 		do {
@@ -1518,14 +1517,15 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
 			err = cs_etm_decoder__process_data_block(
 				etmq->decoder,
 				etmq->offset,
-				&buffer.buf[buffer_used],
-				buffer.len - buffer_used,
+				&etmq->buf[etmq->buf_used],
+				etmq->buf_len,
 				&processed);
 			if (err)
 				return err;
 
 			etmq->offset += processed;
-			buffer_used += processed;
+			etmq->buf_used += processed;
+			etmq->buf_len -= processed;
 
 			/* Process each packet in this chunk */
 			while (1) {
@@ -1585,7 +1585,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
 					break;
 				}
 			}
-		} while (buffer.len > buffer_used);
+		} while (etmq->buf_len);
 
 		if (err == 0)
 			/* Flush any remaining branch stack entries */
-- 
2.19.1

  parent reply	other threads:[~2019-02-15  0:45 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15  0:44 [GIT PULL 00/43] perf/core improvements and fixes Arnaldo Carvalho de Melo
2019-02-15  0:44 ` [PATCH 01/43] perf record: Implement --affinity=node|cpu option Arnaldo Carvalho de Melo
2019-02-15  0:44 ` [PATCH 02/43] perf cs-etm: Add proper header file for symbols Arnaldo Carvalho de Melo
2019-02-15  0:44 ` [PATCH 03/43] perf report: Add s390 diagnosic sampling descriptor size Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 04/43] perf vendor events power8: Cpi_breakdown & estimated_dcache_miss_cpi metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 05/43] perf vendor events power8: Dl1_reload, instruction_misses, l2_stats, lsu_rejects, memory & pteg_reloads metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 06/43] perf vendor events power8: Branch_prediction, latency, bus_stats, instruction_mix & instruction_stats metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 07/43] perf vendor events power8: Translaton & general metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 08/43] perf vendor events power9: Cpi_breakdown & estimated_dcache_miss_cpi metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 09/43] perf vendor events power9: Dl1_reloads, instruction_misses, l[23]_stats & pteg_reloads metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 10/43] perf vendor events power9: Branch_prediction, instruction_stats, latency, lsu_rejects, memory, prefetch & translation metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 11/43] perf vendor events power9: General metrics Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 12/43] perf utils: Silence "Couldn't synthesize bpf events" warning for EPERM Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 13/43] tools feature: Undef _GNU_SOURCE at the end of feature tests Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 14/43] perf beauty ioctl cmd: The 'fd' arg is signed Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 15/43] perf trace: Check if the 'fd' is negative when mapping it to pathname Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 16/43] perf beauty waitid options: Fix up prefix showing logic Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 17/43] tools build: Add -lrt to FEATURE_CHECK_LDFLAGS-libaio Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 18/43] perf trace: Filter out gnome-terminal* parent Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 19/43] perf coresight: Do not test for libopencsd by default Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 20/43] perf unwind: Do not put libunwind-{x86,aarch64} in FEATURE_TESTS_BASIC Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 21/43] tools build: Add test-reallocarray.c to test-all.c to fix the build Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 22/43] perf build: Add missing FEATURE_CHECK_LDFLAGS-libcrypto Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 23/43] perf cs-etm: Remove unused structure field "state" Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 24/43] perf cs-etm: Remove unused structure field "time" and "timestamp" Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 25/43] perf cs-etm: Fix wrong return values in error path Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 26/43] perf cs-etm: Introducing function cs_etm_decoder__init_dparams() Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 27/43] perf cs-etm: Fix memory leak in error path Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 28/43] perf cs-etm: Introducing function cs_etm__init_trace_params() Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 29/43] perf cs-etm: Fix erroneous comment Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 30/43] perf cs-etm: Cleaning up function cs_etm__alloc_queue() Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 31/43] perf cs-etm: Rethink kernel address initialisation Arnaldo Carvalho de Melo
2019-02-15  0:45 ` Arnaldo Carvalho de Melo [this message]
2019-02-15  0:45 ` [PATCH 33/43] perf cs-etm: Modularize main decoder function Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 34/43] perf cs-etm: Modularize main packet processing loop Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 35/43] perf cs-etm: Modularize auxtrace_buffer fetch function Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 36/43] perf tools: Compile perf with libperf-in.o instead of libperf.a Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 37/43] perf tools: Rename LIB_FILE to LIBPERF_A Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 38/43] perf tools: Rename build libperf to perf Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 39/43] perf tools: Fix legacy events symbol separator parsing Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 40/43] perf list: Display metric expressions for --details option Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 41/43] perf header: Get rid of write_it label Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 42/43] perf header: Remove unused 'cpu_nr' field from 'struct cpu_topo' Arnaldo Carvalho de Melo
2019-02-15  0:45 ` [PATCH 43/43] tools build feature sched_getcpu: Undef _GNU_SOURCE at the end Arnaldo Carvalho de Melo
2019-02-15  9:20 ` [GIT PULL 00/43] perf/core improvements and fixes Ingo Molnar

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=20190215004539.23571-33-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@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=linux-perf-users@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulose@arm.com \
    --cc=williams@redhat.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).