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 6B7E6C4363A for ; Tue, 27 Oct 2020 03:10:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1417A20872 for ; Tue, 27 Oct 2020 03:10:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OXnuLvFn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439361AbgJ0DK3 (ORCPT ); Mon, 26 Oct 2020 23:10:29 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37374 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439192AbgJ0DK1 (ORCPT ); Mon, 26 Oct 2020 23:10:27 -0400 Received: by mail-pf1-f195.google.com with SMTP id 126so81891pfu.4 for ; Mon, 26 Oct 2020 20:10:26 -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=ggrCrrOmIGShBF925Jr9ht3p0sf/ZpOgGfgHeELSUDk=; b=OXnuLvFnuFXTHLaM31j3wZeO0dSbDUReJejwsZ91yFLm37d2oWMEA/8VhzBHUqB26t GHR/bhoUTVxb8PjUscvqkDqrZbJ3NGiKZUUbEQUfiEwpD0WyAgQ+ncX5qL7CVx+KCXyt K7xp/jSOsTdNfiAxh9EsletEHzS2/RKo6D4YzFl+w56wUh1iu/+B6ka5G0bPOkLRbcEq UTPTijvbEnqvHi/Sma2q7GOupZXTRwctpI7xGvmlla1oxKy4+wWyqOZNnzkil1NIsv7M /BONzDBGmUNqVp3OWvSRGP3GZsiUhS4sF48taBnwPB5j3c5rw7zOh9GZR4MG+NuNHvUJ +LwA== 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=ggrCrrOmIGShBF925Jr9ht3p0sf/ZpOgGfgHeELSUDk=; b=TuPn4gojvVU9fVZZymPx2dMhI0SqoMRhUVcRHbX3ysuG+6wqx7VKwLZdTosbq0dzHf xsN0JLN9Kykm60NiUwIE7FrKa+nM6biMtQtWOtJkQJAvROeLj1XaCwpNH13hHZ1vuunE GeGy58mDOPLuQ3mSU5LBLXzoCPSprD4SSx8wpDwH6XtDNNHyNxQUYtzPqiSX3PSbd4lv CTjk6g63lufbU6KvhQ0y8w/s8ykRNEgc8wROmgUoa+cJv6iJnvOJTPceSsU9Hv2ygXmj ceB4KhG7GcplCoiATAqaAgOZZ+gznrPHmoes3LVYRzI35L6DJMWH8fPbsCFw/nP0O0K3 2jDw== X-Gm-Message-State: AOAM532/3wLohs+IeJLNTGT/XQfHe0hutIkFzmn+DDokJVhHxQRSEIvG bxVOXJ7nqLtJvxw7KLrUY5ZLIA== X-Google-Smtp-Source: ABdhPJxSizMG3mX5BfHmMTWj2DYVyRO/UhF/3V+PPiAFsxMKjrh388AWFdmx3Hab79poxErholAoGw== X-Received: by 2002:a62:92c8:0:b029:152:1703:2da9 with SMTP id o191-20020a6292c80000b029015217032da9mr182893pfd.60.1603768226357; Mon, 26 Oct 2020 20:10:26 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id cv6sm176450pjb.2.2020.10.26.20.10.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Oct 2020 20:10:25 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Andre Przywara , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Wei Li , James Clark , Al Grant , Dave Martin , linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 04/21] perf arm-spe: Refactor arm_spe_get_events() Date: Tue, 27 Oct 2020 11:09:00 +0800 Message-Id: <20201027030917.15404-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201027030917.15404-1-leo.yan@linaro.org> References: <20201027030917.15404-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function arm_spe_get_events(), the event packet's 'index' is assigned as payload length, but the flow is not directive: it firstly gets the packet length from the return value of arm_spe_get_payload(), the value includes header length (1) and payload length: int ret = arm_spe_get_payload(buf, len, packet); and then reduces header length from packet length, so finally get the payload length: packet->index = ret - 1; To simplify the code, this patch directly assigns payload length to event packet's index; and at the end it calls arm_spe_get_payload() to return the payload value. Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 6 ++---- 1 file changed, 2 insertions(+), 4 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 06b3eec4494e..f1b4cb008837 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 @@ -136,8 +136,6 @@ static int arm_spe_get_timestamp(const unsigned char *buf, size_t len, static int arm_spe_get_events(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet) { - int ret = arm_spe_get_payload(buf, len, packet); - packet->type = ARM_SPE_EVENTS; /* we use index to identify Events with a less number of @@ -145,9 +143,9 @@ static int arm_spe_get_events(const unsigned char *buf, size_t len, * LLC-REFILL, and REMOTE-ACCESS events are identified if * index > 1. */ - packet->index = ret - 1; + packet->index = arm_spe_payload_len(buf[0]); - return ret; + return arm_spe_get_payload(buf, len, packet); } static int arm_spe_get_data_source(const unsigned char *buf, size_t len, -- 2.17.1