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: 10414285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E06316032C for ; Mon, 21 May 2018 08:54:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D006028738 for ; Mon, 21 May 2018 08:54:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3DCA28763; Mon, 21 May 2018 08:54:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43AEA28738 for ; Mon, 21 May 2018 08:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=vq3eE1xnxCQPfECu94mCxuZoVFRJsJo36vWPSrv0l64=; b=V3fqYOWuuXDFEUNYx+gEXhpfvA EjHRy8KfuidkJKkYbkAAv5RhBYkZ2aIDlMpj4NAdh6EjQsQdQyeOxYSipl+r1f2Vg15DS23pu/NgK 8Pb2jjjHtNEbvG+xanM0yJ/Sh/sIv9onVA5Mr/rOm0jhEXYUkkaV2iGXmo/71jgZlYph6zIWxexar L8ZB2uBKWHzWg6CjlKrcQD3Ow4wI0lqfappUQX+9Mbg6UJKbWtv8pCIDdivVYT1hXN9iOQIiUTBcC E5R+VzFlZFfrueMwyvYhyMjMF7z59SEBrmZFKtJw6wKNOEkno+eDRfNoM2fKgqr49eAwvfXSiWykF sxv8xY2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKga2-00030O-5k; Mon, 21 May 2018 08:54:10 +0000 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKgZk-00022w-M8 for linux-arm-kernel@lists.infradead.org; Mon, 21 May 2018 08:53:58 +0000 Received: by mail-pl0-x241.google.com with SMTP id c11-v6so8424546plr.5 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=bhIw94RlU37dNmuZ4ic0npgKkyS8IHy+wkd+3QmEZq8agvwljhiBqI2W06qzkxXPhJ YWnP2gHt2munapBfrPnmp+pWxLIoEOHPTh4Em14cSNYtqhQB0uqFZy0P3XyDzw9NGgPx P797eLNCKF9RPPXTMaP9yGM6QCj+rO6v0kWf3H30tSQkLGsuDw34KyIYMW/CJbSBGqrG Fy3hXDg4l+oRnhX2Yti6rbpTOMeNqrsBpyHGBp68W8fekwfgnoh8GDcDTmZZV1FU3tXB NxuHv1aA9ba5zJHeh7a4Z7y1VoKl/haQ3Fm7p55pMFuuw3RALgolQID/YA1OvMYm/KXR 9Rkw== X-Gm-Message-State: ALKqPwc6BVQaupuYt9vKp9SMe0jcWm/f6nZ+GYNiSsLRUxaGQ16Rfum3 c+Kf81lCtpBeX1zXBy0cbNs6fw== X-Google-Smtp-Source: AB8JxZp5xFRhgLXBvPl0v2l+N7VwXcmVdxFlSmLXYXu4uOYpyosaq/go0AYujvqH1A1b/2eQ8UGmKA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180521_015352_742292_6D6EA05F X-CRM114-Status: GOOD ( 19.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robert Walker , Mike Leach , Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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) {