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

Function cs_etm__alloc_queue() should only be concerned with the allocation
of memory for the etmq and accompanying decoder.  Everything else should
be done in the calling function.

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

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 4cc9fce97a86..c9a5b4935209 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -405,8 +405,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address,
 	return len;
 }
 
-static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm,
-						unsigned int queue_nr)
+static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm)
 {
 	struct cs_etm_decoder_params d_params;
 	struct cs_etm_trace_params  *t_params = NULL;
@@ -444,12 +443,6 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm,
 	if (!etmq->event_buf)
 		goto out_free;
 
-	etmq->etm = etm;
-	etmq->queue_nr = queue_nr;
-	etmq->pid = -1;
-	etmq->tid = -1;
-	etmq->cpu = -1;
-
 	/* Use metadata to fill in trace parameters for trace decoder */
 	t_params = zalloc(sizeof(*t_params) * etm->num_cpu);
 
@@ -479,10 +472,6 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm,
 		goto out_free_decoder;
 
 	zfree(&t_params);
-
-	etmq->offset = 0;
-	etmq->period_instructions = 0;
-
 	return etmq;
 
 out_free_decoder:
@@ -503,24 +492,30 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm,
 			       struct auxtrace_queue *queue,
 			       unsigned int queue_nr)
 {
+	int ret = 0;
 	struct cs_etm_queue *etmq = queue->priv;
 
 	if (list_empty(&queue->head) || etmq)
-		return 0;
+		goto out;
 
-	etmq = cs_etm__alloc_queue(etm, queue_nr);
+	etmq = cs_etm__alloc_queue(etm);
 
-	if (!etmq)
-		return -ENOMEM;
+	if (!etmq) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	queue->priv = etmq;
-
-	if (queue->cpu != -1)
-		etmq->cpu = queue->cpu;
-
+	etmq->etm = etm;
+	etmq->queue_nr = queue_nr;
+	etmq->cpu = queue->cpu;
 	etmq->tid = queue->tid;
+	etmq->pid = -1;
+	etmq->offset = 0;
+	etmq->period_instructions = 0;
 
-	return 0;
+out:
+	return ret;
 }
 
 static int cs_etm__setup_queues(struct cs_etm_auxtrace *etm)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

Thread overview: 14+ 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-12 17:16 ` [PATCH 02/13] perf tools: Remove unused structure field "time" and "timestamp" Mathieu Poirier
2019-02-12 17:16 ` [PATCH 03/13] perf tools: Fix wrong return values in error path Mathieu Poirier
2019-02-12 17:16 ` [PATCH 04/13] perf tools: Introducing function cs_etm_decoder__init_dparams() Mathieu Poirier
2019-02-12 17:16 ` [PATCH 05/13] perf tools: Fix memory leak in error path Mathieu Poirier
2019-02-12 17:16 ` [PATCH 06/13] perf tools: Introducing function cs_etm__init_trace_params() Mathieu Poirier
2019-02-12 17:16 ` [PATCH 07/13] perf tools: Fix erroneous comment Mathieu Poirier
2019-02-12 17:16 ` Mathieu Poirier [this message]
2019-02-12 17:16 ` [PATCH 09/13] perf tools: Rethink kernel address initialisation Mathieu Poirier
2019-02-12 17:16 ` [PATCH 10/13] perf tools: Make cs_etm__run_decoder() queue independent Mathieu Poirier
2019-02-12 17:16 ` [PATCH 11/13] perf tools: Modularize main decoder function Mathieu Poirier
2019-02-12 17:16 ` [PATCH 12/13] perf tools: Modularize main packet processing loop Mathieu Poirier
2019-02-12 17:16 ` [PATCH 13/13] perf tools: Modularize auxtrace_buffer fetch function 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-9-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).