Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp215263imm; Wed, 11 Jul 2018 00:48:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeSWxUjTE4GtrINhC8GEzQ3TAPN0zRHszc6pWtYJceN05nqf+rG5WIDJ+HjbikiNs4piCw/ X-Received: by 2002:a62:384:: with SMTP id 126-v6mr11524686pfd.11.1531295321129; Wed, 11 Jul 2018 00:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295321; cv=none; d=google.com; s=arc-20160816; b=mbcGWAZ0U46UvFdwwu+4sH9l/UAuOhbprA/4qMq3p2/dlV4fz8LtHteyl8NPfgsF0L 2gqN5+lbmPQAxijAjTgnAXs/1lgHYA5xtc/Oqo5pz4F1X830z4m1tBWM6GaaPNrFVHNe Q1h8dZRPY5SPIazNFujLKaGYUvmQ9OtubyX91PRdioCcTAFwyxBctSJLKqh5NtFekIg8 EBdvqdlkAmB+kSl0L8tXlXAMw6uq/Nz/Ua4Pahiai30ySLeOAoys3w1tXvJVHf1PKA5Z SSsSPSDQ0dV0K5o9t8DSvCzV/d/zg9f6Ldmc3hMZ3bupP/uP9zU4GZGhWcGby6TBMvBj 0Y8g== 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=IiQfwRzRhFenPKx3syT6YyzO11tbIr5zqBzOVPhTzi8=; b=J3yCAIbFNBJYzGMLhk0NVK3FFGg8oyF6e9kN+g4JOploxguQihA5Ld/NDzsAUUyRlm OcFYoyw7rEc4oPFw/+Ku9OOiMwPtj7emwnyBFkxCQemApQahpXQq6pe10symzCZjXvg7 xbsuFFIQGqtH/mlegtOqci22uyN0lhk78yCywTUELjsrGS0jieUkihdD0qJJArBLxCjU 6Z8XuftfB6ryePe4sk6gRtRqaSMezZhIbUeGHAgueryK+o48as77IfV7LGSdx90r2xLB DEopDHPVY0+QLJhEPRtInIwqEo7nGDbnpBI4qIT7Ml4fQL3bjGz5/+9SN2OwrEgKmlVC imZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QXQJoJag; 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 h3-v6si18441784plb.100.2018.07.11.00.48.26; Wed, 11 Jul 2018 00:48:41 -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=QXQJoJag; 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 S1726914AbeGKHtm (ORCPT + 99 others); Wed, 11 Jul 2018 03:49:42 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33834 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbeGKHtm (ORCPT ); Wed, 11 Jul 2018 03:49:42 -0400 Received: by mail-pf0-f196.google.com with SMTP id e10-v6so17882391pfn.1 for ; Wed, 11 Jul 2018 00:46:44 -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=IiQfwRzRhFenPKx3syT6YyzO11tbIr5zqBzOVPhTzi8=; b=QXQJoJaglHOWDMCetJj+TAAOswR1/izRmxSO0hGE1iL2cnnz1bUm/PnB0903/jLfn/ OyP09mVMvUq1CA52tmFv3cw01cYaUdI7kPKc/58t3/IaqXJZInFx6i5DBQItiOLew04a Y+eVm4EDuEB7m/zhaynTQU/8exKN46fh91JZE= 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=IiQfwRzRhFenPKx3syT6YyzO11tbIr5zqBzOVPhTzi8=; b=Bs6hOS/XpsfhcqEkU94W5EcZcJGsezefI5EE/V4RNWmNq8Jfp9lG9CN9FfA4bcqW+W oRTn2S4etwN+OO0c+AJbQ+3NHzN0dkdDVZfd8Kf3WkvvvXHnV23Mvi8NSzMqPpyQIA9f C6bMXxv8+BhiBlyckWQDmiUTlvZh5ggB3FAqhYnXrHfHBx8E31Wn6MB/oQiBBUGvz5J6 pcxel0UU3hCwsJ008LM1RR03HMQ2YNafw+5jYT72npuQq0ISdhsggt3kt74T3WFS4Z8I wJLYQP7ZS01RMw3x5mPpQnt0ico2uahxwM4bE7JnorwlU5Wn8Ea8+FNluLwm/EjrMdTo SBIg== X-Gm-Message-State: APt69E0dvXBcIyxEOJAT3RlmXLNPoLJbKnV8B6DWhICH+R4NkFNUc4PB 1yir7XVkrwLTw4ThpVEmxdzkBw== X-Received: by 2002:a63:6986:: with SMTP id e128-v6mr3732916pgc.294.1531295204182; Wed, 11 Jul 2018 00:46:44 -0700 (PDT) Received: from localhost.localdomain (li1192-169.members.linode.com. [45.79.93.169]) by smtp.gmail.com with ESMTPSA id 16-v6sm9260374pfp.6.2018.07.11.00.46.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 00:46:43 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mike Leach , Robert Walker , Kim Phillips Cc: Leo Yan Subject: [PATCH v2 4/6] perf cs-etm: Support dummy address value for CS_ETM_TRACE_ON packet Date: Wed, 11 Jul 2018 15:45:43 +0800 Message-Id: <1531295145-596-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531295145-596-1-git-send-email-leo.yan@linaro.org> References: <1531295145-596-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 For CS_ETM_TRACE_ON packet, its fields 'packet->start_addr' and 'packet->end_addr' equal to 0xdeadbeefdeadbeefUL which are emitted in the decoder layer as dummy value, but the dummy value is pointless for branch sample when we use 'perf script' command to check program flow. This patch is a preparation to support CS_ETM_TRACE_ON packet for branch sample, it converts the dummy address value to zero for more readable; this is accomplished by cs_etm__last_executed_instr() and cs_etm__first_executed_instr(). The later one is a new function introduced by this patch. Reviewed-by: Mathieu Poirier Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ae7c9c88..976db84 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -494,6 +494,10 @@ 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) { + /* Returns 0 for the CS_ETM_TRACE_ON packet */ + if (packet->sample_type == CS_ETM_TRACE_ON) + return 0; + /* * The packet records the execution range with an exclusive end address * @@ -505,6 +509,15 @@ static inline u64 cs_etm__last_executed_instr(struct cs_etm_packet *packet) return packet->end_addr - A64_INSTR_SIZE; } +static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) +{ + /* Returns 0 for the CS_ETM_TRACE_ON packet */ + if (packet->sample_type == CS_ETM_TRACE_ON) + return 0; + + return packet->start_addr; +} + static inline u64 cs_etm__instr_count(const struct cs_etm_packet *packet) { /* @@ -546,7 +559,7 @@ static void cs_etm__update_last_branch_rb(struct cs_etm_queue *etmq) be = &bs->entries[etmq->last_branch_pos]; be->from = cs_etm__last_executed_instr(etmq->prev_packet); - be->to = etmq->packet->start_addr; + be->to = cs_etm__first_executed_instr(etmq->packet); /* No support for mispredict */ be->flags.mispred = 0; be->flags.predicted = 1; @@ -701,7 +714,7 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq) sample.ip = cs_etm__last_executed_instr(etmq->prev_packet); sample.pid = etmq->pid; sample.tid = etmq->tid; - sample.addr = etmq->packet->start_addr; + sample.addr = cs_etm__first_executed_instr(etmq->packet); sample.id = etmq->etm->branches_id; sample.stream_id = etmq->etm->branches_id; sample.period = 1; -- 2.7.4