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=-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 0D31FC63697 for ; Thu, 19 Nov 2020 15:29:08 +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 673B024695 for ; Thu, 19 Nov 2020 15:29:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PKKrEMST"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Pfvm6bqE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 673B024695 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=dsz7vVEXLhOMNB5JlEh5SLXCtnnmFHHxvHikmAFyjKs=; b=PKKrEMSTkIzEtVLnLEUuv3rqzp KhMQSmsGhMZmrfQ+msuqm/QRAHWsZd0V5xZ14ptn2dYeXjp/4mDztK+LX5SMnmxhiAyHSiOqGyEum YVG+TNMVejkT7gaGzPkrMAXRq0QiNYHAQ0NmbHmwocAPNRo2arUKE+h8nkUcLGDBECsVmc0PZGumS iawPdS+NxFb85ofNCvZuBSFvQuciK6eVUO/98ahwxpEt1ev6toi5M0z9/+m2XnPycRn2y6shdg41c h7ShVwZyrSa0wprX3xTftvB/pdAelpXbatDnzdQtMlA8+rtMvionKekXsE/r6yaY1U0VEyr72BYvF urvr6kVQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kflrN-0005LE-PD; Thu, 19 Nov 2020 15:28:33 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfloP-0004HV-T1 for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 15:25:39 +0000 Received: by mail-pl1-x644.google.com with SMTP id bj5so2302606plb.4 for ; Thu, 19 Nov 2020 07:25: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=O87RqMurf7pPIx11yyX1x4VsxqTigVqv7i7uvntvbNs=; b=Pfvm6bqEMnypvbHE6q7WcG1qY9swcIWDM/yRibx6LingVppXeuUoUofX/t4Y+14Wdc aLnIqKRMYN/r+Q1Vb90A1PSGhl8e4UX/p6DJS4mjaQ/so1VobXZGn71bzIyBjy8trYxm GFElnRGzdmYwhUOIkpzK6sSNuxTKBl2W1IjIf3M0X/NRRY7qNb+Ejs6/SuJPp1+fQUvL 0X6QBG5DeZgOEH4k81x/5bQzQWlvVyEvkFEpich/d6mmu5KpcW9rl4dvaZaumbSFAiRk ddRjoty4gt6xywRgL+J1be80RMk3iMkIv0A6hN+X9Bpag5kMdSyz0Kyr0JNC/1cBuAHp OYVQ== 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=O87RqMurf7pPIx11yyX1x4VsxqTigVqv7i7uvntvbNs=; b=nf8QOJD3QCKQS7ktUyTjGlF0ygbsYx4ddbovevwXrP1iBPZKcKq6cMavXoPwSXPH0I TUeHOuyqi3n53/hKBpX2fgr0bK2Ohs/AINiqmMTdygqY3/AHYQFbY/WBgeOw0DRrT3sf Z34i5WRg90rp8+wlfYUWjUnSNp7V+oA8MeirzIxwUcu0ls8d4Veab8942xxdkI6X3yoB b9Hf1IYf+ti35rgkTSrHkig3/EQO4r0Pra+mhJih92iXvxqN+iBkQSHMDRVqvX2OtOvG DL6DNUzNckJ+lM1ZcJTYB17F2MqP8576JOtc84RHJ+bXw+3OTZWgmacY1iQHFOvLYNNZ X3kg== X-Gm-Message-State: AOAM533/AGIefgNH6BROAfcGC2XhVwMfzwyq5J2zTNjlK86FZ0X/ce9V 0O5nX4eY7fNZjYuwxfAcOI64uQ== X-Google-Smtp-Source: ABdhPJw2I8Tj8xztSNsYObB61zG2p7iznEGuvyZY+NqZkGZE/52RvOMfEPYEb153MIiMGV6Vjk95fA== X-Received: by 2002:a17:902:a504:b029:d8:ebc7:a864 with SMTP id s4-20020a170902a504b02900d8ebc7a864mr9072483plq.60.1605799525723; Thu, 19 Nov 2020 07:25:25 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id h127sm135416pfe.16.2020.11.19.07.25.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Nov 2020 07:25:25 -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 08/16] perf arm-spe: Refactor counter packet handling Date: Thu, 19 Nov 2020 23:24:33 +0800 Message-Id: <20201119152441.6972-9-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_102530_080986_167DF069 X-CRM114-Status: GOOD ( 17.09 ) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch defines macros for counter packet header, and uses macros to replace hard code values in functions arm_spe_get_counter() and arm_spe_pkt_desc(). In the function arm_spe_get_counter(), adds a new line for more readable. Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 11 ++++++----- tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 5 +++++ 2 files changed, 11 insertions(+), 5 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 397ade5ffdeb..52f4339b1f0c 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 @@ -152,10 +152,11 @@ static int arm_spe_get_counter(const unsigned char *buf, size_t len, const unsigned char ext_hdr, struct arm_spe_pkt *packet) { packet->type = ARM_SPE_COUNTER; + if (ext_hdr) - packet->index = ((buf[0] & 0x3) << 3) | (buf[1] & 0x7); + packet->index = SPE_HDR_EXTENDED_INDEX(buf[0], buf[1]); else - packet->index = buf[0] & 0x7; + packet->index = SPE_HDR_SHORT_INDEX(buf[0]); return arm_spe_get_payload(buf, len, ext_hdr, packet); } @@ -333,13 +334,13 @@ static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet, (unsigned short)payload); switch (packet->index) { - case 0: + case SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT: arm_spe_pkt_out_string(&err, &buf, &buf_len, "TOT"); break; - case 1: + case SPE_CNT_PKT_HDR_INDEX_ISSUE_LAT: arm_spe_pkt_out_string(&err, &buf, &buf_len, "ISSUE"); break; - case 2: + case SPE_CNT_PKT_HDR_INDEX_TRANS_LAT: arm_spe_pkt_out_string(&err, &buf, &buf_len, "XLAT"); break; default: diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h index 9bc876bffd35..7d8e34e35f05 100644 --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h @@ -82,6 +82,11 @@ struct arm_spe_pkt { /* Context packet header */ #define SPE_CTX_PKT_HDR_INDEX(h) ((h) & GENMASK_ULL(1, 0)) +/* Counter packet header */ +#define SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT 0x0 +#define SPE_CNT_PKT_HDR_INDEX_ISSUE_LAT 0x1 +#define SPE_CNT_PKT_HDR_INDEX_TRANS_LAT 0x2 + const char *arm_spe_pkt_name(enum arm_spe_pkt_type); int arm_spe_get_packet(const unsigned char *buf, size_t len, -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel