From patchwork Thu Nov 19 15:24:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11917925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E62EC56201 for ; Thu, 19 Nov 2020 15:29:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9325A2469D for ; Thu, 19 Nov 2020 15:29:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bkG2871o"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZXDynXQl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9325A2469D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=deIehGW1Lo5JN/raMVpO+kEb7mtgCauaUK5xyRt+R3s=; b=bkG2871o+6TBreONf96EgWZkTX 4gYo1jSyTpI5CyY8vzQ+I+ELI8qV7tGr5PfFk9t6uUgZYzfGIedYSmEwyoCp4cdidRJV4FLlc5YYf Sq8rCMnn9sngR00ZpwIvWcQ44X96Vgp3MbndlVEQ1zvUqZuHYT6kUFXrG4tCm44RnACSAVqL96Zer aB3qq5w2bCbZVnlYGZaGVeObwnwSWPQALDJoCBarDK1MKjzzyXwk3Q+Dm3r/NefiV6Fh43kIB2DuI rBYkBytB9AlxIIrtgSv5XjoIFoZcTFFtgpoRw1iYvqr2lhm7GKyP2SybERX1lEVjKAq2hKlE9Z+Hx Ffm6q1CQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kflrD-0005Gx-9O; Thu, 19 Nov 2020 15:28:23 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfloK-0004Fk-QN for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 15:25:32 +0000 Received: by mail-pl1-x643.google.com with SMTP id d17so3115835plr.5 for ; Thu, 19 Nov 2020 07:25: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=aO1R9Y4e/9JxiW3PDrlAXdoWdQwZ1ng9F7l0GuU1DYo=; b=ZXDynXQlWT9/QOLDZt7tXFzX5/a6ydFhHOVsUL4a0ccs8uVxLsIj118EfJXTOSD38n II5g/3+gZe+vRdME61TMoroYTW69qolhb1SfUN+1tzgtMAKk9djwm6cLZWv2/7qUzUFQ hYoi8T2gYRcWNMgFHQvbeVFNmvrmxk84F34rZcPtB1Sp9BqVGzdKGiiYBM3kEsvvyDiT XhZJDNeXCgepgR2m1TVU7qb4pSJJWGvKOGlvJ9qoW9G0cMPE87oo7jVkadM38wVtugvJ 56YnyCB7RhPUXjevKQCR9iNlm9GSsbL51Wklnh5rt6QlBEAP4R2Rhgey7Uy/lE/M2+WZ 0nCw== 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=aO1R9Y4e/9JxiW3PDrlAXdoWdQwZ1ng9F7l0GuU1DYo=; b=K+NzxS86V+rSvrEfgFedBpAnF931lY4NfjMgVI9jUpkGhaiimah976QRG6pRp5NyyK 07Qno5bRWwjAw71MVO9QVaAixoJvhjaa/VIt8fGPEdvabYh+PkU/ARGqLnTvGIulMhl7 lBsPSArI1/GhpQA95bjN8/shJqgbFXpdm4TJVq9ZjPN5AFmRjhe9DovYUZlIYArgHZSj Xl04XKXb8ox3ZTS+Kp9VkkCsNJUl9WQ7YOZ+DEMwu/qrTyzm+ocKewOC0UNCoLXD+q66 /9eyej8g60LwQH82WM3kYDmNaFt/qu83JirXEQ2e6XQprnVyxR5rK3JVh71bIdI9Ldni e/2A== X-Gm-Message-State: AOAM5327nKsNLiQIeVU9mT0keB2BrbMwLBzTmAfdyb6oDKIRnieMyoOX o+JzrN2gS7oGhZo+0/xcS5gxdQ== X-Google-Smtp-Source: ABdhPJwqTfqoFRngQWcM0UV4vHX8tj4w6rAzql0ryte75Ee/zzR4lqvBqAIfE1nshhVZqVAK20lwtA== X-Received: by 2002:a17:902:6b08:b029:d6:c471:8b5b with SMTP id o8-20020a1709026b08b02900d6c4718b5bmr9565015plk.78.1605799521690; Thu, 19 Nov 2020 07:25:21 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id c193sm117978pfb.78.2020.11.19.07.25.20 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Nov 2020 07:25:21 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Andre Przywara , Dave Martin , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Al Grant , Wei Li , John Garry , Will Deacon , Mathieu Poirier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v9 07/16] perf arm-spe: Add new function arm_spe_pkt_desc_counter() Date: Thu, 19 Nov 2020 23:24:32 +0800 Message-Id: <20201119152441.6972-8-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119152441.6972-1-leo.yan@linaro.org> References: <20201119152441.6972-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_102525_046501_CC06F56F X-CRM114-Status: GOOD ( 17.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch moves out the counter packet parsing code from arm_spe_pkt_desc() to the new function arm_spe_pkt_desc_counter(). Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- .../arm-spe-decoder/arm-spe-pkt-decoder.c | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c index 978f5551b82c..397ade5ffdeb 100644 --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c @@ -322,6 +322,33 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet, return err; } +static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet, + char *buf, size_t buf_len) +{ + u64 payload = packet->payload; + const char *name = arm_spe_pkt_name(packet->type); + int err = 0; + + arm_spe_pkt_out_string(&err, &buf, &buf_len, "%s %d ", name, + (unsigned short)payload); + + switch (packet->index) { + case 0: + arm_spe_pkt_out_string(&err, &buf, &buf_len, "TOT"); + break; + case 1: + arm_spe_pkt_out_string(&err, &buf, &buf_len, "ISSUE"); + break; + case 2: + arm_spe_pkt_out_string(&err, &buf, &buf_len, "XLAT"); + break; + default: + break; + } + + return err; +} + int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, size_t buf_len) { @@ -414,21 +441,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, name, (unsigned long)payload, idx + 1); break; case ARM_SPE_COUNTER: - arm_spe_pkt_out_string(&err, &buf, &blen, "%s %d ", name, - (unsigned short)payload); - switch (idx) { - case 0: - arm_spe_pkt_out_string(&err, &buf, &blen, "TOT"); - break; - case 1: - arm_spe_pkt_out_string(&err, &buf, &blen, "ISSUE"); - break; - case 2: - arm_spe_pkt_out_string(&err, &buf, &blen, "XLAT"); - break; - default: - break; - } + err = arm_spe_pkt_desc_counter(packet, buf, buf_len); break; default: /* Unknown packet type */