From patchwork Tue Dec 11 07:38:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153395 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324644ljp; Mon, 10 Dec 2018 23:40:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmsdodnVlBhjFc67/MGtbzDV3VUc80Aa8ZuybpsELId60Ho7OHvFFJ2PJ5yjCzltI+MWRD X-Received: by 2002:a63:a51b:: with SMTP id n27mr13942989pgf.17.1544514034307; Mon, 10 Dec 2018 23:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514034; cv=none; d=google.com; s=arc-20160816; b=HGK2VBu+ZVhGdLI6QJc4JNZBsRBEQHJZ/mAZBAWL7jUg3U8UO3VotpIaaAatWJgEDK a3+Vm7lWs8ohsyxkaoQpRvy4hdUxUmQg933gwGPTAJDjSEOHjOxqx9qqqKdoTndvRDNR SBnZj0S3yNhvgQlooRFSD+Ody+2NeaAtlb48QXyyetCSOpJpmphEOF9RDgRswVYgefXG km5cIQVumSuEdYMHET4n1esTCd/Txm1Y/E54Tc12xMwyz7kcxb7GoXGOUyUw6A9UY7oh QGzMb6gk9taTZ75O3uyVMrpJ5CKU7mw4Fpx2+XzRlhd/nzb9J3MGVsTzT/kdo9qgOoxl SZhg== 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=DdJei3MXkGiE0iSB4u2n/6IcLLnmeX4skh5tiKXlEYc=; b=YG4GIBPR7mgM2tlQFiBx9FNGqYg1VrKblB+v+czPEZoiWIJ5bJYIf+OC5qq3JwF0/D AQOnKkHyN2QTeb6ZSm+4cYM39Xwx+HFbHJOHcK8XHyvi6lvUPQ36GKgwMM+7N4a3aOBJ oHREQZTEi2RrJ+uRelPoqWX8/kxn94uuPD5t+TYRcVdeD6PStMJpEAlvYpZ6PDAnbI3o FsVqZ3S/oWFuvx0A8Da/TTQ4N716e0kJ95Lh3oT/96Buqwe4FaHkul+NgC7uexi+a7rn kNvMv/6BOzz8p4sxcTf0olbYdWAZfiL02FA3aBjQ16WZmsvUY8w+71yv6eZh8ObGfduh /g9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pelw3oX0; 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 e136si13347052pfh.17.2018.12.10.23.40.34; Mon, 10 Dec 2018 23:40:34 -0800 (PST) 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=Pelw3oX0; 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 S1726226AbeLKHkc (ORCPT + 31 others); Tue, 11 Dec 2018 02:40:32 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39291 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHka (ORCPT ); Tue, 11 Dec 2018 02:40:30 -0500 Received: by mail-wr1-f68.google.com with SMTP id t27so12956178wra.6 for ; Mon, 10 Dec 2018 23:40:29 -0800 (PST) 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=DdJei3MXkGiE0iSB4u2n/6IcLLnmeX4skh5tiKXlEYc=; b=Pelw3oX02t5Wn+zKQ4m+N8Q2Dtp048djj7lyuhalY/P2THi7fEdeG+Bdnq1t9DWCFK fqtZNs8ALDy2Mz2QZiMlVxvS6eXVEY+0sXKLexHhklfSFc8m8IGnjV8dgEgFf4Y9KJS8 mN58fXhibOuSqg/6lEofkfd1OuiHWd5HpeJaA= 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=DdJei3MXkGiE0iSB4u2n/6IcLLnmeX4skh5tiKXlEYc=; b=ZS9bmYD7ThZJc/0r4B2UKrzprMGX2atbNs5mAYoZQ1IzyK7Xj2Rpujatpf6QN0d0zL Zj+86z8A7j4y7PSm6Vz9jx57xHwIprE+MVsMG/nvpvcQrv5+uOQZGeB/vN08MqBNBLzR Rwcc/yvba07Alda3Z3KfXCfCb1SDR+pcNoGx/owYZkjZBSumuItbpfReM0TdwMmK0thq w5EiNioyUsQvq9PeRxyeFuyLRHOLcscZ1yeaJdnykad96dAqjzUKwv+o3u3VW6w5pL2C xL/pKZo4g3oYOjwu6GAWsspg0lB0KKEww60W0Jhx/1sF/HHoopttZzjVCd04tx3OspXz XC9g== X-Gm-Message-State: AA+aEWakqiNlPKu+Bg5qx+yssCc48duOPI4UAvTK07etmzcY+LCVDulc bh4Vpjznvhi+nGDm2Wck3plJ7g== X-Received: by 2002:adf:efd1:: with SMTP id i17mr12066007wrp.200.1544514028756; Mon, 10 Dec 2018 23:40:28 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:27 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 1/8] perf cs-etm: Correct packets swapping in cs_etm__flush() Date: Tue, 11 Dec 2018 15:38:21 +0800 Message-Id: <1544513908-16805-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 The structure cs_etm_queue uses 'prev_packet' to point to previous packet, this can be used to combine with new coming packet to generate samples. In function cs_etm__flush() it swaps packets only when the flag 'etm->synth_opts.last_branch' is true, this means that it will not swap packets if without option '--itrace=il' to generate last branch entries; thus for this case the 'prev_packet' doesn't point to the correct previous packet and the stale packet still will be used to generate sequential sample. Thus if dump trace with 'perf script' command we can see the incorrect flow with the stale packet's address info. This patch corrects packets swapping in cs_etm__flush(); except using the flag 'etm->synth_opts.last_branch' it also checks the another flag 'etm->sample_branches', if any flag is true then it swaps packets so can save correct content to 'prev_packet'. Finally this can fix the wrong program flow dumping issue. The patch has a minor refactoring to use 'etm->synth_opts.last_branch' instead of 'etmq->etm->synth_opts.last_branch' for condition checking, this is consistent with that is done in cs_etm__sample(). Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 23159c33..789707b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1042,7 +1042,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) } swap_packet: - if (etmq->etm->synth_opts.last_branch) { + if (etm->sample_branches || etm->synth_opts.last_branch) { /* * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for * the next incoming packet. From patchwork Tue Dec 11 07:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153396 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324696ljp; Mon, 10 Dec 2018 23:40:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/UGDhdTQ00Gaj/Eyeigst76bszupKVeioFA6xJSBUgxKzJ01rPTPIgwpFWkUH4dRE42ut3Q X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr15287137plb.244.1544514039667; Mon, 10 Dec 2018 23:40:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514039; cv=none; d=google.com; s=arc-20160816; b=AIIbPmvbb0hJdGhPRBIWW0J4YZZFD1OS4nGq58J51f+CqWwBU3XO2BOBlZvMl6WMSr L+73EuSlczjpzAz2z1JL8si6n6dWneXRuj7h4S4bBJk/Ko3Yq0ZLisg0Ph5O4gz7rKxA fPWX0rlsNCd0HI0V0ZEZT2gCeh3AeQwPf3VTRUPTMlGqwc/6GvLIgqOke1TkyTgyAJyL G1HGPr+u/XSxpuoTRrL0BBcWUvTzOPZXBGXgABBLVCUYLEIOwntqTGjvkWvP7G0pcMVd vBi9orZKEY5Gu4TXmv2QN6eoR574+eUH1uiFNEc/dY5FdMBvgwz1SqGi3hUl47P2pgSX 13GQ== 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=mLWiAqN9O2/h7R2V1jDZK7ROs4Kq3pLvcay7+sOXvAk=; b=hg37HxKGKc7nqVBSeIXPuRPIlIwGSmVT2GUvNPb6uxTcgSyVPlaNzuNk93N5+7j4oI Kq0KrdVN4OjjUXiknXLJ2foK/wImCC4VA64WhIhENYKMRzQMhAg1L2PxCi/3o1e0gHuN 0HG72FpNWRKcUyLn5isfx2IbPOymBObtT/D6MfjjecrtLgo2qehhJxTZlXHkWirL+lM9 oL36acDz5AjEAD43hBjJPkK/7obwFra1SPa0JgHy88Pt81inTOjz+NVtW5SgzLm+sQE0 2JGreptAm6bCsTY/Sxyao5gjTUOf8gcAJ67IZ27YVZ2+QxwTgD8j3cYJgomjtFjAaz4g n48A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IgzZwIgR; 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 36si4850662plc.300.2018.12.10.23.40.39; Mon, 10 Dec 2018 23:40:39 -0800 (PST) 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=IgzZwIgR; 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 S1726238AbeLKHkh (ORCPT + 31 others); Tue, 11 Dec 2018 02:40:37 -0500 Received: from mail-wr1-f54.google.com ([209.85.221.54]:45990 "EHLO mail-wr1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHkg (ORCPT ); Tue, 11 Dec 2018 02:40:36 -0500 Received: by mail-wr1-f54.google.com with SMTP id b14so12949213wru.12 for ; Mon, 10 Dec 2018 23:40:34 -0800 (PST) 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=mLWiAqN9O2/h7R2V1jDZK7ROs4Kq3pLvcay7+sOXvAk=; b=IgzZwIgRJYXQqYm4CKMxjNs8DOwkpBTMmA2RqZsUDz0n5lKYvy1PIY7p2OxGnpbfzD 5c57q1h8fV0zuqoGByB+LWOJgV8lwQQZs/jYNIfNlBrOmLDEY9P5/HGzoxwJke1xB7qs BlEmYhpZwAlinsi76PLA+86t/oAWID8wS9Ckg= 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=mLWiAqN9O2/h7R2V1jDZK7ROs4Kq3pLvcay7+sOXvAk=; b=Bq873YSBJXJQ5MDfPxI3/VpzY1TMb2NrOaRhNty1rZQu4IsJC7Vt6TDS1KTDkjB16n iYfpa3nKtDypu66XnlYaRd/UKm2CssT6+yj+iJSc5TCGVONRkGbZsrZ4cIUojuebCFQY NkUYny/GhJmvD53Cbp651721pQ/XGL50SkRMiMf777ApJa1AprfGEf2xUZ3dx1mNKils 7SmrAPD+U8Q7ESdAS0zWElFintGdQaOSBivBwX0c2ln7iLm6KtaK5d2Cyj+QKnlUCNWN q3TZok0V77kjRaCMA3DGA0jNpKYwXihGh/qt9uLImyIp2psT3ryYtAQax+BPLVfqdjxr 4B6w== X-Gm-Message-State: AA+aEWYc/ttjY7ggcs7t82OLnqsmWUJiRb2XrNToTZti6EP0XmpKKYYA if/QdMxSmkB8B9h0B0B+x5kmAA== X-Received: by 2002:adf:e149:: with SMTP id f9mr13540430wri.42.1544514033386; Mon, 10 Dec 2018 23:40:33 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:32 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 2/8] perf cs-etm: Avoid stale branch samples when flush packet Date: Tue, 11 Dec 2018 15:38:22 +0800 Message-Id: <1544513908-16805-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 At the end of trace buffer handling, function cs_etm__flush() is invoked to flush any remaining branch stack entries. As a side effect, it also generates branch sample, because the 'etmq->packet' doesn't contains any new coming packet but point to one stale packet after packets swapping, so it wrongly makes synthesize branch samples with stale packet info. We could review below detailed flow which causes issue: Packet1: start_addr=0xffff000008b1fbf0 end_addr=0xffff000008b1fbfc Packet2: start_addr=0xffff000008b1fb5c end_addr=0xffff000008b1fb6c step 1: cs_etm__sample(): sample: ip=(0xffff000008b1fbfc-4) addr=0xffff000008b1fb5c step 2: flush packet in cs_etm__run_decoder(): cs_etm__run_decoder() `-> err = cs_etm__flush(etmq, false); sample: ip=(0xffff000008b1fb6c-4) addr=0xffff000008b1fbf0 Packet1 and packet2 are two continuous packets, when packet2 is the new coming packet, cs_etm__sample() generates branch sample for these two packets and use [packet1::end_addr - 4 => packet2::start_addr] as branch jump flow, thus we can see the first generated branch sample in step 1. At the end of cs_etm__sample() it swaps packets so 'etm->prev_packet'= packet2 and 'etm->packet'=packet1, so far it's okay for branch sample. If packet2 is the last one packet in trace buffer, even there have no any new coming packet, cs_etm__run_decoder() invokes cs_etm__flush() to flush branch stack entries as expected, but it also generates branch samples by taking 'etm->packet' as a new coming packet, thus the branch jump flow is as [packet2::end_addr - 4 => packet1::start_addr]; this is the second sample which is generated in step 2. So actually the second sample is a stale sample and we should not generate it. This patch introduces a new function cs_etm__end_block(), at the end of trace block this function is invoked to only flush branch stack entries and thus can avoid to generate branch sample for stale packet. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 789707b..ffc4fe5 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1055,6 +1055,39 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) return err; } +static int cs_etm__end_block(struct cs_etm_queue *etmq) +{ + int err; + + /* + * It has no new packet coming and 'etmq->packet' contains the stale + * packet which was set at the previous time with packets swapping; + * so skip to generate branch sample to avoid stale packet. + * + * For this case only flush branch stack and generate a last branch + * event for the branches left in the circular buffer at the end of + * the trace. + */ + if (etmq->etm->synth_opts.last_branch && + etmq->prev_packet->sample_type == CS_ETM_RANGE) { + /* + * Use the address of the end of the last reported execution + * range. + */ + u64 addr = cs_etm__last_executed_instr(etmq->prev_packet); + + err = cs_etm__synth_instruction_sample( + etmq, addr, + etmq->period_instructions); + if (err) + return err; + + etmq->period_instructions = 0; + } + + return 0; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { struct cs_etm_auxtrace *etm = etmq->etm; @@ -1137,7 +1170,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) if (err == 0) /* Flush any remaining branch stack entries */ - err = cs_etm__flush(etmq); + err = cs_etm__end_block(etmq); } return err; From patchwork Tue Dec 11 07:38:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153397 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324722ljp; Mon, 10 Dec 2018 23:40:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WvnaZ2IiA6iEgyrMGP22CUiB76Y4cqkLqddCje9RLROV6n61SHMfTbIYIl2Rq/z0WgPj2s X-Received: by 2002:a17:902:b40d:: with SMTP id x13mr15321481plr.237.1544514042947; Mon, 10 Dec 2018 23:40:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514042; cv=none; d=google.com; s=arc-20160816; b=G4s61DEw8RrxBqec8+0W88ryJOOaKvfkz1WP3GvGbefSJf8tjORmdLXr6ErvuYt16w JpD/YF1YfC71xOZX2gu//CuNZjlTTqjeeZBNH3sX70ohxseWrTuFi+1eccSxGZp9fMWi QQsK3ErxT9LjYFDzRJ16CrTYdslO2jRv1q/hkmHdUKjk1f3CJTHMmfGHxeKAv0TlsqwP WpkCmCoGnlMRuP2TB9PdNjt+1AkROLqq11p/CSgpyOdcuHmOIW6adbuIn2tRB4wrFWXh WZQvfdWqfkYbYE9e8Q9NULoeM2kXgvOhl70CTnqCiZo0oYRyT+KkNdILt0CQ9z30KpXr haQw== 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=QhESnTtb4oxO4oqXaTFof3KV9a2FuHSEH5X1fFwTnNc=; b=NjG+3jvArFfGQ8IVi26ok+9odgdFfzkF02Yyxf6yYDExIfMPEhtcTka3XFt9V88KQh MUvtqiQjXn74vFdDuKgy3HxkYjd3BGytoAEnwRCr4m9hudELe1/ChyWxjIiIQMAw/rjT y81pVh8T2DPdeArcXXXuzeP7qZMuDk2W+w9eydYLqLS/PcGxq5eoVJutEBwb7yhOulsw DEbJBYc1gsZo4QU+nsXjgWdL3tobUcY5llvL05r8uDm/B9GnKoNhUNhBbmTDQ7kYptsG Sr0enHv9tr3wjfwatTmntXjdFL9qgTvOrhUobxuByV2yKWL3gM2b70js3WfprLlW+fUu Wnuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Apj1oepu; 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 36si4850662plc.300.2018.12.10.23.40.42; Mon, 10 Dec 2018 23:40:42 -0800 (PST) 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=Apj1oepu; 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 S1726249AbeLKHkl (ORCPT + 31 others); Tue, 11 Dec 2018 02:40:41 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33851 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHkk (ORCPT ); Tue, 11 Dec 2018 02:40:40 -0500 Received: by mail-wm1-f65.google.com with SMTP id y185so8328926wmd.1 for ; Mon, 10 Dec 2018 23:40:38 -0800 (PST) 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=QhESnTtb4oxO4oqXaTFof3KV9a2FuHSEH5X1fFwTnNc=; b=Apj1oepuxBiwwnLA8c5LR5Jik9SIHfQZ8dkw0tuhXTFNOxPc5d056h+3dFcSglG/HH VZHec2p1IFf+JHPTK24iw/CLhr0WYHCm+Znz6hqURz6vWScBUmPalXhdRsNwASY1/EjI v1wrrs//QbCvT24ResV8UxDGKMDcptWXWoX0w= 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=QhESnTtb4oxO4oqXaTFof3KV9a2FuHSEH5X1fFwTnNc=; b=LqZ4YbGXWLcW/QTEKIEkbnoLyxqRSTcdFznjE2l6fKGxXJW3pHXFYPnnYaur6NUpD8 TJx8Z7hQ5ehFeO8OU66c2K8+G++ct5KUfqEVhM7k2CkSVdCR3topdAyNbyEcU4aBlOF2 pMAerxJj9OsdhoIW2WpPz9rWVVXgLelo7Z/dAOLk6jESqC6/9J8BJITY5o/PaFQVCKfs xEsw0ej68ZQcV7+ke+tSQt+tW+O6Yi/tLNvNveep7a+oiwolir9ptYuAXk3a8pgr0MHA kpkRCaEckaazaApYmjATb02ueknysgYJQbL1kjG+iktfA3Qdo0GwXl+NVOPd3aHepp8k WZkA== X-Gm-Message-State: AA+aEWY5095fA/4CXinn79VE7zFgIOUlHQilwjOMut+mMDL3GcwA2x1A PXV6E6L4f08PiQV4MKqGh5tUVQ== X-Received: by 2002:a1c:1112:: with SMTP id 18mr1367049wmr.30.1544514037870; Mon, 10 Dec 2018 23:40:37 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:37 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 3/8] perf cs-etm: Remove unused 'trace_on' in cs_etm_decoder Date: Tue, 11 Dec 2018 15:38:23 +0800 Message-Id: <1544513908-16805-4-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 cs_etm_decoder::trace_on is being assigned when TRACE_ON or NO_SYNC element is coming, but it is never used hence it is redundant and can be removed. So let's remove 'trace_on' field from cs_etm_decoder struct. Suggested-by: Mathieu Poirier Signed-off-by: Leo Yan Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 3 --- 1 file changed, 3 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 0b4c862..97b39b1 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -36,7 +36,6 @@ struct cs_etm_decoder { void *data; void (*packet_printer)(const char *msg); - bool trace_on; dcd_tree_handle_t dcd_tree; cs_etm_mem_cb_type mem_access; ocsd_datapath_resp_t prev_return; @@ -411,12 +410,10 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( case OCSD_GEN_TRC_ELEM_UNKNOWN: break; case OCSD_GEN_TRC_ELEM_NO_SYNC: - decoder->trace_on = false; break; case OCSD_GEN_TRC_ELEM_TRACE_ON: resp = cs_etm_decoder__buffer_trace_on(decoder, trace_chan_id); - decoder->trace_on = true; break; case OCSD_GEN_TRC_ELEM_INSTR_RANGE: resp = cs_etm_decoder__buffer_range(decoder, elem, From patchwork Tue Dec 11 07:38:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153398 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324760ljp; Mon, 10 Dec 2018 23:40:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/Umfa92uvxiKi0YczRfcvymEJ4BKwH+kyG8RITyqTKuvAiolc5XUUUneeDv4hIJc1G2HdUo X-Received: by 2002:a63:4706:: with SMTP id u6mr12938766pga.95.1544514046950; Mon, 10 Dec 2018 23:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514046; cv=none; d=google.com; s=arc-20160816; b=weNCh6zncT/28OYKOIO1XJ7ivWP6maqZ8PDvGrWhoMQUfqU5MC4ua+17ugfWpC6wNn IEnyrK/YBvUvPP9c8EPIquqEvUXQOfokFbsypLxbv5r9437o1UV6WQq9ZvHyt0J/PCzr OyCAlb49u7ubvTCb4gl7oe5o5VygrKFfm9B21+1i+BSwuVGPLdTIVNzi3snH2ocUksNE uWEfScIgSgb0RC4SsIBMueujhpkCcTMtwYOFm0bMWDcIj2T+gJ96woCfJYSb951zoEdC e6+Sag/PV/gxgpz3MOa2GppWQpo6G0FlAQgOmKKjDTv5g9eH54XsVbSI++GLzzRXl81K nLMA== 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=7KsG51IyxvMCicfAhv+X1OucWXiA4qhwMKrH6icak5k=; b=XvJShmQq/HwTzvuk8r7jr94FAiwigakSbtSIdfK8JReDISvGVo8RYQKqeJI8JV4lAI mAuA/YFH/twdUkMYw4Azy4Z6QPKhxzck7yvPPkvW9ROG8A4BLoqO7G0KCU7eyhXEAooM bDk3MuFisbBXe+5R8bXGmUygxBi16OcA+1pHf7ZQAx2LUAbwtXyMiHFTKU2wE+i/b5b1 Jm4FEBeGzOkoukUW6/gIPQ07mn+Ds6awXBlm7MZgcm62/9rEFjqN4KNgK4WFEwi+44TF vvi7r7Y/8YDLvomlznphYbPa4OiH0xxsT2pBNHps+FjYbJ82NZldws9OmakMTJweiPSQ jflA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iMxLwRDg; 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 h36si10843508pgm.200.2018.12.10.23.40.46; Mon, 10 Dec 2018 23:40:46 -0800 (PST) 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=iMxLwRDg; 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 S1726263AbeLKHkp (ORCPT + 31 others); Tue, 11 Dec 2018 02:40:45 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38508 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHko (ORCPT ); Tue, 11 Dec 2018 02:40:44 -0500 Received: by mail-wr1-f68.google.com with SMTP id v13so12980208wrw.5 for ; Mon, 10 Dec 2018 23:40:42 -0800 (PST) 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=7KsG51IyxvMCicfAhv+X1OucWXiA4qhwMKrH6icak5k=; b=iMxLwRDg3PQZUIpt3OlWqvTuEZfmbgtvhqfN8lG6OI91R7LsqBjlMjaOJlM99vkOZx 3exwV5HwXGH2rCT3nY9ZsH+wCRn4rwnfqZyO6w/n+FaUClJIikrQeQuipGq3cyDaJY4m PXc3GJxPvBDLcnD7eqIUO5uVdK3nwjoj2lRxg= 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=7KsG51IyxvMCicfAhv+X1OucWXiA4qhwMKrH6icak5k=; b=dkRrmX9P6iYgpfMlnZdF0wXu4l+HrUnafQIlDDYrxK3vQHRYUvUXzyVCdNM0DHkRPI 6EmxZnQr8J4d6/OnrfP+UW3Cxc+QsxpWK7iP0pUiS2dQ82z75UBL1uXGiENfoVzVp7P2 ragHfaLsfrGHOY16sXdhJrJYuuRGDAYj3YcJgoxDnvowziS9JV26EhWB1VL3lUQopGiu RTaxacwL2Z3kpUpCRU4ocMafo1JQ04AW9IzhgxbM27RsDwbrfXf/3va65d6Bndr2dxDL q9V10k7gJPC2a7F2OXhcLrVthsY7cegrXsxVoZok5jE+eDr2VTX7gaGgc0n10qwICf1C FuCg== X-Gm-Message-State: AA+aEWbp+6U3xsODym8uv7AjnWXmja/HXuVjGqODj4UlhKqgeE2Xem0p oVjRLKLDxmLLIkZ+wbtvyGf0UQ== X-Received: by 2002:a5d:6988:: with SMTP id g8mr11886334wru.33.1544514042362; Mon, 10 Dec 2018 23:40:42 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:41 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 4/8] perf cs-etm: Refactor enumeration cs_etm_sample_type Date: Tue, 11 Dec 2018 15:38:24 +0800 Message-Id: <1544513908-16805-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 The values in enumeration cs_etm_sample_type are defined with setting bit N for each packet type, this is not suggested in the usual case. This patch refactor cs_etm_sample_type by converting from bit shifting values to continuous numbers. Signed-off-by: Leo Yan Cc: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 Reviewed-by: Mathieu Poirier 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 b295dd2..3819a04 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -23,9 +23,9 @@ struct cs_etm_buffer { }; enum cs_etm_sample_type { - CS_ETM_EMPTY = 0, - CS_ETM_RANGE = 1 << 0, - CS_ETM_TRACE_ON = 1 << 1, + CS_ETM_EMPTY, + CS_ETM_RANGE, + CS_ETM_TRACE_ON, }; enum cs_etm_isa { From patchwork Tue Dec 11 07:38: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: 153399 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324824ljp; Mon, 10 Dec 2018 23:40:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/VQWWm/NFXUTfCeLdr/yqxOn7n1xwHOYXdQx+J7Mo2cm7eDlP+UyIosPHAYBoQSiXf1hZZy X-Received: by 2002:a17:902:b03:: with SMTP id 3mr15022421plq.91.1544514051275; Mon, 10 Dec 2018 23:40:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514051; cv=none; d=google.com; s=arc-20160816; b=hDXgVk4OrCOEYv6Pnxp1rzMAIy2q5boJKhAWdH62SDglFhk03rXy33K2tYFk64k2X/ EZEFE6vxofFLRZGjeAGlQGFu2IEgusksvbP3N1NLeZo2hy7vriJaIco0Lv4iQKvhd37b AfJtWCUeJEed/X15W/KSi80B/GrqljQ46l5aZPzrHVrW2jQVynCjcOU9QAB6/EytSksr 0lbFQchAxAg6U3KO4TUbzmZR0nYOhqu5ndg0IcS4+uw9bU7W/aXaEiBMsiXLmcx4G4xM JFYQSVAg5InSIGONDxNpR2+qE/y1F5LXRh/zKOePN0+eTgMub7YL9OIFQvPeT7tHLlfO sUDg== 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=8QxeFRHi4qMd6sFFXgNwZ7/cePOdaHaHqRD9zBqmzN0=; b=NuaxFCKKPtjkzxG527aCVLoohpJl2HOprVlQmuP8Lu1F2gdBQ8LMyVTskajMEib9Zi 122bqB9wKf/Wt2kQ8F+69/RLekLyLDqpquw50Ari0KOMLIKRViyH2OUmjbIUm3S3Av67 +893t16DpchN0vPt6u5CdHjubZnDrp7KlVDPajxECJ/jo2EzBRPHENFwG9O9sIKKM9V6 t70SJOBPVUjKgCIRz/tCy3MeRsWkmYNP7HvqjdGk5xK2LP0EtHLSE1eUYfyp0wSNcpdY uI+mdue02/kpNoMK13rRI2t2f5flnnF+TmhSnNm0cgFYC4sxBf0lXZT0cNO4K7UxTffT 4W4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PM3xYxmR; 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 h36si10843508pgm.200.2018.12.10.23.40.51; Mon, 10 Dec 2018 23:40:51 -0800 (PST) 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=PM3xYxmR; 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 S1726279AbeLKHku (ORCPT + 31 others); Tue, 11 Dec 2018 02:40:50 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35481 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHks (ORCPT ); Tue, 11 Dec 2018 02:40:48 -0500 Received: by mail-wm1-f67.google.com with SMTP id c126so1096814wmh.0 for ; Mon, 10 Dec 2018 23:40:47 -0800 (PST) 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=8QxeFRHi4qMd6sFFXgNwZ7/cePOdaHaHqRD9zBqmzN0=; b=PM3xYxmRvN7QFw/ApSK0f06969XEiMhna7Uv/Jkq2k11tmt8+LvU9ZXYgOc6wBQV3w aVjr4v+dCjLpMjEdFy/3zVB5ocLwNsTODs0yUKijLmQFNzdLu0i1493yErLraGO5E5DE 5OyuM+U8w0K60gn+K/R54JuWbGABvZCA3kpmY= 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=8QxeFRHi4qMd6sFFXgNwZ7/cePOdaHaHqRD9zBqmzN0=; b=hlTlttDjSXEh20SGC3NziwZ2UldVmNm17VvISMlwGNqjDHFDbl2pYaHXkx3BBVWlHV nrmoseHzmFctgXI8h7sLW6DlWSRYdvSx+o59ugYqF/pBP1bIiR+BOoa71vbgPrHjOSUA klZdwwWMPwztrsUCNE7kL0XebqbROMFRLjFAhz0c7F7PIc8eNQpjaXwZ0z+cmAY76gyg jnKOf3FPsiXRLQUj/y5fOO0/SIJtFYHM/w9OaJJ55ysFtVoR+oRCyN+KyqzXowqmWlWP 3Ieici9ZLK/S41HmUlKkl6f8ZnrR6nhalKf/WtyP7c/QEf84tMJLFuq9jv2bnXjmwttV gu3A== X-Gm-Message-State: AA+aEWZTmTBLolHfNfhWXYYnxPf3cCoJlMnidR0bILfsmPQStBdhF5Pz JaWi/MkHMojdUnbAaxpmfOilbQ== X-Received: by 2002:a7b:cb0a:: with SMTP id u10mr1354069wmj.0.1544514047002; Mon, 10 Dec 2018 23:40:47 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:46 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 5/8] perf cs-etm: Rename CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY Date: Tue, 11 Dec 2018 15:38:25 +0800 Message-Id: <1544513908-16805-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 TRACE_ON element is used at the beginning of trace, it also can be appeared in the middle of trace data to indicate discontinuity; for example, it's possible to see multiple TRACE_ON elements in the trace stream if the trace is being limited by address range filtering. Furthermore, except TRACE_ON element is for discontinuity, NO_SYNC and EO_TRACE also can be used to indicate discontinuity, though they are used for different scenarios for trace is interrupted. This patch is to rename sample type CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY, firstly the new name describes more closely the purpose of the packet; secondly this is a preparation for other output elements which also cause the trace discontinuity thus they can share the same one packet type. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 10 +++++----- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 2 +- tools/perf/util/cs-etm.c | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 97b39b1..1039f364 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -390,11 +390,11 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, } static ocsd_datapath_resp_t -cs_etm_decoder__buffer_trace_on(struct cs_etm_decoder *decoder, - const uint8_t trace_chan_id) +cs_etm_decoder__buffer_discontinuity(struct cs_etm_decoder *decoder, + const uint8_t trace_chan_id) { return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, - CS_ETM_TRACE_ON); + CS_ETM_DISCONTINUITY); } static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( @@ -412,8 +412,8 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( case OCSD_GEN_TRC_ELEM_NO_SYNC: break; case OCSD_GEN_TRC_ELEM_TRACE_ON: - resp = cs_etm_decoder__buffer_trace_on(decoder, - trace_chan_id); + resp = cs_etm_decoder__buffer_discontinuity(decoder, + trace_chan_id); break; case OCSD_GEN_TRC_ELEM_INSTR_RANGE: resp = cs_etm_decoder__buffer_range(decoder, elem, 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 3819a04..a272317 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -25,7 +25,7 @@ struct cs_etm_buffer { enum cs_etm_sample_type { CS_ETM_EMPTY, CS_ETM_RANGE, - CS_ETM_TRACE_ON, + CS_ETM_DISCONTINUITY, }; enum cs_etm_isa { diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ffc4fe5..cea3158 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -562,8 +562,8 @@ static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq, 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) + /* Returns 0 for the CS_ETM_DISCONTINUITY packet */ + if (packet->sample_type == CS_ETM_DISCONTINUITY) return 0; return packet->start_addr; @@ -572,8 +572,8 @@ static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) static inline u64 cs_etm__last_executed_instr(const struct cs_etm_packet *packet) { - /* Returns 0 for the CS_ETM_TRACE_ON packet */ - if (packet->sample_type == CS_ETM_TRACE_ON) + /* Returns 0 for the CS_ETM_DISCONTINUITY packet */ + if (packet->sample_type == CS_ETM_DISCONTINUITY) return 0; return packet->end_addr - packet->last_instr_size; @@ -972,7 +972,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) bool generate_sample = false; /* Generate sample for tracing on packet */ - if (etmq->prev_packet->sample_type == CS_ETM_TRACE_ON) + if (etmq->prev_packet->sample_type == CS_ETM_DISCONTINUITY) generate_sample = true; /* Generate sample for branch taken packet */ @@ -1148,7 +1148,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) */ cs_etm__sample(etmq); break; - case CS_ETM_TRACE_ON: + case CS_ETM_DISCONTINUITY: /* * Discontinuity in trace, flush * previous branch stack From patchwork Tue Dec 11 07:38:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153400 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324877ljp; Mon, 10 Dec 2018 23:40:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/XGzTIM3EzKh5936QN41YVF79a0BxYeV0YQffFRGiE3CFzdYpAPVN9jN6cYwPZCwHfgt853 X-Received: by 2002:a63:2849:: with SMTP id o70mr13392913pgo.155.1544514057232; Mon, 10 Dec 2018 23:40:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514057; cv=none; d=google.com; s=arc-20160816; b=S7QJ71FdgnEPkupWY7BvZptAlgCFD32dwEvKf4wKNjlLTCkuyLwuAl0EN0wFws5E9M Y4670wo1eBcqpNzZuVtNX7fVw1U+usnSOEA0h/rj11aJWg5WMH903om5C2BolxKOBkN3 RrQtGzvAkKj0JlXIeocUtcxzjbcv1XwvzFejk+V5VKuVZOLvC3ROKOLqVHqLsvZqQlt2 8s89Vy1JM6QMNsbWbbcmg6Ye+tTlzalZrNnKS+dRZ8Yj1YwOxh+2e3L3ZJ1eT+Bm+7Qp 99LZNczZfsVyIRp/Z5jTPNt9DshDayi1hQm5DTUJdYbAdCx+wb10PdJ5VjghmBcxQmDF Xj2g== 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=s6aboUTCwaj4TA/VXlzMLvpQGBMMzsatHH0Kix/jICo=; b=Kvlj1vRKfDeSxS5uMZc8OlHClKaLCVZoGw+NqJr6SwFScS4lvBX2HdCy+aHRxcxs2x u6Puky7T4YaXRKH4/e4RYadMls35AKUFKKsa86ztkkj+rf70+RymWihirD9TgyOKQAzX 1g+JgQjQAgmGxpqLiZxtTbyivzLw7bFOdJ1QNnkWUPeMbRR8U3xH3ZRG36pL7B0ZEbo2 TidGtDlhFcfnSX7ercHxhnzldQw2qUYmMUPFysxzLmG3msGSg6Dq2TOFjTOG0+kEyrHW XI7EdfPxs4XrwdxKUYGDJpOrW6g8Yfldcee2bJ2jT2Q6uA+x14ZEsKp9E4BxRWODs36H rmHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J+dbz6iU; 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 y2si12268238pfy.29.2018.12.10.23.40.56; Mon, 10 Dec 2018 23:40:57 -0800 (PST) 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=J+dbz6iU; 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 S1726296AbeLKHky (ORCPT + 31 others); Tue, 11 Dec 2018 02:40:54 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34957 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHkx (ORCPT ); Tue, 11 Dec 2018 02:40:53 -0500 Received: by mail-wr1-f65.google.com with SMTP id 96so12986694wrb.2 for ; Mon, 10 Dec 2018 23:40:52 -0800 (PST) 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=s6aboUTCwaj4TA/VXlzMLvpQGBMMzsatHH0Kix/jICo=; b=J+dbz6iU8ewWu0saYvBbMMYJmMeQuz/VHbn5m1CTalri8JzMCpqLROwpq1G3yGAVEO l5kxfqbZMF8o4TnNe04jEiR1zruc+MyFPibD5YXTW22GzWPgSsJJQ7UYp/KOWP8A5MlS Oi++7stK9UD7kswvx/7HRXrnxdmGTa6aousv8= 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=s6aboUTCwaj4TA/VXlzMLvpQGBMMzsatHH0Kix/jICo=; b=LioBf3d470oEWzFcy4JYiWw5erk0AgIpT2YelX/adWRn8wgFWJogTL0/6qiVSFsItc 9a2fGD7tdtXDgWJNLHY0ufnkI/S+WaFpYzFChuISJ9izLn+bCX/XMqIptnEHAq06JgOt kfFNGEUgBCg/Aooae8PImguN6zZSiG5VnAY5RX+xnNOJti/Vr8mgOxcuTudKhfoAHn9z G/UFYGE/ZWS1/S5fxdbSu1o5p7e9Q715Kq3Xuk2IrPkPDtJKHIsziE5y7wf9WPlFWy/9 +W3oyBEkaU1V3lP9CGf8pEkRCmqMaop29j1Mb9gLOu341MddmHK3dlL7GC6jmGa2w6+r p+Wg== X-Gm-Message-State: AA+aEWb6iu8DfdO6/yFOlb5wkI+vFD4s51XXqD8ed+Crg+iadX8r5+IV LJFDqfn6WCu0JMQlORPXQUVOKw== X-Received: by 2002:adf:f308:: with SMTP id i8mr11822984wro.219.1544514051589; Mon, 10 Dec 2018 23:40:51 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:50 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 6/8] perf cs-etm: Treat NO_SYNC element as trace discontinuity Date: Tue, 11 Dec 2018 15:38:26 +0800 Message-Id: <1544513908-16805-7-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 CoreSight tracer driver might insert barrier packet between different buffers, thus the decoder can spot the boundaries based on the barrier packet; the decoder is possible to hit a barrier packet and emit a NO_SYNC element, then the decoder will find a periodic synchronisation point inside that next trace block that starts trace again but does not have the TRACE_ON element as indicator - usually because this block of trace has wrapped the buffer so we have lost the original point that trace was enabled. In upper case, it results in the trace stream only inserts the OCSD_GEN_TRC_ELEM_NO_SYNC element in the middle of tracing stream, but we don't handle NO_SYNC element properly and at the end users miss to see the info for trace discontinuity. Though OCSD_GEN_TRC_ELEM_NO_SYNC is different from CS_ETM_TRACE_ON when output from the decoder, but both of them indicate the trace data is discontinuous; this patch treats OCSD_GEN_TRC_ELEM_NO_SYNC as trace discontinuity and generates CS_ETM_DISCONTINUITY packet for it, so cs-etm can handle discontinuity for this case, finally it saves the last trace data for previous trace block and restart samples for new block. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 1 - 1 file changed, 1 deletion(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 1039f364..bee026e 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -410,7 +410,6 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( case OCSD_GEN_TRC_ELEM_UNKNOWN: break; case OCSD_GEN_TRC_ELEM_NO_SYNC: - break; case OCSD_GEN_TRC_ELEM_TRACE_ON: resp = cs_etm_decoder__buffer_discontinuity(decoder, trace_chan_id); From patchwork Tue Dec 11 07:38:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153401 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324944ljp; Mon, 10 Dec 2018 23:41:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/XGcbw+4srkFsIiLFXRNEVSx4zavGx2Gg22lA1WAYJtsiCpn0numMlBt6Fd7tpBFBiBy6r3 X-Received: by 2002:a17:902:2ac3:: with SMTP id j61mr15054208plb.185.1544514062944; Mon, 10 Dec 2018 23:41:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514062; cv=none; d=google.com; s=arc-20160816; b=APj9fDFiCJ0Dv8wuox5R8bd+AzCTDSaEtXsDAst8dP635Cu5/NOrdmRcg6pdQ8rKIn /l0T0ZypfVH3JaDXjv1eVrSX3dBNsm8tYyNhzBUV+poJfZG7ITCr8mBWNDjiLYk6iqDF FY9yecUVth6Q99jETWrGAkOPaAmDFa5t8Kvg1Gcq+0xUEzn9qg92CysYoyTuPipbr4zY xt95AWmsoTT88/KQZm1ToEs8dDp+1xnhR50exZdwfjGJh7PBVsAEQeNDRKyz1YFsP714 frKraY0Kzkv5VGG/uRbaL42gm4+b6EDGifE46ex8TWm24hM0Tn3YJLVW1+YhjefhSzg7 hmQQ== 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=HqaxBZzT/ny60CVvOS0lgH0CrB/BIasRrsWm7IM5vG8=; b=YaDq7ORhnaX/QagoEVV6auuvgJVSl/v/hOqw4JuVjbLDQYN6DYKNuRECP4MkFqHbGj cDSbKAQekZtu/m72tye5QXBfMGJyNEJvUKIzYvywsUggaP8kYjzUis9Q37O9rOyoAYkN WvcZE0tZQeposfeaB68Dg6fypG/7hehsf7HLHDOgBqKHgavAmv5EwkN5Kk7G0EEUWDn+ UhZiPCiAL+hpA6td3Uz/Pn1jXlMVvkj60t9W7FHyU7GqbYSW114xFoYjhwUFcEhAYCgB MSLeDtWzeHFLbCs0kPfOzNY9GZTaJ8GCz7+Wcwq/S9kiCXWMGDSyhOozeNPYW0mAOBuG kB4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cp9KUPnh; 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 y20si11680556plr.106.2018.12.10.23.41.02; Mon, 10 Dec 2018 23:41:02 -0800 (PST) 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=Cp9KUPnh; 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 S1726310AbeLKHlA (ORCPT + 31 others); Tue, 11 Dec 2018 02:41:00 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34964 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHk7 (ORCPT ); Tue, 11 Dec 2018 02:40:59 -0500 Received: by mail-wr1-f67.google.com with SMTP id 96so12986907wrb.2 for ; Mon, 10 Dec 2018 23:40:57 -0800 (PST) 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=HqaxBZzT/ny60CVvOS0lgH0CrB/BIasRrsWm7IM5vG8=; b=Cp9KUPnhAQUAo/JG52hN0Hj6I5CbvZjECAnZPG+Sf1GU+t3GohIfKw+LUziR1KXtx6 aMLkIqe1sEoANZKEduQIuphsllazBVrJpYfdlxczQEMm2Zsn64UoE/cToRV6x7AwB+6l kR96G57ANDDlB/OU0QQWA6ygrvwAkhKtdOrYs= 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=HqaxBZzT/ny60CVvOS0lgH0CrB/BIasRrsWm7IM5vG8=; b=D3XSF7r8NniSyVbJD3QISaicHtdEj5ROoMPb288vH/CyfE1EAX4teTkO/OKhaGKkN9 tqFCDxiYVK1QlmwGI/klPgnq4/9zSOVhIr6hSSEBnW6iKnby8TqEv84ZgtIubVf6+xTd 5FSAgV0jniyrhq/n/KIJD44RktEaLvGFlKJL5bvD9JCtdy5qRKWsRClPXlSZmc9LLoOT eRTX+O5LInKK4FJu1J5THWGxZf22Grk9tinzO1CSJqvjW5JsL6WMaeYr2SDZXywPRUdc xL6aNzkw34jIrGdm8QpyhPzCq0Hilbf53IIGsb6JoK2S2MOgAmxR3EuqOrulO9zz5DV2 kefA== X-Gm-Message-State: AA+aEWYgkTwsfCY5RxLq2zpZzKO5isGt1NoB6if43ArCBrfJhhU8QGG0 N3ogBADg4RAAniX53UAYaoZcbg== X-Received: by 2002:a5d:4e47:: with SMTP id r7mr12847975wrt.264.1544514056667; Mon, 10 Dec 2018 23:40:56 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:55 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 7/8] perf cs-etm: Treat EO_TRACE element as trace discontinuity Date: Tue, 11 Dec 2018 15:38:27 +0800 Message-Id: <1544513908-16805-8-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 If decoder outputs EO_TRACE element, it means the end of the trace buffer; this is a discontinuity and in this case the end of trace data needs to be saved. This patch generates CS_ETM_DISCONTINUITY packet for EO_TRACE element hereby flushing the end of trace data in cs-etm.c. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index bee026e..cda6f07 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -409,6 +409,7 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( switch (elem->elem_type) { case OCSD_GEN_TRC_ELEM_UNKNOWN: break; + case OCSD_GEN_TRC_ELEM_EO_TRACE: case OCSD_GEN_TRC_ELEM_NO_SYNC: case OCSD_GEN_TRC_ELEM_TRACE_ON: resp = cs_etm_decoder__buffer_discontinuity(decoder, @@ -425,7 +426,6 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( decoder->packet_buffer[decoder->tail].exc_ret = true; break; case OCSD_GEN_TRC_ELEM_PE_CONTEXT: - case OCSD_GEN_TRC_ELEM_EO_TRACE: case OCSD_GEN_TRC_ELEM_ADDR_NACC: case OCSD_GEN_TRC_ELEM_TIMESTAMP: case OCSD_GEN_TRC_ELEM_CYCLE_COUNT: From patchwork Tue Dec 11 07:38:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 153402 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp324997ljp; Mon, 10 Dec 2018 23:41:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/V76DxVlMnTmwunZCJc4zqh4ZEeRvDTdpn14XP1OfkV4aZvzSZNoyuMeaec+LddY0oYM35g X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr14859053plq.117.1544514066870; Mon, 10 Dec 2018 23:41:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514066; cv=none; d=google.com; s=arc-20160816; b=dFWtXJ6eQpUYekPRQjbQ9U8fO0yNuqb+DL66NEY87stvbwouyITDUmKC4IWeq81Wmk aZpKS23PIDyV8dvmktBPUK5xxqu0gJhctJh3I85y+UNlswltJ1euXY5Oj3uYEUtNuJRy 2DmjyD6GkfCwp1dIT5evfKeaBKdaxNO+iKAIgVISjF4EMf5WvNdYbe1jTZGVFuHBzSUg v5PLz9ttwv1pRRmAO9oO2vsSq1obantmejd+JHZ5qePesXU7aEhbEkWoyrcBrqSe5lX7 3PzI56RBS6FAJwItz12FUPO2OEOkLrqawHdK+J5c4k6/k6MJgQVwN0qxK5hIneYt8jWR dIAQ== 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=9g52Maa9hrzNxiLroyiPhb7DsGqolHn0KBXL8Oe3cxA=; b=S6BlgfYrC4Sgjr6RYpMCgk+PgHm4b4WueuDPKDMg1dUHhKntPvS4aidFzFh3wbNNB9 WpJwEQUFsXFppU0VxBjvwrKSs3F5V5RKvCHQhOe/1ksOHj+eRpy3wER0wpfASMiMGvfB yJlWgNRfhQjyAyj0pCQgV6By9Q8XPhxoDfeTIL7GM0gsywRMtwkCaTN0l/ij2V/hVooR XpkICFA6IUEQ7Qi0c8L2AtRLUOialjAaXJ3pzJcFCP2OVTPe4QXHPnSZDiQsxugp/H1R U8mGg2EO8Y9MRbjZJtHafXyhtsYsnVy1nEAdAhR4I+kdOk4PMJIK2HDRR9BG+MCJb5FE teQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AOVRRj3D; 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 y20si11680556plr.106.2018.12.10.23.41.06; Mon, 10 Dec 2018 23:41:06 -0800 (PST) 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=AOVRRj3D; 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 S1726323AbeLKHlF (ORCPT + 31 others); Tue, 11 Dec 2018 02:41:05 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39027 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHlE (ORCPT ); Tue, 11 Dec 2018 02:41:04 -0500 Received: by mail-wm1-f68.google.com with SMTP id f81so1076932wmd.4 for ; Mon, 10 Dec 2018 23:41:02 -0800 (PST) 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=9g52Maa9hrzNxiLroyiPhb7DsGqolHn0KBXL8Oe3cxA=; b=AOVRRj3DAzXBvvvc7X1HDL2OqCHGBwgEcjzWquJbDEjQ3PzsUzt811+8fdVsimCPan qWsHTu0kAiufn4tM5yoppqPZ3lAFtroAghua2uIZBii6EIBNT5b/k8GPlB0j5ohrJcq7 NuDfKgxaBc0Vg2nmV5otgd8bo9iwy4tW54xFI= 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=9g52Maa9hrzNxiLroyiPhb7DsGqolHn0KBXL8Oe3cxA=; b=O22QHplkpT/I0YXIz2Ya40qrBKcfALFDnQC27AVkeX7sNZOKenlhgEDAbkVLA8okjq cmDekzTF3ucbRCRIEFXSGexGw7+wNn2wa5aUHh84Ur7eoWwB2Dp94lmMdOE744Myc/2C lV6N16eo2RXS8O/MnV9ElBd/2UJRmH4uq/zX2QHvo5iryC2E/u81yh0fqbNgkPO3sR9+ dLQaGHlh273Ugm4f5SP2uSo4LupCruVTge88d1KoSgr87AhfkgpKqOf2//O/YYKaG103 Rafqbna30M3DxCAAayKu4z+vCoWXbsaK9NpRcEK58Wj2uJhciskOQKXKNSprtMWJtpSe XM/g== X-Gm-Message-State: AA+aEWYH+bBR8kfR8Qj/Tf0ZEtCR8dtgN6bB6ngWizIsFJA1OFQHnVAT rei3F1ZjVjRUxhedYb3z9uq1mw== X-Received: by 2002:a1c:1688:: with SMTP id 130mr1220916wmw.86.1544514061494; Mon, 10 Dec 2018 23:41:01 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:41:00 -0800 (PST) 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 Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 8/8] perf cs-etm: Generate branch sample for exception packet Date: Tue, 11 Dec 2018 15:38:28 +0800 Message-Id: <1544513908-16805-9-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-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 The exception packet appears as one element with 'elem_type' == OCSD_GEN_TRC_ELEM_EXCEPTION or OCSD_GEN_TRC_ELEM_EXCEPTION_RET, which present for exception entry and exit respectively. The decoder set packet fields 'packet->exc' and 'packet->exc_ret' to indicate the exception packets; but exception packets don't have dedicated sample type and shares the same sample type CS_ETM_RANGE with normal instruction packets. As result, the exception packets are taken as normal instruction packets and this introduces confusion to mix different packet types. Furthermore, these instruction range packets will be processed for branch sample only when 'packet->last_instr_taken_branch' is true, otherwise they will be omitted, this can introduce mess for exception and exception returning due we don't have complete address range info for context switching. To process exception packets properly, this patch introduce two new sample type: CS_ETM_EXCEPTION and CS_ETM_EXCEPTION_RET; for these two kind packets, they will be handled by cs_etm__exception(). The func cs_etm__exception() forces to set previous CS_ETM_RANGE packet flag 'prev_packet->last_instr_taken_branch' to true, this matches well with the program flow when the exception is trapped from user space to kernel space, no matter if the most recent flow has branch taken or not; this is also safe for returning to user space after exception handling. After exception packets have their own sample type, the packet fields 'packet->exc' and 'packet->exc_ret' aren't needed anymore, so remove them. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 26 +++++++++++++++++------ tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 4 ++-- tools/perf/util/cs-etm.c | 28 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index cda6f07..8c15557 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -290,8 +290,6 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->packet_buffer[i].instr_count = 0; decoder->packet_buffer[i].last_instr_taken_branch = false; decoder->packet_buffer[i].last_instr_size = 0; - decoder->packet_buffer[i].exc = false; - decoder->packet_buffer[i].exc_ret = false; decoder->packet_buffer[i].cpu = INT_MIN; } } @@ -319,8 +317,6 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_buffer[et].sample_type = sample_type; decoder->packet_buffer[et].isa = CS_ETM_ISA_UNKNOWN; - decoder->packet_buffer[et].exc = false; - decoder->packet_buffer[et].exc_ret = false; decoder->packet_buffer[et].cpu = *((int *)inode->priv); decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR; decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR; @@ -397,6 +393,22 @@ cs_etm_decoder__buffer_discontinuity(struct cs_etm_decoder *decoder, CS_ETM_DISCONTINUITY); } +static ocsd_datapath_resp_t +cs_etm_decoder__buffer_exception(struct cs_etm_decoder *decoder, + const uint8_t trace_chan_id) +{ + return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, + CS_ETM_EXCEPTION); +} + +static ocsd_datapath_resp_t +cs_etm_decoder__buffer_exception_ret(struct cs_etm_decoder *decoder, + const uint8_t trace_chan_id) +{ + return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, + CS_ETM_EXCEPTION_RET); +} + static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( const void *context, const ocsd_trc_index_t indx __maybe_unused, @@ -420,10 +432,12 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( trace_chan_id); break; case OCSD_GEN_TRC_ELEM_EXCEPTION: - decoder->packet_buffer[decoder->tail].exc = true; + resp = cs_etm_decoder__buffer_exception(decoder, + trace_chan_id); break; case OCSD_GEN_TRC_ELEM_EXCEPTION_RET: - decoder->packet_buffer[decoder->tail].exc_ret = true; + resp = cs_etm_decoder__buffer_exception_ret(decoder, + trace_chan_id); break; case OCSD_GEN_TRC_ELEM_PE_CONTEXT: case OCSD_GEN_TRC_ELEM_ADDR_NACC: 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 a272317..a6407d4 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -26,6 +26,8 @@ enum cs_etm_sample_type { CS_ETM_EMPTY, CS_ETM_RANGE, CS_ETM_DISCONTINUITY, + CS_ETM_EXCEPTION, + CS_ETM_EXCEPTION_RET, }; enum cs_etm_isa { @@ -43,8 +45,6 @@ struct cs_etm_packet { u32 instr_count; u8 last_instr_taken_branch; u8 last_instr_size; - u8 exc; - u8 exc_ret; int cpu; }; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index cea3158..27a374d 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1000,6 +1000,25 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) return 0; } +static int cs_etm__exception(struct cs_etm_queue *etmq) +{ + /* + * When the exception packet is inserted, whether the last instruction + * in previous range packet is taken branch or not, we need to force + * to set 'prev_packet->last_instr_taken_branch' to true. This ensures + * to generate branch sample for the instruction range before the + * exception is trapped to kernel or before the exception returning. + * + * 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. + */ + if (etmq->prev_packet->sample_type == CS_ETM_RANGE) + etmq->prev_packet->last_instr_taken_branch = true; + + return 0; +} + static int cs_etm__flush(struct cs_etm_queue *etmq) { int err = 0; @@ -1148,6 +1167,15 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) */ cs_etm__sample(etmq); break; + case CS_ETM_EXCEPTION: + case CS_ETM_EXCEPTION_RET: + /* + * If the exception packet is coming, + * make sure the previous instruction + * range packet to be handled properly. + */ + cs_etm__exception(etmq); + break; case CS_ETM_DISCONTINUITY: /* * Discontinuity in trace, flush