From patchwork Mon May 21 08:52:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 136433 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp51719lji; Mon, 21 May 2018 01:53:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqq202IEQUVMxlXt5wbK8+HeUmvHQokFpIenw55Z6EWo3MIhBvmcvf7S9HKRJfbvhrDn/FG X-Received: by 2002:a65:6101:: with SMTP id z1-v6mr7835775pgu.23.1526892829264; Mon, 21 May 2018 01:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526892829; cv=none; d=google.com; s=arc-20160816; b=Mb2EGQlUx9LIzp5cmW2A+691BsypC/wHMYnClvpuMZ61MI8mRU638mhQhrdqK3EdJy n14E/kF2wPjX7d4mxEXq5F+HIIB9Ex84hEH0FQSn1XAoPPOMmKv1dtSsbW/TvNQLS/JC 8D4+4jjoDDKGHvAZQvKvPv1w/zcgWnq0PCavnE2RjeiWHqZNSX7tLlnKBRP0AS8Ncv6+ 3eY81ol3tBuaRskLDRIH2cDb6onnI/LoOAekc2KsNvLH5+ZpTZdimdu2HcfkpcyDMOw/ GxpvlWYCqgH1wAZEWb3iFzATFdnSZ1QdzC0BJxHD5NJK8PbMEZhzHawp+zio/geknGMa WGEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Bk0a/sYUU4Xt/JywC2m6whoF24x/XfBKep4NsctKs90=; b=HTyShdc5f6BdV2H/p4+lzpgPfI60D5/O18GDDIppPQZzpcZk4hLhGaeK9V+JLM4/YQ r4WCCKO5f4IPAvew1yXpkoOmWv2sI4rSa9jNVX7WHTGUWvv6CLKCO+WENFHbA2QCrKOo GDyvfx7ToYOnbjf8J6bYkBt1o8I7ufrQSQ19kLBZK6yTpdZTKmG56t4ZcJb4eAr/Odxf VSxnWZ4DmRtr7YpvEZYvTKZFaVfk2nULwr8JSHMQ1DhtRuoXpWtHKIzynwnWEIajSckb nksm68V7iCeM252HqQCCB2vG2SadslaS5rGjXIF8qewt+TzyhZ6EVLheEKzNchlAq3ql oXlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UAJCw6T6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si9247179pgc.588.2018.05.21.01.53.48; Mon, 21 May 2018 01:53:49 -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; dkim=pass header.i=@linaro.org header.s=google header.b=UAJCw6T6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751872AbeEUIxr (ORCPT + 29 others); Mon, 21 May 2018 04:53:47 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41984 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751656AbeEUIxm (ORCPT ); Mon, 21 May 2018 04:53:42 -0400 Received: by mail-pl0-f65.google.com with SMTP id u6-v6so8412976pls.9 for ; Mon, 21 May 2018 01:53:42 -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=Bk0a/sYUU4Xt/JywC2m6whoF24x/XfBKep4NsctKs90=; b=UAJCw6T6rKfV2TJchHFp85vATrYc/5ZBgUZ7B7inN/s7RbXRc6RUYVG9iz5GR7iFp8 DTb+BXsL0jOgMa7uBO/xrSp1lZI9g5PXA5g2Fy8YtF/n08s2nlq9T3/d6gT/i3RPkkim GN7BKLTBtN2Vitv4JaaaJJiuQ0QqIk9ZVQvH0= 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=Bk0a/sYUU4Xt/JywC2m6whoF24x/XfBKep4NsctKs90=; b=FvCqncj1hXVWHGpf9tYzYYT/ayqxvCRKC7Chtb+4uSMx4M2t2Qnmtiqgiq/XYqM0nd QYPOQvoRpaoUhortzLNlWIHtlJzk44GXjf94k1LXuvRSvzbS8aBSqOkTCU8mLfjHBJed D+C1HbFWQXDTYQNY/kszH2Wlxbk+im+CqUFc3G3f6NehDURbleNK0/Ft8N9Q3a+9VZu2 s35VKQqW2szQ4nVyHJrC4E6qZzOrlBkDBQVvEMKPi+WlGc/4wDoYFhuIhY34iisnA8gh Qw9fgmf4pp04UXw6pPvvRoDKd7EelExNluTiY++JUrFV/jR9m+P2/5pE2XdFWdllybnn Jk1g== X-Gm-Message-State: ALKqPwdvjvaSEsb+wnCgifASS9Npar9x76ZCyACv+7WawWarzESFbBiu L0R5e7e3aTDDy0IdOTItWq11qw== X-Received: by 2002:a17:902:5382:: with SMTP id c2-v6mr19629122pli.335.1526892822128; Mon, 21 May 2018 01:53:42 -0700 (PDT) Received: from localhost.localdomain (li1209-69.members.linode.com. [45.79.110.69]) by smtp.gmail.com with ESMTPSA id 16-v6sm28553918pfq.115.2018.05.21.01.53.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 May 2018 01:53:40 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Tor Jeremiassen , mike.leach@linaro.org, kim.phillips@arm.com, Robert Walker , coresight@lists.linaro.org Cc: Leo Yan , Mike Leach , Robert Walker Subject: [RFT v2 1/4] perf cs-etm: Generate sample for missed packets Date: Mon, 21 May 2018 16:52:25 +0800 Message-Id: <1526892748-326-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526892748-326-1-git-send-email-leo.yan@linaro.org> References: <1526892748-326-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit e573e978fb12 ("perf cs-etm: Inject capabilitity for CoreSight traces") reworks the samples generation flow from CoreSight trace to match the correct format so Perf report tool can display the samples properly. But the change has side effect for packet handling, it only generate samples when 'prev_packet->last_instr_taken_branch' is true, this results in the start tracing packet and exception packets are dropped. This patch checks extra two conditions for complete samples: - If 'prev_packet->sample_type' is zero we can use this condition to get to know this is the start tracing packet; for this case, the start packet's end_addr is zero as well so we need to handle it in the function cs_etm__last_executed_instr(); - If 'prev_packet->exc' is true, we can know the previous packet is exception handling packet so need to generate sample for exception flow. Fixes: e573e978fb12 ("perf cs-etm: Inject capabilitity for CoreSight traces") Cc: Mike Leach Cc: Robert Walker Cc: Mathieu Poirier Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) -- 2.7.4 Reviewed-by: Robert Walker diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 822ba91..378953b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -495,6 +495,13 @@ static inline void cs_etm__reset_last_branch_rb(struct cs_etm_queue *etmq) static inline u64 cs_etm__last_executed_instr(struct cs_etm_packet *packet) { /* + * The packet is the start tracing packet if the end_addr is zero, + * returns 0 for this case. + */ + if (!packet->end_addr) + return 0; + + /* * The packet records the execution range with an exclusive end address * * A64 instructions are constant size, so the last executed @@ -897,13 +904,27 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) etmq->period_instructions = instrs_over; } - if (etm->sample_branches && - etmq->prev_packet && - etmq->prev_packet->sample_type == CS_ETM_RANGE && - etmq->prev_packet->last_instr_taken_branch) { - ret = cs_etm__synth_branch_sample(etmq); - if (ret) - return ret; + if (etm->sample_branches && etmq->prev_packet) { + bool generate_sample = false; + + /* Generate sample for start tracing packet */ + if (etmq->prev_packet->sample_type == 0) + generate_sample = true; + + /* Generate sample for exception packet */ + if (etmq->prev_packet->exc == true) + generate_sample = true; + + /* Generate sample for normal branch packet */ + if (etmq->prev_packet->sample_type == CS_ETM_RANGE && + etmq->prev_packet->last_instr_taken_branch) + generate_sample = true; + + if (generate_sample) { + ret = cs_etm__synth_branch_sample(etmq); + if (ret) + return ret; + } } if (etm->sample_branches || etm->synth_opts.last_branch) {