From patchwork Wed Aug 1 21:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 143312 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1377541ljj; Wed, 1 Aug 2018 14:37:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeQ//btF58oafqYaRC0dRYFmnscuZ1S9e8PzKEvrdpUSDwa9RwSuRaNyeuhvOZEM3D4gu66 X-Received: by 2002:a63:455c:: with SMTP id u28-v6mr87431pgk.210.1533159463764; Wed, 01 Aug 2018 14:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533159463; cv=none; d=google.com; s=arc-20160816; b=ER2XhYJZa7/WVG3uLk+rcIyzhsz0ZtPrB87OEdCPbQsuzvf/4qOEU4ncMDrq2xXrDT tcE+CDwUU/LKZMObkXu3pbrcXRB+PDhADuHtoq5VK/FfTE645MUHY+2krJm/RKOqKOAo +tZL/rQf+pzyQEAF43MRqlUPeUsou1mVQytIO+F7RHcu+TqizahniW+kjNX2otptNDJ9 yO4mnqFVqDwuTq7Pr++gWgGOab8QLb/XMOfhaokfsKIUTdj5kdUiGFn4cbJl4HuMbNky 67y9Onje5laMiz3rLGUFodAfARlSKEVzqjT+AST1ncds/+4pozgs6ncznpemU+UB1fhP 1C4Q== 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=QwUCeM5FEp9xxb62CHdnAMcA6Qv838MhjUKuu6sDE9w=; b=qAbDzt2fz8uHV1k8HI7bD1vRDFBNzANjG2ANZ5vBbL198+eUKV6ykjbuOKgZewcGUJ L3zWhS3lvooCeaDySTYczlzbQNunz9gLDT/MetP32DKLzLNjb0t/uPpcbKMMCS1+oKZK AJnihmUm49M4JvCBpsk1ZIdblGwd0chJ1f3efOBhlZVUZIISXioKRXBViUcBT8CZQo51 LwIbNGBWB+JEen04O23O3XXqbJnQEkIvdcwKiMno9/ykXjdo1vve48ccWLK4WfWXxqt6 ZaOAORA6mX8JyNAu/S2i4xcKDcjZ9x+J7qqdvPanT2L9XT4F3aUR3KVEmd4+9XU4i5f4 LxVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fJFp1zSK; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21-v6si82139pgl.148.2018.08.01.14.37.43; Wed, 01 Aug 2018 14:37:43 -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=@kernel.org header.s=default header.b=fJFp1zSK; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387686AbeHAXZ2 (ORCPT + 31 others); Wed, 1 Aug 2018 19:25:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:39370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387439AbeHAXZ1 (ORCPT ); Wed, 1 Aug 2018 19:25:27 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BAC2020844; Wed, 1 Aug 2018 21:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533159460; bh=cBJxGGiRQ8OhCHI0jL0TIWRSIpaffOEAEiNllGfDtW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fJFp1zSK8K9NBuJ+YJ68XgzsGfth4YCaccLSXPC2AzXu0rkrtHS5Dbo0P/31RFvcr aEadS8tbsW4Z0rH8HlSlDw6C1VULxe2nsyhn+x/jyvY0uzpTmeAgpQzTlnfdOhymuI xxRYRnwxkgxqqG/nFfZ5MiX2f2+5RB5zctiXptYs= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Alexander Shishkin , Jiri Olsa , Kim Phillips , Mike Leach , Namhyung Kim , Peter Zijlstra , Robert Walker , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 12/21] perf cs-etm: Fix start tracing packet handling Date: Wed, 1 Aug 2018 18:36:39 -0300 Message-Id: <20180801213648.4814-13-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180801213648.4814-1-acme@kernel.org> References: <20180801213648.4814-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan Usually the start tracing packet is a CS_ETM_TRACE_ON packet, this packet is passed to cs_etm__flush(); cs_etm__flush() will check the condition 'prev_packet->sample_type == CS_ETM_RANGE' but 'prev_packet' is allocated by zalloc() so 'prev_packet->sample_type' is zero in initialization and this condition is false. So cs_etm__flush() will directly bail out without handling the start tracing packet. This patch is to introduce a new sample type CS_ETM_EMPTY, which is used to indicate the packet is an empty packet. cs_etm__flush() will swap packets when it finds the previous packet is empty, so this can record the start tracing packet into 'etmq->prev_packet'. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Kim Phillips Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1531295145-596-4-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 1 + tools/perf/util/cs-etm.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) -- 2.14.4 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 743f5f444304..612b5755f742 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -23,6 +23,7 @@ struct cs_etm_buffer { }; enum cs_etm_sample_type { + CS_ETM_EMPTY = 0, CS_ETM_RANGE = 1 << 0, CS_ETM_TRACE_ON = 1 << 1, }; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 8b2c099e750a..ae7c9c880cb2 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -924,8 +924,14 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) int err = 0; struct cs_etm_packet *tmp; + if (!etmq->prev_packet) + return 0; + + /* Handle start tracing packet */ + if (etmq->prev_packet->sample_type == CS_ETM_EMPTY) + goto swap_packet; + if (etmq->etm->synth_opts.last_branch && - etmq->prev_packet && etmq->prev_packet->sample_type == CS_ETM_RANGE) { /* * Generate a last branch event for the branches left in the @@ -944,6 +950,10 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) etmq->period_instructions = 0; + } + +swap_packet: + if (etmq->etm->synth_opts.last_branch) { /* * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for * the next incoming packet. @@ -1023,6 +1033,13 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) */ cs_etm__flush(etmq); break; + case CS_ETM_EMPTY: + /* + * Should not receive empty packet, + * report error. + */ + pr_err("CS ETM Trace: empty packet\n"); + return -EINVAL; default: break; } From patchwork Wed Aug 1 21:36:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 143313 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1377603ljj; Wed, 1 Aug 2018 14:37:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdbjjnZnZrHy0hpzgKtksanxh6a9qQkbTlb+93xUaVt/pQqCqrcPRGDIar+WHln1gGvWKyO X-Received: by 2002:a62:c0c4:: with SMTP id g65-v6mr100541pfk.72.1533159468618; Wed, 01 Aug 2018 14:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533159468; cv=none; d=google.com; s=arc-20160816; b=goFCED29Hsc4HpBkkLMBckEqU77Ax3KLX0pZSHxy1p5OY24pSxyd0oMFydb4nPzOs1 OpZl0LrwpP1wONzUTIi35VeUCD6o3WV8OuJee0JaMu/TFHokgUEpCBC7gL12Mhlf52nQ dOOnwxF2dDTGa0O1a9xtfVl4+QWmMfgg+FcfnPMvAWpPhE48IO+k3IvuOsU3jsZUvh6m S+QOe63T1Q0L2djOXJxMCCT76FoJREjpmN8Yn7EpuducLBrTQmfDAOQFU5iYKdqFQFvw i0kaYglba/byovpmp1wbbIv/uENT7IYklba/RIZ8SkaapYSdyVLAZPY67lO0GNqM1KGz Ds0w== 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=eLiNKhrcC89RiBt0ThDw0aQ2TE4N5MHtZflUsh3Gfk4=; b=SEYzwAC2Suk9T8vE0zvrWygOKcXDu3CcXuTwCjw3L3j6OgsGjbOMlpSMB5qzu1UM0v HQ3X/dSk7n7NL/CzH/QNBvwDTB6ZCpwxfjEUiIKN04U2W62g5O+UVY2F1IZFJgu1w/4Z x0DOsifivVTuw1XtLskTvTdlHjedNoT1mEmTgT6L6YZKxp+r1GYAN8LFQVxOCGrogS2k PAik/H7Jx8yw0tcqPZb/rxSvOJUtSvDJGp2OVhRBOYAm305QfuipW0GVGkSxyiO4FYDO Tv7697drxaqiAagbZm+tpYAky2nEJF8Z5joBNyB1R0axFugZi5oTatmNQmEc+TlHPC7T /YFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n3Gy9xfT; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15-v6si43366pgh.593.2018.08.01.14.37.48; Wed, 01 Aug 2018 14:37:48 -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=@kernel.org header.s=default header.b=n3Gy9xfT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388496AbeHAXZc (ORCPT + 31 others); Wed, 1 Aug 2018 19:25:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:39522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387633AbeHAXZb (ORCPT ); Wed, 1 Aug 2018 19:25:31 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 833EB208AF; Wed, 1 Aug 2018 21:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533159463; bh=P3EbxfSbhAlP0lDHU95I527JUVWMv16Ylkjp3mX0IUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3Gy9xfTjEeeWZSwDOXS3rbu8BDNrT3FQpXuDa+dcTzYeLn0sJmfpobUDBxnDkNMH bKdfAOu1jWZO/kTmEG4l2vE/629KXYDncu5ldQnj9sUQJ4LyVgtwv5mFzjxwfli/kQ Q4mgVDG8BUhfyy2G2/szg6AuPYKdb6aoAAXtsLcw= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Alexander Shishkin , Jiri Olsa , Kim Phillips , Mike Leach , Namhyung Kim , Peter Zijlstra , Robert Walker , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 13/21] perf cs-etm: Support dummy address value for CS_ETM_TRACE_ON packet Date: Wed, 1 Aug 2018 18:36:40 -0300 Message-Id: <20180801213648.4814-14-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180801213648.4814-1-acme@kernel.org> References: <20180801213648.4814-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan 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. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Kim Phillips Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1531295145-596-5-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.14.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ae7c9c880cb2..976db8483478 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; From patchwork Wed Aug 1 21:36:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 143315 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1378828ljj; Wed, 1 Aug 2018 14:39:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcY8HSvX8gzBExQ+evnJjZRVykNXrXjojpXJ2Qae5VPAsfQReusYRVc26oTyBK3mO/jq6eA X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr46769plb.181.1533159566386; Wed, 01 Aug 2018 14:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533159566; cv=none; d=google.com; s=arc-20160816; b=Phcj11q5Z5jcET/SoPa8WmN+ZqCipGa2w/z3pPzTbA4nGoOO+u7oCxCdCkjtRz/vq8 QjTisBlgsR08f+vy1Aw8Q4k/jlOJDXTqO1vsTgG2KT6LxbVHt6KoLBfMovmk6tTEdTFN jGnGqVyZlhMODsBD1FkIBU/OkOND/htmqoZDlFRkexkT1Bmeer0tNX4Hylculp3qf7ik cftN8iJug06rAj3sbHWJj+mS5YQz7Z/RO2yqNPvvfYpsJPylJX20KyWKA+GSyTD+MtoV cXrNcSQ6KmFsK8ArhNuHeWJGXF7ZFksGy/gepEixw51nYKNGRij6RGKJvHXyL4PmBvyM 1kUQ== 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=+ho/dAztRl0NBinJdfduzic0XwDrf5rMeHeWU22OpIA=; b=CtLRPdsOWzIOEJlignr1qMjwVNNSGRINQ2Mr/RCVdaqqA8RE1LiWhpwqkxU82om9u3 ms0JX2adLHjc6WCuh93GJX36bHhqp2OVd9B29aMYsivWpNdOnLUgZQXedUyw8QAu8udq JFiAZKXEzi2Zn9qBWZns79Mbk5sKSij1W/WNqCA2wK6BeYgI1jaYnt+1m5mKbC8afSEB 2JpPrp2itrnJQkKqkeDOJZWa5xr+JGJOhBaXdyGvBABt68W6p5RtIJAzkCeTQN1+dLQL +pE8kKsX4mKn3jQ9HJ+xwxe/LWYyWlBcbTOGXfy/ytZyfJhbhu4DqeXt0QQ/liv4F82F j9GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a+rOsewF; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11-v6si73517pgm.154.2018.08.01.14.39.26; Wed, 01 Aug 2018 14:39:26 -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=@kernel.org header.s=default header.b=a+rOsewF; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388672AbeHAXZg (ORCPT + 31 others); Wed, 1 Aug 2018 19:25:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:39628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388609AbeHAXZf (ORCPT ); Wed, 1 Aug 2018 19:25:35 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4971A208A5; Wed, 1 Aug 2018 21:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533159467; bh=7PKxdmB4FcUBYEjNnAhtmm43wZS9a9WB6nlc3RVbQfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+rOsewFPObmsjQuhqrD48RJQj+qPrbMyJFjiHZeyAUifvKRX4n1SY4pQYdNqMpIQ /HGkFMHU2WDrZLcsRz9Ko/oQe6+UvMy040vzHGCVx3TC4+OV+jk5lEeqqLzMYJ2bTF pqt7RNZKQXjOeOw0Sl7S8EMRr08mVuVCUe2EAL0g= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Alexander Shishkin , Jiri Olsa , Kim Phillips , Mike Leach , Namhyung Kim , Peter Zijlstra , Robert Walker , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 14/21] perf cs-etm: Generate branch sample when receiving a CS_ETM_TRACE_ON packet Date: Wed, 1 Aug 2018 18:36:41 -0300 Message-Id: <20180801213648.4814-15-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180801213648.4814-1-acme@kernel.org> References: <20180801213648.4814-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan If one CS_ETM_TRACE_ON packet is inserted, we miss to generate branch sample for the previous CS_ETM_RANGE packet. This patch is to generate branch sample when receiving a CS_ETM_TRACE_ON packet, so this can save complete info for the previous CS_ETM_RANGE packet just before CS_ETM_TRACE_ON packet. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Kim Phillips Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1531295145-596-6-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.14.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 976db8483478..d3b794286bca 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -935,6 +935,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) static int cs_etm__flush(struct cs_etm_queue *etmq) { int err = 0; + struct cs_etm_auxtrace *etm = etmq->etm; struct cs_etm_packet *tmp; if (!etmq->prev_packet) @@ -965,6 +966,13 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) } + if (etm->sample_branches && + etmq->prev_packet->sample_type == CS_ETM_RANGE) { + err = cs_etm__synth_branch_sample(etmq); + if (err) + return err; + } + swap_packet: if (etmq->etm->synth_opts.last_branch) { /* From patchwork Wed Aug 1 21:36:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 143314 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1378577ljj; Wed, 1 Aug 2018 14:39:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqk1lE2t8c18vCRchkJx8CpwoJYmhKBuSnU4U7Hc2tCNFiiB1fONSEPjuBGO4XnwP6pqv4 X-Received: by 2002:a63:e247:: with SMTP id y7-v6mr58659pgj.231.1533159547067; Wed, 01 Aug 2018 14:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533159547; cv=none; d=google.com; s=arc-20160816; b=loo9erNeg1FgXcOW//f/LgM2/jdjhV/kQ9z9RDLWvr1mjiXw9Mw/lEifurlnc2/hz7 tkw9ZhCBkAkyBLVrlq2ddxdqGEdNCdFyeGlM07EYrksbL1HxB5/t61n5CHkCt0AViFmS JTsdzwNBMjk8tmPturC0dvBrXk8oFpK5JCIo7KTPEqrRNVWE+oFAmtRFJTSKn/IDhmO0 mqG77PT5tBnC2eFwBnMY+DVbqE8FSv2mNoKTq9V2MilY/4WagsWUtom63BbsxHvxFCCI uJvI2dnJ0Jg9ZKJHz/+TAJMhuMo4u874LQgNQMi5dFt/9rgojT9NeVEC+OWHdGSrS6Fo /h3w== 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=8uvAWMoKirB5Oq2xV9E9FqrCKKNnbnvGtRdfyFGECc4=; b=TQHoK3+q3V9AfpkDcLm72iq/sZ66A96zz76QjyoV4QeUISO4c/eWr9TuLkIjHYvyKq PBfymq08KSicSNqc1CGnJIdjAvZGra3FcB/qvDmnxwpPvdQ9PlzC1s1oHxcN60xokamb LqrY3UHLISkBLO/1tuc437TfUoCVdlDayZT0ib6Nqf2ARPKkG/My3Evu8o8KmbANdPtK 2PX9hAwUUd9hBNVTb5ijaqobPUgxl8rfelBPfwwmXwNhKKnCE1UqDtWnVNwoqgawyp2t c5ULwNGJfZNLNoVagYY3cIV2K2s0ZMq4wPNt5QHvN91+RI2gxAz6mumv+Pz2hGGCo58f QkuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YvFwQ9Y8; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24-v6si86405pgj.228.2018.08.01.14.39.06; Wed, 01 Aug 2018 14:39:07 -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=@kernel.org header.s=default header.b=YvFwQ9Y8; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388873AbeHAX0w (ORCPT + 31 others); Wed, 1 Aug 2018 19:26:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:39752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388731AbeHAXZj (ORCPT ); Wed, 1 Aug 2018 19:25:39 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22FF8208A6; Wed, 1 Aug 2018 21:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533159471; bh=NqiGDYhS9DKP0U4/znGIEYTBKhiCrrjfAp/8MIJXKfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvFwQ9Y8p5E89BIkO9YmOL9r5t6MC8DddMXKgZ54bzyo5PuRizDW0Cy2LM8VLFlfS 8sjG1VV3eIeATNMSQwbh9J8vW3PaiCptGFgTr8dyG9nVU7N+3bS9D0AnJL4SS+UFGB CLURbYRzaoznbAfN+I4R/2ToRD9MGYGcLZu2b9H8= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Alexander Shishkin , Jiri Olsa , Kim Phillips , Mike Leach , Namhyung Kim , Peter Zijlstra , Robert Walker , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 15/21] perf cs-etm: Generate branch sample for CS_ETM_TRACE_ON packet Date: Wed, 1 Aug 2018 18:36:42 -0300 Message-Id: <20180801213648.4814-16-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180801213648.4814-1-acme@kernel.org> References: <20180801213648.4814-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan CS_ETM_TRACE_ON packet itself can give the info that there have a discontinuity in the trace, this patch is to add branch sample for CS_ETM_TRACE_ON packet if it is inserted in the middle of CS_ETM_RANGE packets; as result we can have hint for the trace discontinuity. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Kim Phillips Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1531295145-596-7-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) -- 2.14.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d3b794286bca..2ae640257fdb 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -910,13 +910,23 @@ 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 tracing on packet */ + if (etmq->prev_packet->sample_type == CS_ETM_TRACE_ON) + generate_sample = true; + + /* Generate sample for branch taken 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) {