From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 65AB0C2D0A3 for ; Thu, 29 Oct 2020 07:22:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03A89218AC for ; Thu, 29 Oct 2020 07:22:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XlzTyc/A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbgJ2HVr (ORCPT ); Thu, 29 Oct 2020 03:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbgJ2HUt (ORCPT ); Thu, 29 Oct 2020 03:20:49 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F72C08EBB0 for ; Thu, 29 Oct 2020 00:20:49 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id o129so1617919pfb.1 for ; Thu, 29 Oct 2020 00:20:49 -0700 (PDT) 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=6+sG0vIdCrrbuR5rtT0M6sRfsz5oija9sA5/ljYuvE8=; b=XlzTyc/AnaW3EZWJKRvF/Ig2S2xIjbLN8d8dnWsdYv123SFmFHoojcWz00Phup/69Q 8ajnl/y8uaOfx6TBhJGdYYFuxGd5m+5rPII122EY/RtKSgA5W9/I2Y6T89hlRlkEVRNW Vg1XSiCKVX3eRZdhOeOHmDR5M5CHJzKpxnJYpUNIyGOEV7Tpx3a/WezMrkiFF4P6rHZ4 g05JZcp9uVXnDJKiPYPOP1iiNLNK11hwNKTPf413lXLB/YrXf+wNH/qntnFNDTOcCgyq mpOliRIE6hLNe5o1D4iLpo5fHBnc3ZWFmyVBDjefVEJ8n/tqVxzIaJTf7gjDR8Revt81 W/Xw== 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=6+sG0vIdCrrbuR5rtT0M6sRfsz5oija9sA5/ljYuvE8=; b=XwDw9qHFFRqyjCIryaLCEGsfAIMOdwOFAsHaJ2xpElV0vEHSjOMSAIylTTXJgb5Qv1 W3tQREZfOoaxGeS0c7gzMmYNSIbg7e86K+Atc6OqsZlzOYzjvN9FtvUgBZK65tB5AZSP o4PVUbJVgNLKGsE9ibPfbyyB6f+rf2ZWEMLNmdv0IFGIllsMWROWBK5ZuY7Sz6AQ58YZ t5ZjipXmYg/vrwxRuc1juuoYswMuRaNsofW7eQoOTRBuu41cim2XhygTzo4S+OtPRfqt miA88h2FVypPN3NYO2908NgFt3Qwj82JYTrVgWQFHMlmitG5BYk/V5qeN7u7gvhwRHQd hBFg== X-Gm-Message-State: AOAM532D9lGZTXsIpnxJ0KdHn2LZ1HElK3sTjhqWXJc1uO2hjZn3Cf9n VgeWKVrioSQyQZuplyTzckOkZg== X-Google-Smtp-Source: ABdhPJxh9tCpzSfyclGmPfLNJp4lf2P3cWOo8rLDdqpa6h9y/obtehM/+cnry5Kak5GGSF4JzCUYVg== X-Received: by 2002:a17:90a:348e:: with SMTP id p14mr2950375pjb.75.1603956049174; Thu, 29 Oct 2020 00:20:49 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id d26sm1752861pfo.82.2020.10.29.00.20.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Oct 2020 00:20:48 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andre Przywara , Dave Martin , Wei Li , James Clark , Al Grant , "linux-kernel@vger.kernel.org" Cc: Leo Yan Subject: [PATCH v5 14/21] perf arm-spe: Add new function arm_spe_pkt_desc_event() Date: Thu, 29 Oct 2020 15:19:20 +0800 Message-Id: <20201029071927.9308-15-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201029071927.9308-1-leo.yan@linaro.org> References: <20201029071927.9308-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves out the event packet parsing from arm_spe_pkt_desc() to the new function arm_spe_pkt_desc_event(). Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- .../arm-spe-decoder/arm-spe-pkt-decoder.c | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 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 bc4b5a5a528b..6e4896327e56 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 @@ -269,6 +269,43 @@ static int arm_spe_pkt_snprintf(int *err, char **buf_p, size_t *blen, return ret; } +static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet, + char *buf, size_t buf_len) +{ + u64 payload = packet->payload; + size_t blen = buf_len; + int err = 0; + + arm_spe_pkt_snprintf(&err, &buf, &blen, "EV"); + + if (payload & 0x1) + arm_spe_pkt_snprintf(&err, &buf, &blen, " EXCEPTION-GEN"); + if (payload & 0x2) + arm_spe_pkt_snprintf(&err, &buf, &blen, " RETIRED"); + if (payload & 0x4) + arm_spe_pkt_snprintf(&err, &buf, &blen, " L1D-ACCESS"); + if (payload & 0x8) + arm_spe_pkt_snprintf(&err, &buf, &blen, " L1D-REFILL"); + if (payload & 0x10) + arm_spe_pkt_snprintf(&err, &buf, &blen, " TLB-ACCESS"); + if (payload & 0x20) + arm_spe_pkt_snprintf(&err, &buf, &blen, " TLB-REFILL"); + if (payload & 0x40) + arm_spe_pkt_snprintf(&err, &buf, &blen, " NOT-TAKEN"); + if (payload & 0x80) + arm_spe_pkt_snprintf(&err, &buf, &blen, " MISPRED"); + if (packet->index > 1) { + if (payload & 0x100) + arm_spe_pkt_snprintf(&err, &buf, &blen, " LLC-ACCESS"); + if (payload & 0x200) + arm_spe_pkt_snprintf(&err, &buf, &blen, " LLC-REFILL"); + if (payload & 0x400) + arm_spe_pkt_snprintf(&err, &buf, &blen, " REMOTE-ACCESS"); + } + + return err ?: (int)(buf_len - blen); +} + static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet, char *buf, size_t buf_len) { @@ -341,34 +378,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, case ARM_SPE_END: return arm_spe_pkt_snprintf(&err, &buf, &blen, "%s", name); case ARM_SPE_EVENTS: - arm_spe_pkt_snprintf(&err, &buf, &blen, "EV"); - - if (payload & 0x1) - arm_spe_pkt_snprintf(&err, &buf, &blen, " EXCEPTION-GEN"); - if (payload & 0x2) - arm_spe_pkt_snprintf(&err, &buf, &blen, " RETIRED"); - if (payload & 0x4) - arm_spe_pkt_snprintf(&err, &buf, &blen, " L1D-ACCESS"); - if (payload & 0x8) - arm_spe_pkt_snprintf(&err, &buf, &blen, " L1D-REFILL"); - if (payload & 0x10) - arm_spe_pkt_snprintf(&err, &buf, &blen, " TLB-ACCESS"); - if (payload & 0x20) - arm_spe_pkt_snprintf(&err, &buf, &blen, " TLB-REFILL"); - if (payload & 0x40) - arm_spe_pkt_snprintf(&err, &buf, &blen, " NOT-TAKEN"); - if (payload & 0x80) - arm_spe_pkt_snprintf(&err, &buf, &blen, " MISPRED"); - if (idx > 1) { - if (payload & 0x100) - arm_spe_pkt_snprintf(&err, &buf, &blen, " LLC-ACCESS"); - if (payload & 0x200) - arm_spe_pkt_snprintf(&err, &buf, &blen, " LLC-REFILL"); - if (payload & 0x400) - arm_spe_pkt_snprintf(&err, &buf, &blen, " REMOTE-ACCESS"); - } - return err ?: (int)(buf_len - blen); - + return arm_spe_pkt_desc_event(packet, buf, buf_len); case ARM_SPE_OP_TYPE: switch (idx) { case 0: -- 2.17.1