From patchwork Tue Feb 12 17:16:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158176 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4090164jaa; Tue, 12 Feb 2019 09:17:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IY5zWdIKhAgO0qEfa/TmGmhnMuE1QSSAK6LYOQcBqbpXetjLTeBUH/Pwtc5YN7mcOmsnZR/ X-Received: by 2002:a17:902:b60e:: with SMTP id b14mr4831222pls.301.1549991863055; Tue, 12 Feb 2019 09:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991863; cv=none; d=google.com; s=arc-20160816; b=Y2AL5KWeRDIfoyws6u1xHDStL0Q/tZa9j1dazgFRbzo9VsTqSGJBVv7mB+bo3PzYEx UkKVi/G9LyVUPMxyJo2DU7tCnXxSmrwQ6QgweSmXhq01D/i756NvAu5JmdcYHxq06JOJ GiyAfbft0sCXhC63sw2Pqsn9/FHR/3dmZvQ0EcXDnG+rCwuBlUpFXt/1SQ8w0+8+SJ67 5iqk7JjiprVX9J0XZKmImDj18mSeXvHreL/vp+pGKkjlrfWVe0iZdf7wA9C+ZjkrtCsE fO1uQx36c7rGeytHTMcf8+tpQT0UcmhR3p1AnJivD78afuySvd0uIYXivmPSvswiWx6n 65iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=F3htzumhw0wsBNPb1jzbmXRsC9SD4nCo3kem2V3UyCY=; b=rEDdtzqGalUFh3mih/gZBafv2FBSXVTawHNhudrvMi+Bn5aFsrdGq1uxiKEDn226qe 97YE1ymrWVYzlWoKsxZz0dlYEtGoZKOzK4RySCJ0CUNmiH+ON+4+0mUy2PaPg1+60pMk IzvtslRH7LbVGniKDwbKeLcsZiryEINL6Pz4mZ6pZ304K4njr2oMilVebK0XAG069mQI DqOPtL4Dg82wUYwA44VH0vOi7I/skoz3Jj4NyU1Eev258WY3R6JIFS755OGA24D0i4Ka VHK6HJbd+z0Wh20RL/sV9cYaiOHqKq5xWHA/4GyLuVgZKTu6kX508BgcKp2tea6I9iEK XDgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EVKqyCWC; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si12635290pff.126.2019.02.12.09.17.42; Tue, 12 Feb 2019 09:17:43 -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=@linaro.org header.s=google header.b=EVKqyCWC; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730370AbfBLRRl (ORCPT + 31 others); Tue, 12 Feb 2019 12:17:41 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35512 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731734AbfBLRQW (ORCPT ); Tue, 12 Feb 2019 12:16:22 -0500 Received: by mail-pg1-f194.google.com with SMTP id s198so1555750pgs.2 for ; Tue, 12 Feb 2019 09:16:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F3htzumhw0wsBNPb1jzbmXRsC9SD4nCo3kem2V3UyCY=; b=EVKqyCWCkFmsCIw/cwaM55FNXGvjvtuhlkDhHlLuPyeOPf1jNJCvsyST22FJeP3N08 SaUxsMOgtm6P50sL15JMmR15PmSkCrH7Rttno88S5ejE67CA5y6fcMGBHTgku9Qvoldn 6LHz6eMcW4WrUw+DLg2ZzIZX7HE3TADx1uCL/CAwi7l7OolGwnyBVPQLc58u51PjOREH j09tKlsRce7Blh6xjKlly0m9P2mkNaI0jIfNrVusW8yp/oJGh184U583VnC1fFtUtlGE l+U+UiptDpUXCrhGP5Dkj4MK8dEzNwss8XtKGp9yE+5xMLnzlv0bxS4HsJFkAnp4orIa m2Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F3htzumhw0wsBNPb1jzbmXRsC9SD4nCo3kem2V3UyCY=; b=S1d3kSd8fVziToUiiMZkLvYB0EjTu0IUF9xdDZaYImzaL55Cys2H/jUcYyx6iHcdM7 j53y5k8Juv8qW0g3ph3RroeTLWi4B2hU7X+mPgOA/ieFCtTGGtcfNNqboPhUob3k5jbQ Vzg/T96AViy/f1QAc7dJwinT1QNdZ4rMszKGnV55pfsdoqSohKSXL7tUdo/yS4ZZxlM8 Pa1x60pl/8aYZgeLY60jJlejjLJZC1ZySIA+uE0Z81v0wfinBYuqS0O4ZRN7JPyygQ0T 62TlYlwszbq02JzDqW5fPgxdhEFTu7w/RjPI7Gw35bhIiPxcF1TGYn3lxG0h0q8j6uG3 OnXw== X-Gm-Message-State: AHQUAubAxphw9SPh8ySSeSGIahvIGE6N+fmZKPGc/IkAXToz4qCKkbaR OErFjGjV2eLf79SIEtwA+Nf5LQ== X-Received: by 2002:a63:cc4e:: with SMTP id q14mr4499520pgi.291.1549991781471; Tue, 12 Feb 2019 09:16:21 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:20 -0800 (PST) From: Mathieu Poirier 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 01/13] perf tools: Remove unused structure field "state" Date: Tue, 12 Feb 2019 10:16:06 -0700 Message-Id: <20190212171618.25355-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Field "state" in structure cs_etm_queue is no longer used and needs to be removed. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 1 - 1 file changed, 1 deletion(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 0b11d653cfbe..ebd68eb43da9 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -65,7 +65,6 @@ struct cs_etm_queue { struct thread *thread; struct cs_etm_decoder *decoder; struct auxtrace_buffer *buffer; - const struct cs_etm_state *state; union perf_event *event_buf; unsigned int queue_nr; pid_t pid, tid; From patchwork Tue Feb 12 17:16:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158164 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4088743jaa; Tue, 12 Feb 2019 09:16:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IYhxDIUG1xlri3WSrzZwLExcrmZt33ddzyv0XTsupBoPf/oRciJBPuzS+44EG5ZPOyxQeaw X-Received: by 2002:a62:1049:: with SMTP id y70mr4943494pfi.220.1549991786792; Tue, 12 Feb 2019 09:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991786; cv=none; d=google.com; s=arc-20160816; b=EX2031hvXKDWiOH26O30LUCDChODb5JMBQ+mZD+eCv3BLa8HT/VcizOQJUFHXHc9XI HvmJffcEDecfqbnLH6CXq+st+cpfI92zKD8i5O1rJPriD49cHQUIXJg/XO1/6/kQQ97q gsHtds9Z59dqLEOIPzewDpFQOrbPnTN/v7vgjGEVD8teJEHZgkSchKIcfsYZP+3m3Fl1 2JxGBcJx4dn+Uuk2YwxZFLXApf8MSrbt4HmAiZjtMHT656O5SzlNci0Ece4jLyNaqmpp dQwvyeaPgWHQegwZi9C9mZtkKS8WjnnJk6zQLbOWTe+d/A3oaqPM4mtT7AQpxX5oxUGm JOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=VCeE+fVe6sOPfIScwVf+tBPxTH5OVWtBxrO1s0RcHJI=; b=wPPprZwf8ZGJFOzP3poUrYP3LKbomzPKHKl0Z/Le0bq0+e6uO02eBMFeVHI/MUInou pt1U3DfXmmrd49JoEzXDD3XQ7KnOzJskDltGFGgTjZcZCvlQNZdDrF8HXcwR5KugILbL 6oCiBWoUOVDP/H7WjMExULLByLpmvTtYHb0A5I5n4ZnbXTKZqS2YH6cxAqNhfaa0/9U2 KDRaIh+2OG9I4c2pejOwo/geEYF5qAbzNQcUCD1RyaC9uwhU5jPnZZCm/hzYjX07Hv5+ DsIwlloujLkqjj8/j/NRnY5g95TC7f+rSN+pg1NlBA173mg7xdl7TMrqZhMSDbNI1tfg /uKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IakIojWr; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e92si955949plb.152.2019.02.12.09.16.26; Tue, 12 Feb 2019 09:16:26 -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=@linaro.org header.s=google header.b=IakIojWr; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731762AbfBLRQZ (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:25 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42943 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729211AbfBLRQX (ORCPT ); Tue, 12 Feb 2019 12:16:23 -0500 Received: by mail-pf1-f194.google.com with SMTP id n74so1586772pfi.9 for ; Tue, 12 Feb 2019 09:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VCeE+fVe6sOPfIScwVf+tBPxTH5OVWtBxrO1s0RcHJI=; b=IakIojWrVhLLuunKXwwN4iY4XDiT0UcS3/3wk8jIMBLxEkKEYFPIytjPBl0G/M45oy eAkA1XwPou7P12w14qY2H2PWiXTxCEJALNrYPPwQfbxobxcLs5Jnzcm87oyN0A4u4v7A pX1gg3cbtN6KNoA+2Mw5Vl1BYGpEX8vnqUpJV210HchPYaPVmu9/q/2ld8MuGtyCrBJv uDLQpBy386ikkiecyTPEkggRObY58Y2aX+2rMKEuOg8a2WO1EtUSzZKVmfoVvXpLy1zt oyR/VaKnp9BlTMDaFcKTA8FgbrGEErj/v/rpVce3Q8YThiGHpj2Gk0nbfxshcVp+imC3 jWIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VCeE+fVe6sOPfIScwVf+tBPxTH5OVWtBxrO1s0RcHJI=; b=fkCpQ0V0gtj9fmAxCfTjGupy3rW1gjt8/nngAcHp6IO4gqlBHJaiXlfocxY9sl2z2v uG3kvu9Js1cletf0UifokkLkwV/gFMAUy3fMesn1qPplwvWZWSWWDfx7gYTnPo0f4ujD Thm5z49onasvh9hGbDvc1ZWvp1VAaWMF/jZJIGfNlo/dmLDUVlKqMbVVdf6wf9HzeToW sRl5KJEM9CNJ1oB3vTSPexHRKz94VY45PtP7OfepBJqK7i5A9Ri0l0xLUJyLTrh53CUo U+wWp70ZkbekTrDnZ+QylXiWx6pTgmkeIWiNuFprSFYTS4edecY2tzscNO6qzhS1PFD+ JmdA== X-Gm-Message-State: AHQUAub/xWe5xQYkCwPsjxsbtc9GESUHON8W+L3egWdPpNoXQTMRnVJm sHvaJ4dDICDmzJPDe6AWUTlHdw== X-Received: by 2002:a65:6491:: with SMTP id e17mr4540223pgv.418.1549991782641; Tue, 12 Feb 2019 09:16:22 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:22 -0800 (PST) From: Mathieu Poirier 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 02/13] perf tools: Remove unused structure field "time" and "timestamp" Date: Tue, 12 Feb 2019 10:16:07 -0700 Message-Id: <20190212171618.25355-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Field "time" and "timestamp" in structure cs_etm_queue are no longer used and need to be removed. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ebd68eb43da9..1d9419a0cf0c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -69,8 +69,6 @@ struct cs_etm_queue { unsigned int queue_nr; pid_t pid, tid; int cpu; - u64 time; - u64 timestamp; u64 offset; u64 period_instructions; struct branch_stack *last_branch; @@ -82,7 +80,7 @@ struct cs_etm_queue { static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, - pid_t tid, u64 time_); + pid_t tid); /* PTMs ETMIDR [11:8] set to b0011 */ #define ETMIDR_PTM_VERSION 0x00000300 @@ -234,7 +232,7 @@ static int cs_etm__flush_events(struct perf_session *session, if (ret < 0) return ret; - return cs_etm__process_timeless_queues(etm, -1, MAX_TIMESTAMP - 1); + return cs_etm__process_timeless_queues(etm, -1); } static void cs_etm__free_queue(void *priv) @@ -1583,7 +1581,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) } static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, - pid_t tid, u64 time_) + pid_t tid) { unsigned int i; struct auxtrace_queues *queues = &etm->queues; @@ -1593,7 +1591,6 @@ static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, struct cs_etm_queue *etmq = queue->priv; if (etmq && ((tid == -1) || (etmq->tid == tid))) { - etmq->time = time_; cs_etm__set_pid_tid_cpu(etm, queue); cs_etm__run_decoder(etmq); } @@ -1637,8 +1634,7 @@ static int cs_etm__process_event(struct perf_session *session, if (event->header.type == PERF_RECORD_EXIT) return cs_etm__process_timeless_queues(etm, - event->fork.tid, - sample->time); + event->fork.tid); return 0; } From patchwork Tue Feb 12 17:16:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158175 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4090057jaa; Tue, 12 Feb 2019 09:17:36 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibs+eNlmIYYv9m6SvhdrVXHjPSLzEOAkPE2ujdmblIoZCyVzAf9nOuVuDQKxxWSe98r1jOb X-Received: by 2002:a17:902:bc89:: with SMTP id bb9mr5053148plb.212.1549991856850; Tue, 12 Feb 2019 09:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991856; cv=none; d=google.com; s=arc-20160816; b=fsOW+4FB1/NkutPa3ggha8QsTk/0zJ07brGkqZvyFhs5wqq7WqNChnedf50OEsi/+z wUV3QMQvMKLFdAJtwqIJx9JoSSstIqTgDTeNIH2WFu/1xkBrZUYqdYtWZYVbXSNqERmM F9GMaAVj4KeeslKX59Lce9riGmEKnwv7Ga+Xeu6N50hwsE3M2cesmEGeMLoMch2UA2RZ tNenjospT52qT6pTC1GiBW6YQmM74EOJNMXaTKwOGglTsazCmTiDp8XqdKw6eBDZEVxg ErTGnca2Mv2itDlN7FOme63RZgfcvkS0AN31Lhuxp8Yx6stAbAhyLU3UmE0Ewdd7hx/m PicQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=/lnWMMCIsg4/tFUsl2j1cd75JRahCaG7A5ViWQnd0OY=; b=R9iGPFRV7xX1jf7qJuCN5fWTIodfziD1wJLTRcBwpNyArArwUxNgBAMoyerrvMherc d9m8GZ67jGqe/bueBQRtnOpDcO/jAXl6Y+DgqvfWfyYTkhx9DiFMJMf+Ea+m3iAdmgFl dY8kFcIZ9msCam0wIuy06Yugd/cbtDU3OuaiIWRG9gyfZ2uzq7qWCTksn4x6Gxmn/cGi nmnd9jDc5eWk0/FiORzU51NxLDehyciOUMklSGhBZE66UohPyvhJGH7rfumdWnYMQJz2 o9w9AGJ8s8fFr2A4KFKvQXyH5qCbeYka3OpIJazs7Qc4itze33MLVovGsjiACsd0b1qC dmIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvD3sPQV; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si13168746plt.69.2019.02.12.09.17.36; Tue, 12 Feb 2019 09:17:36 -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=@linaro.org header.s=google header.b=nvD3sPQV; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730240AbfBLRRe (ORCPT + 31 others); Tue, 12 Feb 2019 12:17:34 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45128 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729807AbfBLRQY (ORCPT ); Tue, 12 Feb 2019 12:16:24 -0500 Received: by mail-pl1-f193.google.com with SMTP id r14so1584407pls.12 for ; Tue, 12 Feb 2019 09:16:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/lnWMMCIsg4/tFUsl2j1cd75JRahCaG7A5ViWQnd0OY=; b=nvD3sPQVTmPup1RY7P6dkHQg3RQbopWaNl2R7n0ekAHhDAV5NE/q69+aIzpOmXe6XU IcwLyhmnoL2lS90lSvUSI/ta9vrDvlC1/Ub3O/uynQAv0zL3YY+dqzL2GZ3Yw8m49APy +OzEmV3koMukBg5tYr/x0HFN3dTnYQuSOy0JH9M2qBzjO9DMzqagpMDhG/GBa8f247iQ gAz0RJOK0D+R30EfucoL6waUOOzflugJpiWEJATPoMRo61FvUY8AnX9CnnQWTuAYsnN6 SZfaOJBeasDCJpcvhKRJYeqCXl7sKm7S+utqmOCNtl5qcQqPoucR/aXS4Zu03+DOsAYY v19g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/lnWMMCIsg4/tFUsl2j1cd75JRahCaG7A5ViWQnd0OY=; b=PLXTjCX5HiBX3/3i2mJYdJvxGC2WjXNc2qyfvVIB/KGVxPF8GOFiTUj0bWG2fOE2WI RIZbxYhpEVD82FWiW/S3d2aNeinZ8dfZ6YMHpoq2r1i8JMWxqs9C5Xr8eUuCHEYni63R LOW3H8kMAQJvmfHGE3lBrwxRlcEoKFvCtUPs03J5JX5iMuoo4VfKUIAy0P8aMb4JTpcQ tm2b+q4r9/ubeZo4P27Ar3mK1fAuL7v2HGUL6WXRjlT79AF9Sg4BWaMmzLJg6hN0Tf8z HJgn2044WGfwDrrutC19QYD/naw1PIdbni1fx136Hzm3rwmY5IWdvqS24LDRMcLyDHlz h14Q== X-Gm-Message-State: AHQUAub/Z8+vcdgoDFJM4TDAJ5n34ddT0YkmDIq5QfqjlPvok3Ik1rZd aE+76zbCOImofkJgA9/PcUpngg== X-Received: by 2002:a17:902:9884:: with SMTP id s4mr4777634plp.1.1549991783804; Tue, 12 Feb 2019 09:16:23 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:23 -0800 (PST) From: Mathieu Poirier 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 03/13] perf tools: Fix wrong return values in error path Date: Tue, 12 Feb 2019 10:16:08 -0700 Message-Id: <20190212171618.25355-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function cs_etm__mem_access() is supposed to return a u32 but the error path returns negative values at a couple of places, something that really throws off the clients using it. Fix the situation by return '0'. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 1d9419a0cf0c..f396fee9bb95 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -324,7 +324,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, struct addr_location al; if (!etmq) - return -1; + return 0; machine = etmq->etm->machine; cpumode = cs_etm__cpu_mode(etmq, address); @@ -332,7 +332,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, thread = etmq->thread; if (!thread) { if (cpumode != PERF_RECORD_MISC_KERNEL) - return -EINVAL; + return 0; thread = etmq->etm->unknown_thread; } From patchwork Tue Feb 12 17:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158174 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089891jaa; Tue, 12 Feb 2019 09:17:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IZHAJy9h7twxdio7G5XQuzuTb6gY9opiYetCgXc++Y6Jn/KAiDdfHRbV3EEUuSa24FO60YN X-Received: by 2002:aa7:8847:: with SMTP id k7mr4835600pfo.99.1549991846978; Tue, 12 Feb 2019 09:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991846; cv=none; d=google.com; s=arc-20160816; b=ttbsZyeuPoq00CDCLEVSYACLBZDmILq9sE4Dj6stSw3KmNLFpLqpWncMTpHmwP7sXF SDu5ptvP2hCpF5rKMgR53MilhcOBV1j7375a0RGlIdnf4z2F0D3oiMlUOp+7cXa15f2z JT0w61WCVlAtYcYkt40DHw1qzlJ0IIVNwF0FRVlA+z3skep+y4h4FRph9UbzdG1IAnBF bUXDxK6TzKmU6z/B9oS8w8AywptQorj0WLNN3x/h7gSmrTH1L4TrYDkxap4ntxdBk9X0 lEhL61MYkGxWiQhr5g/v+wOI5Mv9GGFXO0r+6xhAH6J7KyCi20gV9zLPhlPS1cW/rNKq Y+hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=d25EPOQ1/eL3uzzHkP0zLvCcnfX2yAd0t0DIGDfrgSI=; b=pMcsODMMb2lRh+r9BIXklDV5cRE1caJYMJmk1PniBCIkgU6jWRoA8/6ZsBoW5MT05p lDCAu9hITUu/f0JOiz2SsZPfgqWwD42GI8R721jfyZbhIZngH1z+edc61pOJKMa8dZ2h /+l8VAmdQSAhb6aU5hLqnX4pW+3esppFlWnrXUTUbhROFymEmg6VU4LjIR+46WVCklpz Y/94uzyKpWWxWZAAOxYHPZTqaUFhca8OAcSl2MTvwebRzkoi36/bhsDBMiND60tuspRk l3oAV/uf5cQzQRY5dN4mSd/hmfKsSTxv5MwG658ZOz3OYZzZLVeCwf9NIkmgaDhLkndC 5ztA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GGgVP5XA; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si13168746plt.69.2019.02.12.09.17.26; Tue, 12 Feb 2019 09:17:26 -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=@linaro.org header.s=google header.b=GGgVP5XA; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731779AbfBLRQ1 (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:27 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41250 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731754AbfBLRQZ (ORCPT ); Tue, 12 Feb 2019 12:16:25 -0500 Received: by mail-pf1-f195.google.com with SMTP id b7so1588535pfi.8 for ; Tue, 12 Feb 2019 09:16:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d25EPOQ1/eL3uzzHkP0zLvCcnfX2yAd0t0DIGDfrgSI=; b=GGgVP5XANqmy0QCTFX14LkYAMfmmOgC+GSwRJVdBwgg6qA4U2J3nPYCMpJGBUMLBVO AZjG/MNQ8hDEjiDqMc7REehUZAAgXjHgdwvn4fXZQBpb9MdarapyjHATTQXqIs06Nsd1 JVUaQwcXhP4Pv2xCAH2lxRHrSk8Y4Zz11CLrPNGi0OlsW+5NPA0p+g2vmRqCG6N+qZma YPwbgX4eLoebY3fTdh+IAgE/6DPaR4VghWMZQQGyfFuRAtxiz6+FTYVtN8V3qkjN3WXT yrtFDXN/BLx2dMOn7AmYBNMTUtdUTr3iaOmhWqKyLCZdyJSnWFKfNRhIvjFRC6om8a9c 7igw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d25EPOQ1/eL3uzzHkP0zLvCcnfX2yAd0t0DIGDfrgSI=; b=D8W8dDGJyKlCiRegYMISW82oDiNZ5hJ4sbPWIV0YnD46VRf6V0g2U6uDI5NzJgQCuS 5MPPVl69dxBMyM6FDeZ09fQH60vYX6t0b1YBM6dTfAC5dJ0p0rh5hrz9Tzxou9tbVLfn NPs2O0D7OA4Ec+qWPl24lsRT+VNdpSAOY5k1atRtD0i27gaQIgPE+rOvTJSDWE+MwbMH 58HPp4aLyTfyCbOP8auLhAkO2jcqEsC/YIKP9KJuNvH/u6LPeyQfcpIEgKfOwd4lFjs9 XkSKW1qLAz/oxiDVaBe/WJHkq1O6Jkbm9s5KQB9G99GW5zQAtpj4kD886ukNXuGy7wiO 1j5A== X-Gm-Message-State: AHQUAuZkLGa7liFdZk4Ybekgl8eQs3eauxZZs4BTbO1Ro4D624LZpsaW 90BK2kDxEBrFHq50XlE9z9fyjQ== X-Received: by 2002:aa7:808a:: with SMTP id v10mr5037856pff.8.1549991784951; Tue, 12 Feb 2019 09:16:24 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:24 -0800 (PST) From: Mathieu Poirier 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 04/13] perf tools: Introducing function cs_etm_decoder__init_dparams() Date: Tue, 12 Feb 2019 10:16:09 -0700 Message-Id: <20190212171618.25355-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introducing function cs_etm_decoder__init_dparams() to avoid repeating code at two different places. Signed-off-by: Mathieu Poirier --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 3 +- tools/perf/util/cs-etm.c | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.17.1 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 7e6a8850be4a..663309486784 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -105,9 +105,10 @@ enum { CS_ETM_PROTO_PTM, }; -enum { +enum cs_etm_decoder_operation { CS_ETM_OPERATION_PRINT = 1, CS_ETM_OPERATION_DECODE, + CS_ETM_OPERATION_MAX, }; int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f396fee9bb95..3011c6cae531 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -136,6 +136,28 @@ static void cs_etm__packet_dump(const char *pkt_string) fflush(stdout); } +static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, + struct cs_etm_queue *etmq, + enum cs_etm_decoder_operation mode) +{ + int ret = -EINVAL; + + if (!(mode < CS_ETM_OPERATION_MAX)) + goto out; + + d_params->packet_printer = cs_etm__packet_dump; + d_params->operation = mode; + d_params->data = etmq; + d_params->formatted = true; + d_params->fsyncs = false; + d_params->hsyncs = false; + d_params->frame_aligned = true; + + ret = 0; +out: + return ret; +} + static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, struct auxtrace_buffer *buffer) { @@ -182,12 +204,9 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_PRINT; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; + if (cs_etm__init_decoder_params(&d_params, NULL, + CS_ETM_OPERATION_PRINT)) + return; decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); @@ -436,13 +455,9 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_DECODE; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; - d_params.data = etmq; + if (cs_etm__init_decoder_params(&d_params, etmq, + CS_ETM_OPERATION_DECODE)) + goto out_free; etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); From patchwork Tue Feb 12 17:16:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158165 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4088819jaa; Tue, 12 Feb 2019 09:16:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IZWttK3xq1dmwBgmhS/DI3VkYAv2H4x6OSKZLNo34rlARdrvF88rMXv9CGYbOxyYuC0gJye X-Received: by 2002:a63:ce08:: with SMTP id y8mr4501882pgf.388.1549991791341; Tue, 12 Feb 2019 09:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991791; cv=none; d=google.com; s=arc-20160816; b=wM4JBV0EJ2f7o7NlXPB9x7iHF3c+xNWegR2XeJhWvP7dHTEUmAWVRrnr3ccxNpsanX MuU0z0FKJrDwlrzk2CksNfYj/a1xXso/GcxXYoPHwm9x3Bw1IxLpo10af+Cgx3sQZkZ9 V5j7YS8z1mBSNm95lzibzSQM/KOzz/GCtmC+G2T8YxESA/BDi8gf3IwjkOCwy/RNa+5M 5wdg4nt2rwv5xJ284Y0szsvaxp3o8MqxVceSpaidHkHo1RD/1Dak9p4KmO9S4fOUTv6n 5kKcwBI0wmYZF0TzR2ghqGzYPs4LL0suMCZKUxcZxTOnhyJ/xku2VjYokSglX8+HCxmM LCSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=V0vDEzF3Mc5eeutz94nbRQZ6xPyugJQXobqfjuLKiSM=; b=H6ZGBa3XZcATsM5NPnUxaA4TWxF4TjIj8Mis3u0o9UpOo5yActWplEyFEhTfsMLzsu vSOa2BloDpX/S8S4yJuus/521dPVzCi22vA6BWdrTGKPpoNkMqiOPR4KYCVCiF4TSQST MGeu5rxi+2aT/08m9BkrDODw45tG1IqqT/nL5uq17PHT/v74BQkAISHluEoBmyHKr5c8 rZHWCdplNdUTB6GWDAixmzFC1ibKRpf/EgoQd7rJtPXlMc+VL7W8mKwsDO6wGDws5xje l/QSkPU6Ii9L4yKkkPaXyA+6u+X9n1TdeTmfQJvp6vW0jb2tNl4t1aBnmC+v1zhSt7LL agPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cObDZdMv; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b136si7238277pfb.165.2019.02.12.09.16.30; Tue, 12 Feb 2019 09:16:31 -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=@linaro.org header.s=google header.b=cObDZdMv; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731791AbfBLRQ3 (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:29 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40365 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731767AbfBLRQ1 (ORCPT ); Tue, 12 Feb 2019 12:16:27 -0500 Received: by mail-pf1-f195.google.com with SMTP id h1so1589538pfo.7 for ; Tue, 12 Feb 2019 09:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V0vDEzF3Mc5eeutz94nbRQZ6xPyugJQXobqfjuLKiSM=; b=cObDZdMvnlT9QoWFKtK5J0NH3yLnZBykk0W6O6czUdQ/wYALlhy+/89BGrRGgozWdD M9OBesQ2ZbzZmMEKzL3X5eFzKAfw5RToYyZFRGIjd7UT8ljdT3ekmZ0Up6mcbVozjiEL DRIx4WCIZNObHIFFf1/umNJU1yic69+R5q6hOLr5lBKjoZbkhQRA/D5TOqyaHIGld3P0 8GHrzUVTDPRgUxbcQ1vy63emJiAy7J9y22QOVf8fiOd/y9RtvBtd4uP88uwaPSFIQjzZ +IOKPHt++r1IAu+P5vmeWCbjTOrYh7HW/LAof8xPoCWlwi7DRfpbGyGAjn1nMIBgh2Md TFGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V0vDEzF3Mc5eeutz94nbRQZ6xPyugJQXobqfjuLKiSM=; b=ZYXMxD35uy1peE/1EFJOj01XBPWhD+f07fKQ1JUydo9kyFzPm78sP/yUGbdpPpffw3 onWjVmILE8nG5IZWTOXACPM3OAlQBsGILbUZ+OvIgnO6ifX+TKVBI8wuzPEZHIVKbKQc 9dcwmbq6RVYu12fty4YDpCRnsXHUxu0mXqEyP9LBUeT1ToMxewet6FKZW72LgiTQO3yR LUflvfV2R1OgTROXUHYU70sl+D2EyhZdlrktc38ugW31IKc/YiZkQCy7m1x6GbLO07uc tC3nxHZItV56GwZ6oNVK2uNo/kZPSKzw0f/kLWHWg/boooOuaoJIJKYz2MeyPPqvN0JT I1VA== X-Gm-Message-State: AHQUAuZ1zg5UItwFsaCRV7pMy3KaLEuqqRVlscWEDwQ/9XgRiVeYKBFI hYzVCqcW1o6tEDZ7RzTfwgsHxoshASI= X-Received: by 2002:a63:c345:: with SMTP id e5mr4571313pgd.103.1549991786088; Tue, 12 Feb 2019 09:16:26 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:25 -0800 (PST) From: Mathieu Poirier 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 05/13] perf tools: Fix memory leak in error path Date: Tue, 12 Feb 2019 10:16:10 -0700 Message-Id: <20190212171618.25355-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memory allocated for variable 't_params' isn't released properly in the error path of function cs_etm_queue *cs_etm__alloc_queue() and cs_etm__dump_event(), something this patch addresses. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 3011c6cae531..aac07f950074 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -175,6 +175,10 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, /* Use metadata to fill in trace parameters for trace decoder */ t_params = zalloc(sizeof(*t_params) * etm->num_cpu); + + if (!t_params) + return; + for (i = 0; i < etm->num_cpu; i++) { if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; @@ -206,14 +210,12 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, /* Set decoder parameters to simply print the trace packets */ if (cs_etm__init_decoder_params(&d_params, NULL, CS_ETM_OPERATION_PRINT)) - return; + goto out_free; decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); - zfree(&t_params); - if (!decoder) - return; + goto out_free; do { size_t consumed; @@ -228,6 +230,9 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, } while (buffer_used < buffer->size); cs_etm_decoder__free(decoder); + +out_free: + zfree(&t_params); } static int cs_etm__flush_events(struct perf_session *session, @@ -379,7 +384,7 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, { int i; struct cs_etm_decoder_params d_params; - struct cs_etm_trace_params *t_params; + struct cs_etm_trace_params *t_params = NULL; struct cs_etm_queue *etmq; size_t szp = sizeof(struct cs_etm_packet); @@ -461,8 +466,6 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); - zfree(&t_params); - if (!etmq->decoder) goto out_free; @@ -475,6 +478,8 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, cs_etm__mem_access)) goto out_free_decoder; + zfree(&t_params); + etmq->offset = 0; etmq->period_instructions = 0; @@ -483,6 +488,7 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, out_free_decoder: cs_etm_decoder__free(etmq->decoder); out_free: + zfree(&t_params); zfree(&etmq->event_buf); zfree(&etmq->last_branch); zfree(&etmq->last_branch_rb); From patchwork Tue Feb 12 17:16:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158172 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089714jaa; Tue, 12 Feb 2019 09:17:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IbuO5pk8B0UyvIcc14F0dDYnhR0Jp4ZMZ0iTkXSzszpoGdrLOWoEkMTeOIQpNkI53+lJDPE X-Received: by 2002:a62:4b11:: with SMTP id y17mr5058066pfa.124.1549991836860; Tue, 12 Feb 2019 09:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991836; cv=none; d=google.com; s=arc-20160816; b=I2j/i3LTPpLKRIBPtBlLoy9CWyY2KFJXIZotMSEUXZpR6v5eM50rWpFEP+4xSutn5E 4Luo+kYzyvkuIhGJALKkPxn/eN6OWu7GIll7MUF/FtEKIQFQIQLP2s8Z0OZUVwiDYf83 S+fk6ZAiPlwrfH0ofGX+vV6Q1WF+ujicsQZLRWv6gCLUUX42J2sFY8S5R6f8qARpGJic N4DJWTN1ibZfwlTuqOjWWMnb1k1KbM6jvvKnRrPBDRg57ZSdtPfEjaDgdz8ib233pt3j Qgaki8W5rBr/9wX6geM1anYS6JXAuiM0eYue6VhA9wfaL8UvlpZ0EWw5jsNOfpqyBe4d wv1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qBtfkm7Aoo/feOhhrqKL+o79kVL9oAED5/pempgClW0=; b=VPg9N2m7vRFTXYoaYQTInJszyBmY7sltBpJww/YJ0azxtlDRk1EQ/lvdnGavOxOtB6 vnGoUG0OH4DU3+lm02V80Nw8HL7kq1NF2scfucC2GXRRwQRJhQCmnzg5ofNK/lvY0Zys vcY6eY1hAE1yHWRqYvJdeL5zVuaM821360+jZDos1sK5g14J/XRWJtWjVF39TEC730/z V9f16INkXcA/pEDYEB17ose8nmjMutGCD2p88T+LEiy0TYIfx9CeXVINuI5i/3KrxZl9 1jqhzGuPXKCR2bXLiXUVrXWVsoKkYub8qJwsb78BXW3TWWiNchSsS2KBdYiNr9NCqQ+6 TYWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YNW+frnJ; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b30si14474078pla.285.2019.02.12.09.17.16; Tue, 12 Feb 2019 09:17:16 -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=@linaro.org header.s=google header.b=YNW+frnJ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731874AbfBLRRO (ORCPT + 31 others); Tue, 12 Feb 2019 12:17:14 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34539 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731775AbfBLRQ2 (ORCPT ); Tue, 12 Feb 2019 12:16:28 -0500 Received: by mail-pg1-f194.google.com with SMTP id i130so1289820pgd.1 for ; Tue, 12 Feb 2019 09:16:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qBtfkm7Aoo/feOhhrqKL+o79kVL9oAED5/pempgClW0=; b=YNW+frnJ9THIpOHeaU5fgArgePOQEKFlNjaVyZRq0kxYox0+IOtEf1dCefvA8AmCe9 5dKqrLcEfHG+PRAOLifcCHs3cwveSA61uCPiKajFcdbUVxtU1U5dAwbJv1+qZmPzvIBq 6yc5gCOluL9Qxj3150ZCPfilXEHNoqEE2opjz/4ziZO1c9Ol6X+oNS34Fu6KguY7ueWh 6j4ga0u9X6w3sPPPvg6dGIS2+CJu1755RNqQz3tVECFkRT8UwPIPb5WopG1ORVZDiIrt mxR74coqJuZcQjGMj3dTLjMfMaMRHc9eDwgaUawrTWU7qfHNBBHL+vUpPQzOOTvHGG1R LLvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qBtfkm7Aoo/feOhhrqKL+o79kVL9oAED5/pempgClW0=; b=XmvXqa/3NQZFgmktv5EJcjZrw2m56IDpngpyYVH5STcjzBmhWN1smV/e6G7krw3kZj pBoRfaXd2x6N9HbcqFRipR5KkS/DoI/Cf+FZKgyOeedHBJeGo7+SDCL7ML4gXY6S5axn mDte9mNnl8q5SKeCbEq3T7cvESTjOG2FaT2ekTwPoUQ6/w/GCiRzF5k8kEwrf8WkBAl8 jr8TvI/wg6IMFOOtrk4qROxiW/T9RlqE/HbBA5JJRiSZgwZPlg6+dGXcbF6wdWLLzXMH NCc8kxR+JlGQ8LzIFhIBysFfiD7R6XuaWn1ncwVvBvbEy6FC1o2nwUVzg+yN2njbEpJW o/7w== X-Gm-Message-State: AHQUAuYf2J7uSp2YNsTlbIv0E7I+XvB1edaChvqdtXlvYacThGp8yrOc VDCRb02C9HKoo8B5hsbaZw9xM+ccaEs= X-Received: by 2002:a62:7086:: with SMTP id l128mr4957980pfc.68.1549991787247; Tue, 12 Feb 2019 09:16:27 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:26 -0800 (PST) From: Mathieu Poirier 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 06/13] perf tools: Introducing function cs_etm__init_trace_params() Date: Tue, 12 Feb 2019 10:16:11 -0700 Message-Id: <20190212171618.25355-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The trace parameter initialisation code is repeated in two different places, something that bloats the file and can lead to errors. This is fixed by introducing a helper function and calling the right protocol initialisation code when required. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 112 +++++++++++++++++++-------------------- tools/perf/util/cs-etm.h | 4 +- 2 files changed, 58 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index aac07f950074..f3a6dfaf3026 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -136,6 +136,57 @@ static void cs_etm__packet_dump(const char *pkt_string) fflush(stdout); } +static void cs_etm__set_trace_param_etmv3(struct cs_etm_trace_params *t_params, + struct cs_etm_auxtrace *etm, int idx, + u32 etmidr) +{ + u64 **metadata = etm->metadata; + + t_params[idx].protocol = cs_etm__get_v7_protocol_version(etmidr); + t_params[idx].etmv3.reg_ctrl = metadata[idx][CS_ETM_ETMCR]; + t_params[idx].etmv3.reg_trc_id = metadata[idx][CS_ETM_ETMTRACEIDR]; +} + +static void cs_etm__set_trace_param_etmv4(struct cs_etm_trace_params *t_params, + struct cs_etm_auxtrace *etm, int idx) +{ + u64 **metadata = etm->metadata; + + t_params[idx].protocol = CS_ETM_PROTO_ETMV4i; + t_params[idx].etmv4.reg_idr0 = metadata[idx][CS_ETMV4_TRCIDR0]; + t_params[idx].etmv4.reg_idr1 = metadata[idx][CS_ETMV4_TRCIDR1]; + t_params[idx].etmv4.reg_idr2 = metadata[idx][CS_ETMV4_TRCIDR2]; + t_params[idx].etmv4.reg_idr8 = metadata[idx][CS_ETMV4_TRCIDR8]; + t_params[idx].etmv4.reg_configr = metadata[idx][CS_ETMV4_TRCCONFIGR]; + t_params[idx].etmv4.reg_traceidr = metadata[idx][CS_ETMV4_TRCTRACEIDR]; +} + +static int cs_etm__init_trace_params(struct cs_etm_trace_params *t_params, + struct cs_etm_auxtrace *etm) +{ + int i; + u32 etmidr; + u64 architecture; + + for (i = 0; i < etm->num_cpu; i++) { + architecture = etm->metadata[i][CS_ETM_MAGIC]; + + switch (architecture) { + case __perf_cs_etmv3_magic: + etmidr = etm->metadata[i][CS_ETM_ETMIDR]; + cs_etm__set_trace_param_etmv3(t_params, etm, i, etmidr); + break; + case __perf_cs_etmv4_magic: + cs_etm__set_trace_param_etmv4(t_params, etm, i); + break; + default: + return -EINVAL; + } + } + + return 0; +} + static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, struct cs_etm_queue *etmq, enum cs_etm_decoder_operation mode) @@ -161,7 +212,7 @@ static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, struct auxtrace_buffer *buffer) { - int i, ret; + int ret; const char *color = PERF_COLOR_BLUE; struct cs_etm_decoder_params d_params; struct cs_etm_trace_params *t_params; @@ -179,33 +230,8 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, if (!t_params) return; - for (i = 0; i < etm->num_cpu; i++) { - if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; - - t_params[i].protocol = - cs_etm__get_v7_protocol_version(etmidr); - t_params[i].etmv3.reg_ctrl = - etm->metadata[i][CS_ETM_ETMCR]; - t_params[i].etmv3.reg_trc_id = - etm->metadata[i][CS_ETM_ETMTRACEIDR]; - } else if (etm->metadata[i][CS_ETM_MAGIC] == - __perf_cs_etmv4_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV4i; - t_params[i].etmv4.reg_idr0 = - etm->metadata[i][CS_ETMV4_TRCIDR0]; - t_params[i].etmv4.reg_idr1 = - etm->metadata[i][CS_ETMV4_TRCIDR1]; - t_params[i].etmv4.reg_idr2 = - etm->metadata[i][CS_ETMV4_TRCIDR2]; - t_params[i].etmv4.reg_idr8 = - etm->metadata[i][CS_ETMV4_TRCIDR8]; - t_params[i].etmv4.reg_configr = - etm->metadata[i][CS_ETMV4_TRCCONFIGR]; - t_params[i].etmv4.reg_traceidr = - etm->metadata[i][CS_ETMV4_TRCTRACEIDR]; - } - } + if (cs_etm__init_trace_params(t_params, etm)) + goto out_free; /* Set decoder parameters to simply print the trace packets */ if (cs_etm__init_decoder_params(&d_params, NULL, @@ -382,7 +408,6 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, unsigned int queue_nr) { - int i; struct cs_etm_decoder_params d_params; struct cs_etm_trace_params *t_params = NULL; struct cs_etm_queue *etmq; @@ -431,33 +456,8 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, if (!t_params) goto out_free; - for (i = 0; i < etm->num_cpu; i++) { - if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; - - t_params[i].protocol = - cs_etm__get_v7_protocol_version(etmidr); - t_params[i].etmv3.reg_ctrl = - etm->metadata[i][CS_ETM_ETMCR]; - t_params[i].etmv3.reg_trc_id = - etm->metadata[i][CS_ETM_ETMTRACEIDR]; - } else if (etm->metadata[i][CS_ETM_MAGIC] == - __perf_cs_etmv4_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV4i; - t_params[i].etmv4.reg_idr0 = - etm->metadata[i][CS_ETMV4_TRCIDR0]; - t_params[i].etmv4.reg_idr1 = - etm->metadata[i][CS_ETMV4_TRCIDR1]; - t_params[i].etmv4.reg_idr2 = - etm->metadata[i][CS_ETMV4_TRCIDR2]; - t_params[i].etmv4.reg_idr8 = - etm->metadata[i][CS_ETMV4_TRCIDR8]; - t_params[i].etmv4.reg_configr = - etm->metadata[i][CS_ETMV4_TRCCONFIGR]; - t_params[i].etmv4.reg_traceidr = - etm->metadata[i][CS_ETMV4_TRCTRACEIDR]; - } - } + if (cs_etm__init_trace_params(t_params, etm)) + goto out_free; /* Set decoder parameters to simply print the trace packets */ if (cs_etm__init_decoder_params(&d_params, etmq, diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index d76126e0e3d0..0e97c196147a 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -105,8 +105,8 @@ struct intlist *traceid_list; #define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64)) -static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL; -static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL; +#define __perf_cs_etmv3_magic 0x3030303030303030ULL +#define __perf_cs_etmv4_magic 0x4040404040404040ULL #define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64)) #define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64)) From patchwork Tue Feb 12 17:16:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158173 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089788jaa; Tue, 12 Feb 2019 09:17:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IYwJ/PM1PzmdGa3vCKRVO9VRzKuc2Nxn/2fFf4YjLWPR56D42oOE8A1jH3AjHI/C4QPVD+0 X-Received: by 2002:a63:1647:: with SMTP id 7mr4539317pgw.53.1549991841992; Tue, 12 Feb 2019 09:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991841; cv=none; d=google.com; s=arc-20160816; b=ljz1neYh7OrU7MFVuRbLLvunqX/FbH5hWuILOI8WTmIZKBSnmj9TL85dB0yiik89Vo m4HYfOqdfLnjkFX56bqmfZbJXe4mXoLQAE5LjiYM9afAxlB5+EDZgBMfD5dWPA6v89pl KxEXiVdfujTStofXNMF0e1c4lY6Q1d6yA3myDNP7eItNIgBWEjlenmM2rxWnDCkqnGUU 0KS1IxxAN65sBDywYsMHTDULR7Ht2TBGoe8fixngPZg4iis61Chq8Sqeityn9a+SHhz0 gxy9FQoxJEtTyDF0ztv+KFS8sRNJ9IMupZx+bkdJ5/Z/W+2HhBBdT/p6KXgIFgSyc/LQ gTMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=XOTxqo9OH5aLAc5Vxl6Hirh4+uNIGwOwzNR9lCBfbZ0=; b=ItO35+AUFvmDT8hpyHRR3Lb2fFNDy86WKC+6RVrz2BL3kHaPR8N0/4wG22eO/oW8A3 pglKKYWOE+2i6JLSt67WeOoFEIlheyaljIupmaedHyBpLIz+sCgo5pWEp4KEg2SGMyCi 3Sz9J8f1Wa4NmlFf181NxzSqOkvwJnauA/G6gvQcZZaSkM/M4DX4VjsN4MDviAfgOAPr /iUbgLgk30ycPvco83GnvIrUd5cJauKxtafq2gMgJKKU4Z//aCzjbkBbD4lXuR8VBk58 0Eonui6u6z6CtBachYwZKf+FNyI2T+13tWgx6rUAS3IzB6zP7BNvCmC/YGvBkJ/LwFs+ HAoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TzyNQMny; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b30si14474078pla.285.2019.02.12.09.17.21; Tue, 12 Feb 2019 09:17:21 -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=@linaro.org header.s=google header.b=TzyNQMny; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731862AbfBLRRN (ORCPT + 31 others); Tue, 12 Feb 2019 12:17:13 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43075 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731784AbfBLRQ3 (ORCPT ); Tue, 12 Feb 2019 12:16:29 -0500 Received: by mail-pf1-f194.google.com with SMTP id q17so1587065pfh.10 for ; Tue, 12 Feb 2019 09:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XOTxqo9OH5aLAc5Vxl6Hirh4+uNIGwOwzNR9lCBfbZ0=; b=TzyNQMnyrMRx6Y03GfKuRDaDoyBCPgxtVbwbn+yIjf7NIdqbElgGSzg2CYYQ6OGLh6 XvT6xAW3yQT5YqEcw9iqBEU1XZOVLOHM5SLE5L+exa1VCE8dkm9fXvMhg4sC+V2QJi/A 5CuG2AOCjjHGJ2Ok8wXOC1QVlS7gYQq5frcZWTEMtLrUNh59UpMJ8zTJ6EiFQUu5L+Ce TE58F/dufPL/i3irM2lthKRkJhcMTrRx2eoxQ8w/a39eMxcfKiKzRIND7iyZzVA+xYum UXQbZq17Mz4stq7GIvAvkgRke/Wtr2TF9/BhRb8bWwoPblOIT6MFE2hoIv3s7U9K2nME VgMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XOTxqo9OH5aLAc5Vxl6Hirh4+uNIGwOwzNR9lCBfbZ0=; b=LNzz3zstUe5XHNXA7LUAknu5i4xivwny5XondDhgGftx7TMOvGven+cKP4U3UYK/tJ 0LFMElCZtyGQjZBZCKJngIylXkk9yFFcOpMTg37/nWVY1VlUEIWu8AZAGixKlo6D+Msb CT5XZhBwpc7J9LTLxqtFaFbkUdE6FfQUEHEMJGgwG0D7VXxvV5BiBULdfv5MJAUPSXbc 6ogd2nZ0SLD/TTjOhOwzGq7L8nz1SjAR2GEzSjdpMEaQLb0rB1c0VAvICweUBEnMWo1B f+LooGEHQpfbCl4tzO1/Diq1Sjd7jk5PLM6NJPx3WQyelXqPhgUMvmbn7NbK/wMlxESl N2cQ== X-Gm-Message-State: AHQUAubtLAiCUm4/+q8olvq6rHoFGiroQPTbxCdWE0CaeTqQC7LH9pjX bZdI5xwNlnnK40ChvfxjkmoiNw== X-Received: by 2002:a63:a:: with SMTP id 10mr4523207pga.121.1549991788408; Tue, 12 Feb 2019 09:16:28 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:27 -0800 (PST) From: Mathieu Poirier 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 07/13] perf tools: Fix erroneous comment Date: Tue, 12 Feb 2019 10:16:12 -0700 Message-Id: <20190212171618.25355-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The comment just before initialising the decoder is plane wrong since it is part of the decoding queue setup function and the operation code specifically mention that trace data is to be decoded rather than printed out. This patch simply fix the comment to prevent people from getting really confused. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f3a6dfaf3026..4cc9fce97a86 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -459,7 +459,7 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, if (cs_etm__init_trace_params(t_params, etm)) goto out_free; - /* Set decoder parameters to simply print the trace packets */ + /* Set decoder parameters to decode trace packets */ if (cs_etm__init_decoder_params(&d_params, etmq, CS_ETM_OPERATION_DECODE)) goto out_free; From patchwork Tue Feb 12 17:16:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158171 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089552jaa; Tue, 12 Feb 2019 09:17:07 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib0tASvzN0gOJIromB1z/8IfAx5qkR20hXNdxpzzBGPFpnWM5H0Q1WG42sPF8bLi9X90Q1E X-Received: by 2002:a17:902:fa2:: with SMTP id 31mr5030635plz.75.1549991827781; Tue, 12 Feb 2019 09:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991827; cv=none; d=google.com; s=arc-20160816; b=jDD43WwYWVVA7kGjeBmaUnU+miihsrEVX694fDHV6yQg0LgsDcXRuedmFEHggpvlWE +vun4tm+hcVvM8eMwZeHxvDJAdEnmG9aEzbbcydMp4CuZCMobl5jYbIiDI2Wcy+6KY84 zt3aOu2wP7VPviVZ9JjPHv6FTVDuYavCL+F8mDl6Uo2QdLWmCXpYU4kpwUDuDYBBY/+b J5IVgz2mB7P4f+6aykBxSnC8TlgTk/IlI3WsVaA1oAFfL9ldTaB2dCHq70fzyG8WjwsV ZBvx0i3o8tqbZ9DHdGvSHTXedmooQjqCBpPnaggBpvFPCutO9RvdM675H1fnvVoDIWgE m75w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=+oNal5RstQ3YgpTY86Id5Pbgg+JpmJKHh+fQyKrDyG0=; b=XDpszrAzBE/vDahXg21IkXYI/Mgr5HyJ5jhZPug201ncFck7tasgqiL7VCjohfieDE YBE+P47ebT7gvAxAciRVLL/3TuLkYldf37Z3/6BUccqR2yMcNi8BAAt5DmwTlJwSogDs PXkebr9zAoB0xUGPvpTGxJe1V5v+0MNtiSUctTRN+zVsjUjjBKs7qbA+N1YXnQJSGzzu p66Mfe91CTYyCc3wqz4GAoK6JufJ3kkZCHy594KN22Y+UlUoeIJhj0uo0GP6Pfl2xo7z 0jaAQKnqgV9NEAjEWNSpgSZ+L3uvkATZrxehzz4lfYK/dnd7evUz1IRtmRRsC655YwMr 1zTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q+p+weP6; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si9980746plo.435.2019.02.12.09.17.06; Tue, 12 Feb 2019 09:17:07 -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=@linaro.org header.s=google header.b=Q+p+weP6; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731856AbfBLRRF (ORCPT + 31 others); Tue, 12 Feb 2019 12:17:05 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46551 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731792AbfBLRQa (ORCPT ); Tue, 12 Feb 2019 12:16:30 -0500 Received: by mail-pf1-f196.google.com with SMTP id g6so1576396pfh.13 for ; Tue, 12 Feb 2019 09:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+oNal5RstQ3YgpTY86Id5Pbgg+JpmJKHh+fQyKrDyG0=; b=Q+p+weP6kUGU7tzqY8/EauId7g4FmWlr24ilDKPKxgWckBycZcn62SX1aYAakhrvKl EU8uVaZezJhjYnlXKr8Xrd8N4mRuXMpf9oTz+R1x9TKN0zVI+Rj5wx2F7ySlvozeGlEz pQRLTS+UFyARG9yLiPEqEDuLtSrRXFVKUkFouKMYFkI79JeiA+JpIFU0xPb3TkHAQE97 AuLbZOXkWItJBL4mP7/tiVWHEzSX8x1m1+Pg4Faieyd/LdmydSzjI+XwY9qlr7VSHXJp biACrsYOC4i0nvCD4972EwbxVtlHOZiz0ISWdlAMJiUJg+CV5vsgMLBCB1YY7ya0KddX b3KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+oNal5RstQ3YgpTY86Id5Pbgg+JpmJKHh+fQyKrDyG0=; b=aUYwp7eFlm98dlq7M4Q6LZix059YALDM9dWwIZHSvB5KbkaMP51AiM4p2obzc1FTVy RTdThWRmemQmD0bgz0Q/lIZ90rqRTes9oPpb+fTlghuST08XDAF25n+a5Pb3ad9nZD4q 7zDRs82H7LGoWmGVuwTrd1PlZ7LnMSwAhj1CBlW19J2MxdYT6m1OaHG8Tf6L2vwiPKML kp2tSFJKstArtWlO77GQ/wD0Bs+0uKPFAujw/daAAenfImuu8SB1/7maEZYdzEA/z7da UVgHEltJWzGrX5VLqMu25mtC1U/Upk+xaefR/6qkENmIRRjNZIVHZJq6nYnD9zwuW4wO PXZg== X-Gm-Message-State: AHQUAuZt7N20KJP9vgx7pWaAOffubmzbwX5wTkTsaK2V3PAl8uEuG8kw ZBj8fuF2jXfYnxcy6pHA6xVh0g== X-Received: by 2002:a63:574e:: with SMTP id h14mr4369440pgm.336.1549991789518; Tue, 12 Feb 2019 09:16:29 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:28 -0800 (PST) From: Mathieu Poirier 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 08/13] perf tools: Cleaning up function cs_etm__alloc_queue() Date: Tue, 12 Feb 2019 10:16:13 -0700 Message-Id: <20190212171618.25355-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- tools/perf/util/cs-etm.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) -- 2.17.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) From patchwork Tue Feb 12 17:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158170 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089438jaa; Tue, 12 Feb 2019 09:17:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IbHxg2UdUoZR87KQK0yGvg4cIrGPohXUZfGJodaycNhQ6r4VFAZVHJZEdbJG1hKy7l+BqPJ X-Received: by 2002:a17:902:bd8e:: with SMTP id q14mr5017273pls.153.1549991822027; Tue, 12 Feb 2019 09:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991822; cv=none; d=google.com; s=arc-20160816; b=rg0VdFVLEV4GO1zjPOqSpSqh5OlljwUKRuxoqSTn0rk8i9SWZgjTenbH/tRv4Aj6fr FL/se4yGADdSmh73SNiNt1E5tOMGVnvuE8jHHpP6TjT2cL2J+vgGMFMkcg1P2WLCJ3Nd 493GLtOiAOWGFURsFJRNIuDn/SuzZr6865KjKHbCSrsk6Db7mFuy4XSs+Vm/GRrP+HhG qhu5b1qdyDDc3OOe4+7E8fMszJm7RgXTFpgB9f3aK2zcoaseidF7EgC9DLwOh4mtrnmt jD78o2kFrygbuXBBO0Xwy1UvjxVczPP7lPc6lo2WrBXR7PSk6Os1nry9BtPwYLyytheS U6bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=AqOVPM1vkj1BcrdjSYH7HyHM4JuITQIO8J2Q0BieCKs=; b=w9bvT33AGE3XeED4FQfUuglGUm+qWyEJq17zxxfVOcdDDo4soAQxK0jWLjKH7gtILm qpPeZmYLMOZId6kycuitz02V4al4ZHtpp5WbFffc2Lufq1yAjojo4BPJ/+osjp33U10h 399+hTT8ajF9Fhn5m84TJs1OBMlpmNcdeLGxsz48pSE8mOFWUKkPyOMWITz813P/pQDH lBgAhwhc0eJqyPjN16upIjw1c+EnrYkxLEbHLZIBN59DcjAd5Ls2oni8alS5q7KLYPPq 6kWANxIs8C1DmVBGCdhvq5QsUTMUkPr1EMRk/YhG/8X+oQU3/vxYzFKzOZb0TdkeqoN5 LTIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EaEbAYCm; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si1201394plp.380.2019.02.12.09.17.01; Tue, 12 Feb 2019 09:17: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=@linaro.org header.s=google header.b=EaEbAYCm; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731835AbfBLRRA (ORCPT + 31 others); Tue, 12 Feb 2019 12:17:00 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36447 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731798AbfBLRQb (ORCPT ); Tue, 12 Feb 2019 12:16:31 -0500 Received: by mail-pg1-f195.google.com with SMTP id r124so1553163pgr.3 for ; Tue, 12 Feb 2019 09:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AqOVPM1vkj1BcrdjSYH7HyHM4JuITQIO8J2Q0BieCKs=; b=EaEbAYCmXtoB46vY9L0sicfUIQl51y7gdkSivvKVXdgCulNJFy3rGyTHCYw7FsdztW QGbtQdVdQ13XLwiDeCegaCUYqUOonZlJklzCrQiXmv2hbBnsOncAyHpuLQoc94IU+Onn czV39rUvqxM5LG6U0m+E8kVYtgyZYcp/y3zVaoXoQOhxH9v3cwHLwpZOtCNUXn1hDe7Q feyHanRxoQyS9Tx+fZNEnxHxy9AQkwaoWGR1RwmvOF+wmhHcr/zvF0Z1ls4anxSBBLym o6aTw29G7Ml/Zs47lwpeNF4q7LNXMppTazLo9qyWW7rKkAtdOK9lbbEkScHamCX3nDnr /2mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AqOVPM1vkj1BcrdjSYH7HyHM4JuITQIO8J2Q0BieCKs=; b=ahuhOOySDKkhI4WZZ2jhanPAh2dfoNvuTlyue29mj7BGmk2xPKUNHjzPf7iycczRHa Q3DvM5l+eIbMLAAI0a1AZiWsxElNRZtHZ0IhFLXPHv4sivErCAlaxkgz8JGsBr0AtbZF KUTE/Jg1kDZ87U2EmnCv6/nlRjglzSUYRxpGdguQEkgXKN9fMLHCSzhtMEfZlb51jvm+ l8434habZc+Y5oyCqARtFroYMVMuiQtGMCNPzKTdAQj2Say8J0SETjTQ92mX3kgQ6Dau ioXVRBur6fDiE2kKdDKnos1pF+/oTHCnYJZiBwYO7l4QkZ5K3yoxb3sVoj8Xpxup8nkq GVbg== X-Gm-Message-State: AHQUAuZrAelVQK2leM1fHEr/Ke1sLxeK0JMgveYAIz25TuCXtUfpVxkd yJQ+dDByUaeHF6+aJwvpMD+Q/Q== X-Received: by 2002:a63:2ccd:: with SMTP id s196mr4551020pgs.194.1549991790712; Tue, 12 Feb 2019 09:16:30 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:30 -0800 (PST) From: Mathieu Poirier 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 09/13] perf tools: Rethink kernel address initialisation Date: Tue, 12 Feb 2019 10:16:14 -0700 Message-Id: <20190212171618.25355-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving initialisation of the kernel start address to function cs_etm__setup_queues(), considered to be the common denominator for queue initialisation. That way we don't have to repeat the same code at different places. No change of functionatlity is introduced by this patch. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c9a5b4935209..2d2de898ea68 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -523,6 +523,9 @@ static int cs_etm__setup_queues(struct cs_etm_auxtrace *etm) unsigned int i; int ret; + if (!etm->kernel_start) + etm->kernel_start = machine__kernel_start(etm->machine); + for (i = 0; i < etm->queues.nr_queues; i++) { ret = cs_etm__setup_queue(etm, &etm->queues.queue_array[i], i); if (ret) @@ -1490,14 +1493,10 @@ 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_auxtrace *etm = etmq->etm; struct cs_etm_buffer buffer; size_t buffer_used, processed; int err = 0; - if (!etm->kernel_start) - etm->kernel_start = machine__kernel_start(etm->machine); - /* Go through each buffer in the queue and decode them one by one */ while (1) { buffer_used = 0; From patchwork Tue Feb 12 17:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158166 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089091jaa; Tue, 12 Feb 2019 09:16:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IYRa8BK5VUAVbB24lkSkzUdUaucKcG958tj0ohxMN9LsIUUTQTR1OD6qg9Yusl/G3Y2U2za X-Received: by 2002:a63:da14:: with SMTP id c20mr4371731pgh.233.1549991804578; Tue, 12 Feb 2019 09:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991804; cv=none; d=google.com; s=arc-20160816; b=fo396zfdns2QXHrfAA8D6GwGBbChM0A95kN+rUT55GWhQurffazUqp88l9mBzTktSV Zn2UJiLfHODURoedWIKnPHWnFewa250q3uLCVdRLjUbS+WK0vsg5dFVGREduDsUgB9IV f6qipmE9ML/3ju8vYcmYi5hdosdOVawHSGVI69KHi51AK2WsuGCGKgrtnq0zPiTYSTcH e7EsD77ZUSJ8Hw50TMTI3LhZ4afRTOvDSpVuN6T2dhwVqJDL7CBgX+AnbloY5iJniIEk ztq9jl7VW1bfCrFXe+Uf/4N8j6Iy96Dux2ukFW/YcUx+0JpoQGeoX0CRujE4GXkt63Kg RmHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=meZtkgH5cImMXR3ybdUTFzkYUQz8/L+H84Qg8MqCSA8=; b=MwMM9+oKndVpM1CMDtWbhIH+8fHBYFWjwnMTIijTEU8gaeHNgAlXYUHvukoQRvvS+p YLyE5dKWqVZ9BHfsbQm+Tis/cfvMqjeT9mQZEp4R0gSCW3Vbsr/0k3wJBXaFZPW9Guoc fkZllzIl2ICoNdGEk4LjwyrwPjadrmBFMUkRolpeP5XS1eM+C1Tssafh8YAyHiJ4Yfai rncoOFlm8StrYOt5Xm/edvD4hu2OlBWpfjBLwgNt0m3Pp3tDwjJhG5dW305fqjtS3Cdl 3CbLWr1tyBRlEqVYvVgE/UmamRh7xPoxN/ARuw8yjHwBThrhZfj3u3KzpHIFi0gltZi6 kglA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vZHvAcXJ; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y129si5007421pgy.175.2019.02.12.09.16.44; Tue, 12 Feb 2019 09:16:44 -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=@linaro.org header.s=google header.b=vZHvAcXJ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731816AbfBLRQe (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36447 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbfBLRQc (ORCPT ); Tue, 12 Feb 2019 12:16:32 -0500 Received: by mail-pg1-f194.google.com with SMTP id r124so1553181pgr.3 for ; Tue, 12 Feb 2019 09:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=meZtkgH5cImMXR3ybdUTFzkYUQz8/L+H84Qg8MqCSA8=; b=vZHvAcXJnsp/c3UfnpJh7hvmSVO5hZHPN6EpPFaiOWcnOQmgxR7mLYnW75CQa53EnQ vuu6iE04ioKMlJDDQcYK3AZwSqRDDiSQBxxswQ1YhBLtQKa6lzArcVmEnm7VXHBmruwH nIvOg7cAj4baH4AcnnsLs6p8mKRRNUvhOlL8TIZJW+cFd/EZed0AxwURN1HmmOaQJatq rwmQGoqcjGQg5VwGmD2/T1PDnixaIBOtVs6pdg/BKgpnw0qMcPFdx5KSbXp9sYvSnCse GV2AQBr3RzU8ZsqSryLfKUs64aSYFXEVgKhb74xJkAebcBLbsKEdK+Dy9EvV2jl4dqHT /bgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=meZtkgH5cImMXR3ybdUTFzkYUQz8/L+H84Qg8MqCSA8=; b=VFLrte2qcq4YwwJ/OqXbGaIsPayFFuhd1meZmyCTNGVY+jQtQe880XYGCKpqFUwquo k9mp5FqEe5LbMKkWB82h+qfXojHB3YNUom1yqu8SmO3B1iYU9jZ9UbXnlX+S76d6GroH fzP6FO4+1V7KxElQJ6vYxeXTv4DgFWBRyMpziaOPyQTaSdfMGzraU4iodiuc8VeqMHZ8 Jc5gelvY6gudv0nY5P6WEKRClHSmq/9hv7sEWKTjxShy/6ZsOitpuFDVRcSGo5/mCYqH AmR15K7NVZw+BZ9nIqS2LIWO2PW9Gk2ASFKFrxIx87AniqoujufioImhY2pbNWghTE1W cHrg== X-Gm-Message-State: AHQUAubCvi/0+FM8s3FoovFYfo50VVzp/+1lpinj+XygqJuaFlAOItPI W2wCeZVc2bOXcwgla/KA/Yj4ZA== X-Received: by 2002:a63:4611:: with SMTP id t17mr4526538pga.119.1549991791818; Tue, 12 Feb 2019 09:16:31 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:31 -0800 (PST) From: Mathieu Poirier 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 10/13] perf tools: Make cs_etm__run_decoder() queue independent Date: Tue, 12 Feb 2019 10:16:15 -0700 Message-Id: <20190212171618.25355-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 7 --- tools/perf/util/cs-etm.c | 52 +++++++++---------- 2 files changed, 26 insertions(+), 33 deletions(-) -- 2.17.1 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 */ From patchwork Tue Feb 12 17:16:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158169 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089294jaa; Tue, 12 Feb 2019 09:16:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IaTDU5nrcPtQKU3ywVfK9v9YR6J6j0z+wxrE7AiXMUPbU7neoHNstrSoSxfLcc9BGxyT+kj X-Received: by 2002:aa7:800c:: with SMTP id j12mr5078028pfi.183.1549991814603; Tue, 12 Feb 2019 09:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991814; cv=none; d=google.com; s=arc-20160816; b=TPh7v2mktZXRi8E/DuGiPqVfFs+RoA7hBA8keYcYYi4iNvGbNv6zBWL8ty6j4BZ+Hq Lp7mFgCGchqR6CHVRPcUOXEx6SOg4emhxwV25JmkodkBhy/aCrqACwUy0XiwvRCgRhxM IjHI48fEyD5C1+4cDjNA2cowu3x/jTp0+lcyQuf6b78ttEjMAmJ/mkuVjwN7ac4vrd5m ns+wdHw7NwxFYID3QWRT7Xl013SxXyABh8jjZtJ6LSWjd+k8ovCh1ByQbq5q7xw7j7Nw /a4uhlK0iphTAALxA8e68zhHN7pM5rA/A5KOt7+/AiaWODWWqGj+W8pfYplpMRDABSBW duWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=/UH8SrTya5tl/qVTuklo7mGBNz+HUAk8Fnba3ZSHvA4=; b=JmO9mh7QFo+HVJaxELL/vNNZY8moX9nvsBZii8S4TozHTeefIrDAVqmJQ49ShuLt/n 1QBr1FOe0wePL4umd+6yK6stvRjVtSrUesziYMPw37fKMHR5RqfzHKJB7OORnGeDpem9 EGZSWLn6eMm2bEwg8uHOHSnCJcq/gJkvihDEBI1PGnDtC9CoDA3FIGbxFp/dV4Ruv5KZ zXg3SuKONtYcd5NvyVOSy5MT9kG0wVyn7yKp4j6Cnv1/CQgmD9sUEw11e5VlQC2sC6uv uo7+R780IwXxQs/cAl2Q7TUrKeatDfYZR7cLk6NmJ5augQesJj5ozgvG6kTBnqgfOxQY CeiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wYgl3NNS; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si1201394plp.380.2019.02.12.09.16.53; Tue, 12 Feb 2019 09:16:54 -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=@linaro.org header.s=google header.b=wYgl3NNS; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730400AbfBLRQw (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:52 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37206 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731772AbfBLRQd (ORCPT ); Tue, 12 Feb 2019 12:16:33 -0500 Received: by mail-pg1-f194.google.com with SMTP id q206so1550559pgq.4 for ; Tue, 12 Feb 2019 09:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/UH8SrTya5tl/qVTuklo7mGBNz+HUAk8Fnba3ZSHvA4=; b=wYgl3NNS2JG8qwab9R9cIm8sIzbImuxDxN/dEDQKbHn/IZUxPZN4CrrHj/nYcEJ1/t k6e8vUwg3Q0MY2UCkeCKEZg7zsYkRBA2GJ/GuRjwOXc+MOl7EPcEu9AF4GivB6xj1c5J mupsEFF7+AIvSu5UrKasfzWJNwMa8+63ZiNnzfSRhKi/FW+EdOUavkb+s4OD64ZPCMiM 5NUe4upIhs3RiQ3XivQgnTPmmHYasY7g7hJK2AjoCngqbQJkJWPcX8w9OZg7pC2omM7a m7NepYWwAZAaY/CQ3wcCKiqWx8J6WGI0cZs+qudK88BiSlBpZiW9/OtU8z6SyKjWL+63 Tk2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/UH8SrTya5tl/qVTuklo7mGBNz+HUAk8Fnba3ZSHvA4=; b=ZUfKI4Ca6Onrud2lZ8jT+rHg5aKWQkTAsh5OB6eQlS1t8F1TGssb0dHJWYFApReWBJ zPtGloDjBw1rt2d7NQvVqKIP4HXoPNPWbfB9KECPQpDxdDf+6VQJJ29IqcwD55nYX7iS Gv23bwz3a5LSpdMwScOqhQgXMZlJJO8uPf90rxCrilhKploZYPDgfjUGZNtgviCsQzF2 04uIYp0HDvh2UmhJ+cEES4fCn/dquJXleiv1RwhhX8pAAxzd/gsoMzawV8pxPhqrwBdL Ip3a64P9h+KH9Wgfox4IwukWsw2tmk4uyLxxLDFD2bFPLX32HYBitC+WffLES/ec8PYj mVIg== X-Gm-Message-State: AHQUAuYLslN6cRju0H0OSpdC91TCbUiP+dW0D6t98Tfx/q9rqoaoSkbZ 9OmQdSljMmmg9gZYo6ac/xvm+g== X-Received: by 2002:a65:514c:: with SMTP id g12mr4481382pgq.169.1549991792926; Tue, 12 Feb 2019 09:16:32 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:32 -0800 (PST) From: Mathieu Poirier 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 11/13] perf tools: Modularize main decoder function Date: Tue, 12 Feb 2019 10:16:16 -0700 Message-Id: <20190212171618.25355-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making the main decoder block 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 --- tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d2c90b369e7c..cfa686fe223e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1491,9 +1491,36 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) return 0; } +static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) +{ + int ret = 0; + size_t processed = 0; + + /* + * Packets are decoded and added to the decoder's packet queue + * until the decoder packet processing callback has requested that + * processing stops or there is nothing left in the buffer. Normal + * operations that stop processing are a timestamp packet or a full + * decoder buffer queue. + */ + ret = cs_etm_decoder__process_data_block(etmq->decoder, + etmq->offset, + &etmq->buf[etmq->buf_used], + etmq->buf_len, + &processed); + if (ret) + goto out; + + etmq->offset += processed; + etmq->buf_used += processed; + etmq->buf_len -= processed; + +out: + return ret; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { - size_t processed; int err = 0; /* Go through each buffer in the queue and decode them one by one */ @@ -1513,20 +1540,10 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) /* Run trace decoder until buffer consumed or end of trace */ do { - processed = 0; - err = cs_etm_decoder__process_data_block( - etmq->decoder, - etmq->offset, - &etmq->buf[etmq->buf_used], - etmq->buf_len, - &processed); + err = cs_etm__decode_data_block(etmq); if (err) return err; - etmq->offset += processed; - etmq->buf_used += processed; - etmq->buf_len -= processed; - /* Process each packet in this chunk */ while (1) { err = cs_etm_decoder__get_packet(etmq->decoder, From patchwork Tue Feb 12 17:16:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158167 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089105jaa; Tue, 12 Feb 2019 09:16:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IZCvAscDmo0gg4H3H4bZYLAGDPPVjAEl0EAY5wk7r/kxoTzM/ihTcBrx/HHgqXQNgB7+cal X-Received: by 2002:a63:2882:: with SMTP id o124mr4578667pgo.446.1549991805113; Tue, 12 Feb 2019 09:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991805; cv=none; d=google.com; s=arc-20160816; b=017u/AuYhB8aY9QDMirlvE9ah5LNqGkRpsjF5wzIJLzvDY3s4xnNCrzUMJ7j34W2gv +0+4YhnB2nvbRAGCwKGX9ELxQnCNE2d1baSiq+TOfpP3ZgkURzeNBqQV7hScIyIdSYNX +FEFWPw1HdjJ0hwGjBoOGfCUKg8UkM7LdRPcZ+FzcRR4TreS74WpAGshDaawZjf4FSjk vHN0f7HgZ1fbr/4OOFdATWshhAyqPOFJrIKcV3VBxdFYcraPu9jVj+nJBenC5i3duteE 6DjJitLb3eZKRP6JotY/bqopQ/W4aKa4qRrbdLh81kOkAXQqphysqw0DtyLU1YtwTFr8 k8EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=fPu8+x56+bPaqE+Kt7QPAly49dZ2m5zcnSswTAaxNxU=; b=ly6+zd3Y1136w+Zqh5MYjN2ayWMn8mvhd5F+9Hb9LFyyoWwI0g4HcVgvi9tOMFdakU kjGNiVmFGEPMAf2gZwSbtPxRQirSib8mZtHgzn0ke09f6vYt4TSaNdd4SDOtqe+bgYjt 7W5R0fhVIIvRgiespiMkhn5vYNG3/3m8f30Sz7GslXLH2eg+NyNBglak/004rb/hPr5t 7znXlYJzpkESPkva93s7fjfWzKJZVRdu/OUtPUAhIv+2zzmRnHJEuvc8W4AUoqBboY3u VR6+h6wgvstIEBj4ChqnV9Yx+pohBidfYK76e1Y+QCSRdbtZlqzWLfRmjfeXjTimIQFH JGXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wmd0f4y5; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y129si5007421pgy.175.2019.02.12.09.16.44; Tue, 12 Feb 2019 09:16:45 -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=@linaro.org header.s=google header.b=Wmd0f4y5; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731827AbfBLRQg (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:36 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43210 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731813AbfBLRQe (ORCPT ); Tue, 12 Feb 2019 12:16:34 -0500 Received: by mail-pl1-f196.google.com with SMTP id f90so1596881plb.10 for ; Tue, 12 Feb 2019 09:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fPu8+x56+bPaqE+Kt7QPAly49dZ2m5zcnSswTAaxNxU=; b=Wmd0f4y5WvxofS4IIk+dxekor1GLWA5HfI5d997lyaW20uM6gGnPRhTpEjUcN2xYhr XfdDxPEaxyvelxa9DuAKy+wIo/vZZXq5kpL1aYRyrWfV2R2NLEnU3R0f8BYjGKjBalFu U5tjNeJbUVnHwuZ1O1gYT6Bam1FmRP7Njaye9A9CZ/Rjqv4k1fuxD4afpTgcz4afOgIp 1VV9aLv2+tEQQS8my2EHZp70eY4gYPJ1GF55AQUfHhVMlknG0upE1pWRsv0dR5dvfsun 0NEmlUObt9WSKKmJRsZdNnT0y0Xqp+Cr/DgtU8QISnCP01VYvzOs5iBYceEop0GQfqIh WTNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fPu8+x56+bPaqE+Kt7QPAly49dZ2m5zcnSswTAaxNxU=; b=hp4BTPfDfq37IQlxmou/GOpaUSrjrjLfr7ZRpj3+NAj05WB7YfPDxZBwmfCBbc1g5Q 6znbl2hMfPGt7GBIV9pc7fM+NtkPBZWGgEQJDS0ZSvCBY0MzIRZOHi7LPvyKJSAqqaAk SnfWVM8qV3Fz+tnAwUu3n+dLFeOhBRug/l9r7umeC6Hx38h/iO53q/aJE2aEQKUsFXxj oM9qLlMqDURIc7AQKvmYwwnn3SFC6SejfRlyrXfQxIztsfvlNgA0Dtt53sAiT5nACuvb ZV5Rd2zGJ9D4FinPPA53cz1aGA1qCWITP536Ph3sijzhewcfQ6CJlSCsZGq4qiYnQxwg kg+w== X-Gm-Message-State: AHQUAubpouddESiJJYfhpaBC96pDCG+81K0KxL5ie7FUGYUps4Vkn0eh lPHpLjvshqT56Z9paolozyuDxA== X-Received: by 2002:a17:902:b581:: with SMTP id a1mr4999975pls.36.1549991794044; Tue, 12 Feb 2019 09:16:34 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:33 -0800 (PST) From: Mathieu Poirier 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 12/13] perf tools: Modularize main packet processing loop Date: Tue, 12 Feb 2019 10:16:17 -0700 Message-Id: <20190212171618.25355-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making the main packet processing loop modular so that it can be called from different decoding context (timeless vs. non-timless), avoiding to repeat code. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 129 ++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 57 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index cfa686fe223e..f607bc58bd03 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1519,6 +1519,72 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) return ret; } +static int cs_etm__process_decoder_queue(struct cs_etm_queue *etmq) +{ + int ret; + + /* Process each packet in this chunk */ + while (1) { + ret = cs_etm_decoder__get_packet(etmq->decoder, + etmq->packet); + if (ret <= 0) + /* + * Stop processing this chunk on + * end of data or error + */ + break; + + /* + * Since packet addresses are swapped in packet + * handling within below switch() statements, + * thus setting sample flags must be called + * prior to switch() statement to use address + * information before packets swapping. + */ + ret = cs_etm__set_sample_flags(etmq); + if (ret < 0) + break; + + switch (etmq->packet->sample_type) { + case CS_ETM_RANGE: + /* + * If the packet contains an instruction + * range, generate instruction sequence + * events. + */ + cs_etm__sample(etmq); + break; + case CS_ETM_EXCEPTION: + case CS_ETM_EXCEPTION_RET: + /* + * If the exception packet is coming, + * make sure the previous instruction + * range packet to be handled properly. + */ + cs_etm__exception(etmq); + break; + case CS_ETM_DISCONTINUITY: + /* + * Discontinuity in trace, flush + * previous branch stack + */ + cs_etm__flush(etmq); + break; + case CS_ETM_EMPTY: + /* + * Should not receive empty packet, + * report error. + */ + pr_err("CS ETM Trace: empty packet\n"); + return -EINVAL; + default: + break; + } + } + + return ret; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { int err = 0; @@ -1544,64 +1610,13 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) if (err) return err; - /* Process each packet in this chunk */ - while (1) { - err = cs_etm_decoder__get_packet(etmq->decoder, - etmq->packet); - if (err <= 0) - /* - * Stop processing this chunk on - * end of data or error - */ - break; + /* + * Process each packet in this chunk, nothing to do if + * an error occurs other than hoping the next one will + * be better. + */ + err = cs_etm__process_decoder_queue(etmq); - /* - * Since packet addresses are swapped in packet - * handling within below switch() statements, - * thus setting sample flags must be called - * prior to switch() statement to use address - * information before packets swapping. - */ - err = cs_etm__set_sample_flags(etmq); - if (err < 0) - break; - - switch (etmq->packet->sample_type) { - case CS_ETM_RANGE: - /* - * If the packet contains an instruction - * range, generate instruction sequence - * events. - */ - cs_etm__sample(etmq); - break; - case CS_ETM_EXCEPTION: - case CS_ETM_EXCEPTION_RET: - /* - * If the exception packet is coming, - * make sure the previous instruction - * range packet to be handled properly. - */ - cs_etm__exception(etmq); - break; - case CS_ETM_DISCONTINUITY: - /* - * Discontinuity in trace, flush - * previous branch stack - */ - cs_etm__flush(etmq); - break; - case CS_ETM_EMPTY: - /* - * Should not receive empty packet, - * report error. - */ - pr_err("CS ETM Trace: empty packet\n"); - return -EINVAL; - default: - break; - } - } } while (etmq->buf_len); if (err == 0) From patchwork Tue Feb 12 17:16:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158168 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089116jaa; Tue, 12 Feb 2019 09:16:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IaA/Bd4g5fhjrTWNeJ9k7bn02nBouHHqZHuIMO9l6xtmCiN6sqqxn9m/AGYIOhWmgMq+VyN X-Received: by 2002:a62:61c3:: with SMTP id v186mr4985657pfb.55.1549991805490; Tue, 12 Feb 2019 09:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991805; cv=none; d=google.com; s=arc-20160816; b=M/TpWZn2F/vgFCd4HsZVOeNjcip7x1z6Y1An6lZ4DunRLUEoz9BFokX32Ez0SHkLMk b5pCz+QVC0kyxUWsvYVjijS7D3fMJTMhfDaWfpqtRXuyoaDdw9VrnUAgZE0fF84VTMZ4 CLJtG6ZqyJi3BApW39WRA0/D8t0CxZHb1evgAY5VGBXTGvulB9QO7mHIY10E01u6LS7W Ui5BytIrviGI++egGaBo6mBKRbXWGTxG+8U2/wLG91tFIeEzSQXnAdYUwKyO4Eak2giJ 7snJDMcjsdBeQEMDjvtNNmoCjRsZ9awr5mZCoycP6fo3uT6asXtXXt8gujBVNTR5BdEh XwOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qkiQiMGL+p9I6/iS3vRnEYYc23edBwfSeQJiedeTSRc=; b=gPIhsET9r/5dht1zYXVMrWuG1kmUl312LmUtt03QtgRFDdcFUfU3x9Oldex3MRdvMr 6z8jcn/Iq9aAjeJKnwREGUo/DHNmEDjm5IlhGwTXh5BlAIkE5KMwgY0IOD/ui+tmAy0o Ud4HNBGWTC3miB9QaoUVWR/6EMGHKaH72fDjfD88uJAkZsnRViFwQbOgG7byf8bHsZjh Fz082ALGs7Eql/tkpmBib+MB9gYbKsN0Lifue08xzCsllll84jZ2iFNmvXBWxnbU6+f4 uNMjHGs/qM73yoIqfDSYPQ+PlcXrZpUHWbGlIOpr8KZc+2uDwQ+72OamHmtb5wZCRLdU U44w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sVIhgAj1; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y129si5007421pgy.175.2019.02.12.09.16.45; Tue, 12 Feb 2019 09:16:45 -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=@linaro.org header.s=google header.b=sVIhgAj1; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731843AbfBLRQj (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:39 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33124 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731819AbfBLRQf (ORCPT ); Tue, 12 Feb 2019 12:16:35 -0500 Received: by mail-pl1-f196.google.com with SMTP id y10so1622188plp.0 for ; Tue, 12 Feb 2019 09:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qkiQiMGL+p9I6/iS3vRnEYYc23edBwfSeQJiedeTSRc=; b=sVIhgAj1YxApYOZcGkQA8IOcPqUHNNfVOBXsJ3MIFFlT1Hp8bmWs5av4xevdXiVNZW FSC1Yo1a8IBZkR46UdZoVR3FzPxk79HkIZCfHoTxlU8GGBKw8v8cOrzeCP54IGWvsR8v PzMzDOol6q8ak1JwyqPhqIVjqViUCZIG9JLB5SZUtCUZFE9WQIA8YFOKafHfRMcpwksv /KbApTEcZ92QxjNlFM9SVa3rUX1XD/RHSE+zlfpd9Po0e8bq1JYHfK3fA5fMbe3UteYg vcupn0WP+VnbtW/3yDgT6jB0RLT7I35yBoSiTePGbd5SNZIGI/BeE40t1UPLDRoc5QhJ lluw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qkiQiMGL+p9I6/iS3vRnEYYc23edBwfSeQJiedeTSRc=; b=oW/Qngxz1+82nvMsGMBnnFsUAWvnbZhptDqcPAOQLb69kaUHfgD4Edvd0JPdFATgGi 2gB3YcWDnQpTvmxshdytWzORaQnFfbc1z8EQkd4QDruBbzRoJoxmhanvEChx8LFS+cDc dlq1bwhAZQne4SEiKeQvr9TnV0lx1iZ6kw5uLot2OOuFaOiOAU43vIBU25YEvLLS475b JD7vUIc69rEoqkkpxqcqrYzg28BsggCW3Z5Z4vu4HVkgS4a0XE+zOyJEY5bVto/SCTsx dRcIMfSRCFq3y1zbHAMwcBBS7pvjxajBmmU+yfAFv4oKaBpKD/Qy7W9SQV0ubg9BZ9e6 lkQw== X-Gm-Message-State: AHQUAuYJmjvKi2TIoTSG1hHs3UCvdrH9t+fG+VlN0XRN+i6sXckZhGeC 4z+iOvtE2VLq7Rd56lAeQIr9KQ== X-Received: by 2002:a17:902:14b:: with SMTP id 69mr4904861plb.120.1549991795240; Tue, 12 Feb 2019 09:16:35 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:34 -0800 (PST) From: Mathieu Poirier 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 Message-Id: <20190212171618.25355-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.17.1 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 {