From patchwork Fri Feb 15 00:45:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 158461 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103781jaa; Thu, 14 Feb 2019 16:48:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IbwWHGpGHo3nSn+YCeLgHRyiL+mL/vVBy6b1SgIim9XnTcGtKIlEjfMncwDrNzakr2PJzS7 X-Received: by 2002:a62:c302:: with SMTP id v2mr7027975pfg.155.1550191682845; Thu, 14 Feb 2019 16:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191682; cv=none; d=google.com; s=arc-20160816; b=azd1R46zmDQGozhBeMXBNkiWyDiNOP28xIGh7SkRrW6rH8IGz78GElaGrDC2FkBM8X F3BR0OKQYMbby8vziammpDIqgydpI55C5SEsx6Nsh1fZIhBYo3kbz2qKk0kGVmBCJ807 e3NIxpiu7sNcRUN8IUSHF2q/76LYnCpMOS+l4ph4p8BCb/59pNWT92u5ZgBRFMN4n0C3 UnOfyVeaiterIFeJRit58rFlwDstX6g9sYr4hgJBfKjbvNNxIbEbCe48PVkTGy7Uovod 2ndutNDTB8WhZv25hFWL9j+iJDhIrBasAhnNeHa+IfECTFfgFLlq1lZ0+YtNtHyXt0qr +KfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ph6fdiVxcmW8XtXa5whDwKhP3LOHYplxekgagmVEN9k=; b=rB3CUPSBPTYk2hvHr0/w4jTGlv8UrkjJ2rEjP4687tdWQjBSL5Jt6xJxNtbZnQkRFY /cSKeUyNrN3RzaivbkLk9dtn0z1r6fEZgy2YhSAcF7Eg9oHCCBLbOF6FafG4rztD9aNg aPbcQjfOev4npB3TjLFc10rqby6wvcdmicfwkrbXp9y6PoiePta24bueGZ5hhzLxp30m mUNNiZ4ESLW8KqvU0jJmKCltlo7n8I8Sdi3PMFvDsa01on7CIPohNlpStWhA37Fy4xqw lkw1ZgqCxo48fQfkmMcwaJJjIAVQDOwVYPFwHAZ8kO48d4GQsJP66aj9VaU+j7bLsdMB SMxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LCnCLwLi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si3551428pgp.282.2019.02.14.16.48.02; Thu, 14 Feb 2019 16:48:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LCnCLwLi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389491AbfBOAsB (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:46950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389443AbfBOAsA (ORCPT ); Thu, 14 Feb 2019 19:48:00 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86E172229F; Fri, 15 Feb 2019 00:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191679; bh=T354beYzSKX9jaLyEiLMxRWSCwNVNXXElIwYhxrdRy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCnCLwLi4KMpA1TxI3aIASI4aE7Q2bPh3PLq1VM5GAH1Hgc0IDrMsE4aVdtVQNQw/ 1gpQBK6ykXxkVzCpuzxxcU3QkEaUrUDxtopneOK4wgEKjXYSueaUpdmV11gggPBYDF BPhkebYjCAiDVJlaIlYzMSCmW3T2ufey5py3gS9c= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 30/43] perf cs-etm: Cleaning up function cs_etm__alloc_queue() Date: Thu, 14 Feb 2019 21:45:26 -0300 Message-Id: <20190215004539.23571-31-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier 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 Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-9-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) -- 2.19.1 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)