Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp696634ybg; Thu, 19 Mar 2020 07:12:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvc4PfOpl5kAQb+W6oZoLt03Y1zZjGdTg6CB0CkOSDJd/vrVPxMjHtRPxbNw+8tca/xJ42i X-Received: by 2002:a05:6830:201a:: with SMTP id e26mr2567802otp.238.1584627122253; Thu, 19 Mar 2020 07:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584627122; cv=none; d=google.com; s=arc-20160816; b=oyY2XGXSQNPMtM/6qh06dwt/RZRXhwPevx4qkydxNEMHE7zScAoIwhXYbEsSGKcDPs 3MAXwguSjH95PFvvzX7uACFBVGyc/hhDHWnNqE5qiDvAJAqL7hRYexYo1k/n+wxLOHS1 8u7dnhE4pYt5RS97U9xUMeXe47c6N9muuppw81UOS7B/yaPPTdRFy0OlvaHL3ML6Oviv FAY8GAUNAfb5LQIVqRdZnKCIKS8nMJVeVOI4s56GFhrML3ktVlCI5QIJoWpli8PVmuj8 6UjSw9jlWjCBQHzCD7sKcD6HewHuvSNvktT0MhdQ6+m0qaztWcX2R0s1i9bDar9mLEfP lf5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=GMGmytXyMKzmMsc+h+RsFPpnfvXpuDCrbYKfiQwDo6o=; b=J6VgrkaEHqpWqqCyrF7j8RDWIBWiuPSXEKTKz2uzWZDmM8e+HLNeAvAqLjzH/ORuc9 YEIMKVaYcn015UDSAopVQiN6ulDjfc6GRDvWaASqKq4CYVVfPK7WUs9Ahhdswl6QwLbA nNJZvqs/GFct2kdHjcubk/Mys+gtXqdU6btZXoz//YQwt+L37detSJlxgk7f4Zyw4iuh AljynScOVXxglaASWWzfj9yQPMJ21s6aJTrooCCOjb0pHAE/9xUuEZ3n96CMR17rJZzh qGgUPJ6EoV1D1W0nbh0Ora7g4FaaS2ZMDcLuTzYoCb0OB0BSxx23wjehN/byhl635v44 lLYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si992634oir.119.2020.03.19.07.11.30; Thu, 19 Mar 2020 07:12:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbgCSOK6 (ORCPT + 99 others); Thu, 19 Mar 2020 10:10:58 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60906 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727731AbgCSOK4 (ORCPT ); Thu, 19 Mar 2020 10:10:56 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEvsk-00024d-VJ; Thu, 19 Mar 2020 15:10:47 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 3DBC41C22A6; Thu, 19 Mar 2020 15:10:45 +0100 (CET) Date: Thu, 19 Mar 2020 14:10:44 -0000 From: "tip-bot2 for Leo Yan" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf cs-etm: Swap packets for instruction samples Cc: Leo Yan , Mathieu Poirier , Mike Leach , Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Robert Walker , Suzuki Poulouse , coresight ml , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: <20200219021811.20067-2-leo.yan@linaro.org> References: <20200219021811.20067-2-leo.yan@linaro.org> MIME-Version: 1.0 Message-ID: <158462704492.28353.17202068509574581928.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: d01751563caf0dec7be36f81de77cc0197b77e59 Gitweb: https://git.kernel.org/tip/d01751563caf0dec7be36f81de77cc0197b77e59 Author: Leo Yan AuthorDate: Wed, 19 Feb 2020 10:18:07 +08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Wed, 11 Mar 2020 10:48:44 -03:00 perf cs-etm: Swap packets for instruction samples If use option '--itrace=iNNN' with Arm CoreSight trace data, perf tool fails inject instruction samples; the root cause is the packets are only swapped for branch samples and last branches but not for instruction samples, so the new coming packets cannot be properly handled for only synthesizing instruction samples. To fix this issue, this patch refactors the code with a new function cs_etm__packet_swap() which is used to swap packets and adds the condition for instruction samples. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Reviewed-by: Mike Leach Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: Suzuki Poulouse Cc: coresight ml Cc: linux-arm-kernel@lists.infradead.org Link: http://lore.kernel.org/lkml/20200219021811.20067-2-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index b3b3fe3..294b09c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -363,6 +363,23 @@ struct cs_etm_packet_queue return NULL; } +static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm, + struct cs_etm_traceid_queue *tidq) +{ + struct cs_etm_packet *tmp; + + if (etm->sample_branches || etm->synth_opts.last_branch || + etm->sample_instructions) { + /* + * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for + * the next incoming packet. + */ + tmp = tidq->packet; + tidq->packet = tidq->prev_packet; + tidq->prev_packet = tmp; + } +} + static void cs_etm__packet_dump(const char *pkt_string) { const char *color = PERF_COLOR_BLUE; @@ -1342,7 +1359,6 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq) { struct cs_etm_auxtrace *etm = etmq->etm; - struct cs_etm_packet *tmp; int ret; u8 trace_chan_id = tidq->trace_chan_id; u64 instrs_executed = tidq->packet->instr_count; @@ -1406,15 +1422,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, } } - if (etm->sample_branches || etm->synth_opts.last_branch) { - /* - * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for - * the next incoming packet. - */ - tmp = tidq->packet; - tidq->packet = tidq->prev_packet; - tidq->prev_packet = tmp; - } + cs_etm__packet_swap(etm, tidq); return 0; } @@ -1443,7 +1451,6 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, { int err = 0; struct cs_etm_auxtrace *etm = etmq->etm; - struct cs_etm_packet *tmp; /* Handle start tracing packet */ if (tidq->prev_packet->sample_type == CS_ETM_EMPTY) @@ -1478,15 +1485,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, } swap_packet: - if (etm->sample_branches || etm->synth_opts.last_branch) { - /* - * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for - * the next incoming packet. - */ - tmp = tidq->packet; - tidq->packet = tidq->prev_packet; - tidq->prev_packet = tmp; - } + cs_etm__packet_swap(etm, tidq); return err; }