From patchwork Sun Oct 28 12:34:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 10658575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 258CD109C for ; Sun, 28 Oct 2018 12:37:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 134AF287A0 for ; Sun, 28 Oct 2018 12:37:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 073DF2997E; Sun, 28 Oct 2018 12:37:57 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 6F8A2287A0 for ; Sun, 28 Oct 2018 12:37:56 +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=Bsn+IGWfCcQ/7vjKuTgk6r1GPVoDa4b9qI5i5tA5B8I=; b=OWAOnm4tMbtu6ZUmeQPRYPewyv 7t+up6C6tOlRvqiSRyoucQUQpS4JgnrO07sir0vsjq3JhVMMJ2EBz1870f7jfiC/PxBgzhebp80xf FNoIzGsvw/H5XRYTxvfEOEvdtm7aFEhccK2z5ZVqvrnyEggm5nc4m3TsGVRBk11qKwFumlzb0b69J M85B7Spu8buTUFJHKjnipVCD0n/yBWXHtCYZ/K0MQHTL34mcpNxn/pM2CY1YjEtmgqVxpdy3jGmE0 FjIXyyuIkInkYNCPzgZpdsmCuCvCO8ON6MkIgpmJBg3B8gdoGIFf6OY1J0khnTFHGdUPBsqFxypJ4 K/FnumuQ==; 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 1gGkK5-0003XU-1D; Sun, 28 Oct 2018 12:37:41 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gGkIC-0002dm-7A for linux-arm-kernel@lists.infradead.org; Sun, 28 Oct 2018 12:36:05 +0000 Received: by mail-wr1-x42f.google.com with SMTP id u1-v6so5752129wrn.0 for ; Sun, 28 Oct 2018 05:35:33 -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=XgY8Dmsgnyr0i5Rac8Jw8Y7UJTS++BaAcXwdM3B2J1U=; b=OtudAmWs506HqkYJfYy3vJ55svZ6VkX2cZMqUz9i+JhuoF2ntYElB0mEaTq2N1lkkD 5vH4qtzn7Fk7FwM70EGM5ZXMMBL2jYbFDNAxCFaUwUYNGUMRDgBfQXVTtu2FzQYvOM1B PqGdvhB4hSFV3uF3d+76h3QcSxjkjqPyWirAI= 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=XgY8Dmsgnyr0i5Rac8Jw8Y7UJTS++BaAcXwdM3B2J1U=; b=PHsnQj12w1QefU9mAuVMspBUit96dBx12nO+7ZSrWo9TIbcR8IMZKzez8l8/JV6Sk9 pKewTc0XCiqe0EoiKOtJVFNU0Gyznn6GLkD3cAuiE7gLxUUvaAQ9r9LRMJ7UXXRuXOAW NwhUAheePevPuReLi83W9rKEoi1rNrctQwMU7PjIl6Qpr85/wFE+f+UMAeEKOY+RSjGN DYPjvCeBLcz0EWKH1sVhV6nmpZrkRAs2nMXBvKXAZo2Kuu/b8Mju3WadyIUC53Kq0LJF KIElzLEuDf4YwA2PfTVD6e64N1Ux0t5Q7dxYsP/KhPUt/yO8YY31JZ1L/Vr0L1cbbNAN 5xew== X-Gm-Message-State: AGRZ1gK2T80SDW5vUpoGVmJZuEEfUBPwxJHCaqNLqWI8IWxvtXzBfKI3 DZ14v4R4eBF5vAIIYDuXLXwPtbqwuNC4XWH2 X-Google-Smtp-Source: AJdET5drWtdY1i8bsNRTUoYTOcn9DJTr80GkVnx0B1xuNd/1jTxdotEZhbiwHQspoxTxv6+dt8jNJA== X-Received: by 2002:adf:ef41:: with SMTP id c1-v6mr10536749wrp.33.1540730132437; Sun, 28 Oct 2018 05:35:32 -0700 (PDT) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id v30-v6sm18926830wra.67.2018.10.28.05.35.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Oct 2018 05:35:31 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML , Mike Leach , Robert Walker , Al Grant Subject: [PATCH v1 4/4] perf cs-etm: Add support sample flags Date: Sun, 28 Oct 2018 20:34:55 +0800 Message-Id: <1540730095-6732-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540730095-6732-1-git-send-email-leo.yan@linaro.org> References: <1540730095-6732-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181028_053544_275243_B42305CD X-CRM114-Status: GOOD ( 17.79 ) 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: 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 We have prepared the flags in the packet structure, so need to copy the related value into sample structure thus perf tool can facilitate sample flags. The PREV_PACKET contains the branch instruction flags and PACKET actually contains the flags for next branch instruction. So this patch is to set sample flags with 'etmq->prev_packet->flags'. This patch includes two fixing up: if there has TRACE_ON packet in the middle of instruction packets, the TRACE_ON packet indicates the trace is discontinuous, so append the flag PERF_IP_FLAG_TRACE_END to the previous packet; if the coming packet is exception packet or exception return packet, also update the previous packet for exception specific flags. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 00a95d7..7e36dcf 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -655,7 +655,7 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, sample.stream_id = etmq->etm->instructions_id; sample.period = period; sample.cpu = etmq->packet->cpu; - sample.flags = 0; + sample.flags = etmq->prev_packet->flags; sample.insn_len = 1; sample.cpumode = event->header.misc; @@ -711,7 +711,7 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq) sample.stream_id = etmq->etm->branches_id; sample.period = 1; sample.cpu = etmq->packet->cpu; - sample.flags = 0; + sample.flags = etmq->prev_packet->flags; sample.cpumode = PERF_RECORD_MISC_USER; /* @@ -945,9 +945,13 @@ static int cs_etm__exception(struct cs_etm_queue *etmq) * The exception packet includes the dummy address values, so don't * swap PACKET with PREV_PACKET. This keeps PREV_PACKET to be useful * for generating instruction and branch samples. + * + * Also update flags so can tell perf it is exception related. */ - if (etmq->prev_packet->sample_type == CS_ETM_RANGE) + if (etmq->prev_packet->sample_type == CS_ETM_RANGE) { etmq->prev_packet->last_instr_taken_branch = true; + etmq->prev_packet->flags = etmq->packet->flags; + } return 0; } @@ -965,6 +969,14 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) if (etmq->prev_packet->sample_type == CS_ETM_EMPTY) goto swap_packet; + /* + * The start tracing packet is in the middle of instruction range + * packets, this means the trace is discontinuous; so need to set + * the previous packet flag to PERF_IP_FLAG_TRACE_END. + */ + if (etmq->prev_packet->sample_type == CS_ETM_RANGE) + etmq->prev_packet->flags |= PERF_IP_FLAG_TRACE_END; + if (etmq->etm->synth_opts.last_branch && etmq->prev_packet->sample_type == CS_ETM_RANGE) { /*