Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2218694imd; Sun, 28 Oct 2018 05:37:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5d4HMQR3gqxxUJeWbCQMKAfIVB3Qfxe46pXg6Zyv4s1IAqPSpBS5JCxZfogJlQSw5U4GrpT X-Received: by 2002:a63:36c8:: with SMTP id d191-v6mr9895999pga.404.1540730248133; Sun, 28 Oct 2018 05:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540730248; cv=none; d=google.com; s=arc-20160816; b=dv/jHzhZKTwYQcj+7qd3KCSQt8yuKO3NaA+2zjHG/mRTXJMbvcckwOfuRhR+izXrbI HZpiH3AnBaxmZOWk30k2TqXGkGHvHvpZbr/S8WPPaPwClFhJjwTtd9+aUoSQ0hkHurrS ndySzKA5zKcXp2YyYw3ZepSmOvmKTlHSpBu6ueApOQ9i3TZnf2Aq5cAowu6uAdV6O6zB 3vYX8F4GX2pYggy+3c0tJ/Sq6M2aJJDvEaOj4lOYroOj+gUHsmLdmxJld78JH3l9LIN4 lZFT2gV6W0jMZg083Hv+j6TuKscykF0lpdMmRjKaJqXLBgM5EVNxj7bD6SJut9pWoevr kEFg== 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; bh=XgY8Dmsgnyr0i5Rac8Jw8Y7UJTS++BaAcXwdM3B2J1U=; b=hUv5cvfmHT69tr7lYylLuIkZ6v7zEg4PF8fqGl++liHxVILk/iKhZiuSKbncNComZ3 /GkG1DEyXFTxvR7ai7z4iYD9UcEgMYDk9DHdvkiKFSlYWGGObx0rw++wIM57QLnHV7Ak PaYMkGYtbFylfEjlE8k9JajfCyXJHHy1x79ujOTZ5vrHI9KQmw7hAv3YZOm77RovhAP/ dESrXZQOsSUMBCtGmU8Kq8In3/oUu6QEW8BdMcCxI2q66MMTU3P2VnyH5MLy44nl2Xhx YJPcUgcgsIjwbpANsUWk3xuxJb2wo53JCWSZVeRzEYDRw/m+JETvfsCqjNs+WIfs9BS1 muzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OtudAmWs; 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 d12-v6si17381466pgi.194.2018.10.28.05.37.12; Sun, 28 Oct 2018 05:37:28 -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=OtudAmWs; 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 S1727645AbeJ1VUF (ORCPT + 99 others); Sun, 28 Oct 2018 17:20:05 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:35879 "EHLO mail-wr1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbeJ1VUF (ORCPT ); Sun, 28 Oct 2018 17:20:05 -0400 Received: by mail-wr1-f53.google.com with SMTP id y16so5730469wrw.3 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=ZTnn4YekZTQ+7TaCR8Lh2oXbaepKELgKqPan4YTPgQs2f1W604m05Ov1DfJQyZl6Tq lSJzVfq+v4OpQHVQEDpXWuU+fKg+DfBEYys+YV9PTv5IaTuziR3K5p0Lw/Uoyca6n1P4 93rn6Mvot305zl5rlTAJqzrGQDnasbBRXXjoO4VnGyiaf8u/cm6tbyadSKAxp2fkNzI4 lh4RCZPrPuJn/YFDyuU79ZlLaLNq0VFDow+btzOtW54QdNd/u1VuglJwqE/sfbNkg0ti b0kzQ2+qVCPfhNGiVNBxq45zMGxKcWSOZERumXElRhsRKDstv2JE6XxrAx0ccfT1yvFX 2+7A== X-Gm-Message-State: AGRZ1gJ+zIvHETUYkYRGc36EjlYjEfLNmL08id+m88C2ALzgaiVHQSF6 ZDZjiqEiI22pWUR2SsrE/342HA== 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 Cc: Leo Yan 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { /* -- 2.7.4