Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4781341pxu; Wed, 21 Oct 2020 05:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3HVUrmvRRTtNdMcovh0t8K85ylU0rKzvQcu3nDR5POiPFVR5YbLkpkpIvdu6N1GEX4oeL X-Received: by 2002:a05:6402:3191:: with SMTP id di17mr2723983edb.376.1603282962137; Wed, 21 Oct 2020 05:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603282962; cv=none; d=google.com; s=arc-20160816; b=zXy36Z2j5HXI7Nu1upZCg6foopD7p+6Wxt6mr2a6v5qaFnw4xoeUAQ6yIkZRC3d4a5 8Zjy6rYQwl+V3yJj652IMTgHC24OLNAc7Igyl07qqJ857yBhCC5ILpKImYEEcknb3JrL F0AlCB82IrigG0iVJ2f/e24t/Vep8r4z0l9gJsUlNXdkKjLE2MPv4pBgJDp7zWltdvhX Uw/XX10Nq+CN4pjKEJoHvnOleGxxBYnv/u1HpjVM0Jj7+D2weko5cLQOQ7VbQccXx3XS ci6pep3wNYn2ZQxeHl34MuO7chwkhDZ8RqcDVPeVjbYmrEHuUCUNPs6HGZqUZrOD3uFM aOqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mFpqSA2KhjqRwu8wHBb6+NW2cwuO0N+7Zos8HJ01i7c=; b=AhhMecoqsu2eib48Uml6yk2HqX9sVlE3DjG+8PFlMjUzoFGlyrW0DhlFOWtH7rhU9D XsccnNMGPXKSGnwrql4ya4+KXjyiBIOTSCxnU7Gdm5TTqhh68OtWHokjX4DmTiWUyVZA RJGSQnuuBwA/9ckohBUnYWqOH7xeQZT26DvReV50a1pIt8ZplvdOBKsCqP8Fm+UyJ0G6 BSNGPtTEricxXFsnICb/WZ/1Wn59n7m1HYJ1e5F4QOKd99ic2b1xD3M7askxH6NHyYDW jX68EBY5QfS/VaIgXNiS/oG0CivMz+xtqRSBUGfan1yCAnM0PCDJwB+Zj1cv81qB3R22 lkdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnJnlbvK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id cb11si1260335edb.274.2020.10.21.05.22.19; Wed, 21 Oct 2020 05:22:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnJnlbvK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2411862AbgJUDwU (ORCPT + 99 others); Tue, 20 Oct 2020 23:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411844AbgJUDwT (ORCPT ); Tue, 20 Oct 2020 23:52:19 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B4A8C0613CE for ; Tue, 20 Oct 2020 20:52:19 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id p3so1567951pjd.0 for ; Tue, 20 Oct 2020 20:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=mFpqSA2KhjqRwu8wHBb6+NW2cwuO0N+7Zos8HJ01i7c=; b=wnJnlbvKioV60GDwgvJJidcKH1/VKZoW5z0rnonNUbBPYaq/YatSNgbOjlRGYwGzfo SXY536CPop8IqBuvljkSvDGLUikbkls+B17bSG2+U/KPjkt4cpJs07Z/cIhNQo5WPDmc a5PXy5FcARnlB/LsUt3FdK8Mk8EjU834biBSDvkecWOj2tEYxolPSx9sH2IO6Ym6M6xo PAM9c9nUZMz9OvEhzdr9oRiJhVCChO0gPn5VGTqUQe0xKWCCeXXrotNGzA6zB7HyjmbQ s5GygeFz71Ba0LUDE2Cd36C3ImCcRS4swkcOndyhkfr3PRcoCAr8o4+CvcCHspNX0s+L 91Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=mFpqSA2KhjqRwu8wHBb6+NW2cwuO0N+7Zos8HJ01i7c=; b=N1xPtnklWZZrtIra7DUCJEy3BPLgFxTmNimxffidU72xNkqWMxI0YzJc3UCbMTIKqw hBUIF+rhpCdIF9x6vC7BhyBPu2h838a5abXMKRrzSHWdqG2rGZOMl/s73QlawjLaoYHw NAMCcYZzdj6TVVl95U2lp8Rk/wuumtUhwzme+Tg/WZ8OwTHtf8VAL/CaoJXtuJgATvwL Bzealv/9SA1gsOVBLstw/HzABF+d3yaEfhUQNf8LgsuCVc4J6Pf4zB0uxsXjUb7QDGMx VP2CQqvfDKuTgGNLsMLBiBAbWEjOFNx0PxJY7Mr92Mwh4eK2V0LCUg8db40dmamikaCg cvfw== X-Gm-Message-State: AOAM530A/bmbH/Wrhsn/hLfL7ips3h1venGf4kaBE8SHOKIV+zq+gyW/ w6j45GRtjgkWO5iZCeWTM1KfdA== X-Received: by 2002:a17:90a:d317:: with SMTP id p23mr1292947pju.52.1603252338814; Tue, 20 Oct 2020 20:52:18 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([14.192.49.12]) by smtp.gmail.com with ESMTPSA id z30sm470982pfq.87.2020.10.20.20.52.14 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Oct 2020 20:52:18 -0700 (PDT) Date: Wed, 21 Oct 2020 11:52:12 +0800 From: Leo Yan To: =?iso-8859-1?Q?Andr=E9?= Przywara Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Wei Li , James Clark , Dave Martin , linux-kernel@vger.kernel.org, Al Grant Subject: Re: [PATCH v2 09/14] perf arm-spe: Refactor counter packet handling Message-ID: <20201021035212.GC7226@leoy-ThinkPad-X240s> References: <20200929133917.9224-1-leo.yan@linaro.org> <20200929133917.9224-10-leo.yan@linaro.org> <6080472e-a117-e36d-ec4a-80f7ef93b3fb@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6080472e-a117-e36d-ec4a-80f7ef93b3fb@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 20, 2020 at 10:53:47PM +0100, Andr? Przywara wrote: > On 29/09/2020 14:39, Leo Yan wrote: > > Hi, > > > This patch defines macros for counter packet header, and uses macro to > > replace hard code values for packet parsing. > > > > Signed-off-by: Leo Yan > > --- > > .../util/arm-spe-decoder/arm-spe-pkt-decoder.c | 17 ++++++++++------- > > .../util/arm-spe-decoder/arm-spe-pkt-decoder.h | 9 +++++++++ > > 2 files changed, 19 insertions(+), 7 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 00a2cd1af422..ed0f4c74dfc5 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 > > @@ -150,10 +150,13 @@ 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); > > - else > > - packet->index = buf[0] & 0x7; > > + if (ext_hdr) { > > + packet->index = (buf[1] & SPE_CNT_PKT_HDR_INDEX_MASK); > > + packet->index |= ((buf[0] & SPE_CNT_PKT_HDR_EXT_INDEX_MASK) > > + << SPE_CNT_PKT_HDR_EXT_INDEX_SHIFT); > > + } else { > > + packet->index = buf[0] & SPE_CNT_PKT_HDR_INDEX_MASK; > > That looks suspiciously similar to the extended header in the address > packet. Can you use the same name for that? Checked for counter packet and address packet, they are using the same format for index. Will use the same name. > And, similar to the address packet, what about: > packet->index |= SPE_PKT_EXT_HEADER_INDEX(buf[0]); Will do. > (merging the mask and the shift in the macro definition) > > > + } > > > > return arm_spe_get_payload(buf, len, ext_hdr, packet); > > } > > @@ -431,17 +434,17 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, > > return ret; > > > > switch (idx) { > > - case 0: > > + case SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT: > > ret = arm_spe_pkt_snprintf(&buf, &blen, "TOT"); > > if (ret < 0) > > return ret; > > break; > > - case 1: > > + case SPE_CNT_PKT_HDR_INDEX_ISSUE_LAT: > > ret = arm_spe_pkt_snprintf(&buf, &blen, "ISSUE"); > > if (ret < 0) > > return ret; > > break; > > - case 2: > > + case SPE_CNT_PKT_HDR_INDEX_TRANS_LAT: > > ret = arm_spe_pkt_snprintf(&buf, &blen, "XLAT"); > > if (ret < 0) > > return ret; > > 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 62db4ff91832..18667a63f5ba 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 > > @@ -89,6 +89,15 @@ struct arm_spe_pkt { > > /* Context packet header */ > > #define SPE_CTX_PKT_HDR_INDEX_MASK GENMASK_ULL(1, 0) > > > > +/* Counter packet header */ > > +#define SPE_CNT_PKT_HDR_INDEX_MASK GENMASK_ULL(2, 0) > > +#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) > > I think the Linux kernel coding style does not mention parentheses just > around numbers, so just 0x2 would suffice, for instance. > See section 12) in Documentation/process/coding-style.rst Yeah, it gives example as "#define CONSTANT 0x4000"; will follow the coding style. Thanks for suggestions! Leo