From patchwork Wed Jul 11 07:45:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 141683 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4803504ljj; Wed, 11 Jul 2018 00:46:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVc4YIjRlmDK/yLaA7ax++xkPERWBj89emRpmTaCgALNk0qUk0TnQmMCfgvjizQp8yZHfz X-Received: by 2002:a17:902:88:: with SMTP id a8-v6mr27148222pla.156.1531295184847; Wed, 11 Jul 2018 00:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295184; cv=none; d=google.com; s=arc-20160816; b=U3FjYnOpIUgoXN3CRX7eaOZx5dwo/kUoGdyO5Z5jXnt/nRQ3VDBQB72QiyuoZWgD9A FROCGjMSkZiiCld38unpfnpf+UFBPDCWjCEoLc/VUH01yPXXA/aREE4dSpDGnG9lYBo1 oYElRjy4DBszlbL8k7gDDcuiX+sLU0lEjAAQAij5U5lQxSuuz69aDY9zHkWuNXmWpGWM 5CkO+2UY89bVZMa6hCmGubQGd6NtN3XgpP5OEtpKTCv8JrHxWxcfkhXMnF3USkjnFJ+Y JxU4ubfa2LV/Xm/MIzvzrPIHm9OYc+9rYE+Ymbjq7C8NAPcTVHwVP85vkODMBdfUKvF3 9GqQ== 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=vW3cqebjdlydqMs6JbHwBlmxXx9urlbBEoZPw9FFXQA=; b=pYn5oBcZX4NF1fMFfsCY2lcLLK9pe75NeBiAKkZaARF/+/jrNtj8H6aZmVZAFGYimj EXX7lWQ+vB/p0t3rPlUC5xY7W9nQvXIcnYCLvDDB/HU+ln8QbL31/9ga/dWzPrK/Qsu7 k4LkAz1FRtY0wDek0Hvg5RuxgOmRX7/0SEUqNnRS0215aRAY3CAJ6shtjckutsPaaBsc HNfcIiq3yWw8vUAhLueTlEzPMxh+IJKyfw/qXmSbqd/b/1WsbaP9TdRy+GlA0cQ8Fxox bQes+kXBrQZjg9KPEfIQ040AuUiDuUsk2Xad8G0CzDKUydEWeLdjoxX/t6MAFYmsru29 ztng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="E/m+IA6t"; 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 i2-v6si17752566pgo.121.2018.07.11.00.46.24; Wed, 11 Jul 2018 00:46:24 -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="E/m+IA6t"; 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 S1726566AbeGKHtT (ORCPT + 22 others); Wed, 11 Jul 2018 03:49:19 -0400 Received: from mail-pl0-f54.google.com ([209.85.160.54]:43284 "EHLO mail-pl0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbeGKHtT (ORCPT ); Wed, 11 Jul 2018 03:49:19 -0400 Received: by mail-pl0-f54.google.com with SMTP id c41-v6so8810644plj.10 for ; Wed, 11 Jul 2018 00:46:21 -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=vW3cqebjdlydqMs6JbHwBlmxXx9urlbBEoZPw9FFXQA=; b=E/m+IA6tJldpTNUN28KPNYTUMALeXE1c3aisZSeM0vza4oUI2WypgO3EvHbSTMjl7b HE3f7QwSy0Hb4o8mEww6hSct8NA/E3R95vaVTlQqzKJZo4TKoXuzHIj/e4yI6TBXdf1m VUb2bCOaW4mhAEFlXdrMV/M02n7aSt4B7HsDw= 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=vW3cqebjdlydqMs6JbHwBlmxXx9urlbBEoZPw9FFXQA=; b=nakq/hyRXtxLit8a+IwYEBUuHgEzgKz2weCZYaVuWPiHuTFkOl6JgjV0GK837dwtWD a21Hpob8MT8A5L3xhq2B0BMv1WlOLO89Ps4ZPPLkeIMGq2/e+AfqHVgqrOK7KB7rfaGC rVU9iOiToF1QHUecMvBJfTsqpOipPutFiWJFa++93XbbCV9OpMwFpRQK7+xYIFKSqZxn 4Ua2pUV1ytQT5BNuKU70/2qjXngsknYhvbQ6kBOxYnpZTOXQtmGEXVO1i65ABGZph5Zw c2qXbtxOraG65UZZbF5zG8N+cDRn2J6O6wE/PZ917gbc70qlqEdG4yhTyv/IUuZyJk/I DH7w== X-Gm-Message-State: APt69E2dbzOzwyFE2NIJUw0XbfQH6qRez4hTup9uq/p8gdMeUOwDCyVi LYD5LHcVPZ0I/FH3lqyaXDXmEA== X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr28192496plu.22.1531295181150; Wed, 11 Jul 2018 00:46:21 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 00:46:20 -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 1/6] perf cs-etm: Introduce invalid address macro Date: Wed, 11 Jul 2018 15:45:40 +0800 Message-Id: <1531295145-596-2-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 This patch introduces invalid address macro and uses it to replace dummy value '0xdeadbeefdeadbeefUL'. Reviewed-by: Mathieu Poirier Signed-off-by: Leo Yan --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 4d5fc37..938def6 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -31,6 +31,8 @@ #endif #endif +#define CS_ETM_INVAL_ADDR 0xdeadbeefdeadbeefUL + struct cs_etm_decoder { void *data; void (*packet_printer)(const char *msg); @@ -261,8 +263,8 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->tail = 0; decoder->packet_count = 0; for (i = 0; i < MAX_BUFFER; i++) { - decoder->packet_buffer[i].start_addr = 0xdeadbeefdeadbeefUL; - decoder->packet_buffer[i].end_addr = 0xdeadbeefdeadbeefUL; + decoder->packet_buffer[i].start_addr = CS_ETM_INVAL_ADDR; + decoder->packet_buffer[i].end_addr = CS_ETM_INVAL_ADDR; decoder->packet_buffer[i].last_instr_taken_branch = false; decoder->packet_buffer[i].exc = false; decoder->packet_buffer[i].exc_ret = false; @@ -295,8 +297,8 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, 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 = 0xdeadbeefdeadbeefUL; - decoder->packet_buffer[et].end_addr = 0xdeadbeefdeadbeefUL; + decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR; + decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR; if (decoder->packet_count == MAX_BUFFER - 1) return OCSD_RESP_WAIT; From patchwork Wed Jul 11 07:45:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 141684 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4803573ljj; Wed, 11 Jul 2018 00:46:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeczQNDnOiHA1V29bIzQ7ChHoWYF1Z8sFCCA2Lps0RxXsLjHBdd+6XwiLXv34a3q4Uov4Y2 X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr27980230plb.273.1531295191741; Wed, 11 Jul 2018 00:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295191; cv=none; d=google.com; s=arc-20160816; b=AwxJfwYA82A3Altgx6vTnYGNczKPTipi/bjFu6EDboyBLKG3eQHY4AUyWGE9X+r69w PHy0tq8VlJn8jwXaIvuTtBDM9/RqII4Y2MeL6W0CpRHRklnH7ZWDaoXP2nDEuM5aczGe pmJ6aF31ZqpXHR9J6RjFfZQHNuw7nSiiCQJDmFDkwXNz6eCQ21CFghH+qPQUGT4v+8KY UuNkQw4Hz7BBWRtFBPm8ZvyO9AFWUW1PB8tb6slcYwAOQGiTBeB/ZDTvqPoTsTZigDJK W+SpvC2GfK7Pbu2akNfesVfO302zad6bPiuREnb1O/jk9QRQ3+4oaEXtLVLW+Crr7ewQ tduw== 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=IOhFeWQKL4l7VSWl48ZwW81Bvvd5Dpc7t8AlhIsqGMU=; b=Lytdj8149JU4QHNha64YPWucJHqBB6Wfn278LzJMxAi5l6xSOjugiaJNt+BCynmWOS VRi9VGT5o2Nnj7957BkYvUHZZWx1qDBeqmqB6pJNeInXUrSssSvy6gssUge4M3MXF86y M0p+fDC7qACCEzwg8jOWjcbfjobRa+ekNrGc4RyP46NkdVK2qoCAqeVcgPQFMVhePXop EoA/ghQvcrcUogRgpLKNPEvQM3nAm8HlRwpLqEXg7mUsxkSglkkYEwdfBQWPB0zPvyho K/HoD7dtDopukZVFv5ieIwdECdEcl6nMw1ymVqo7RQKcmzO1S6iDJe1XjgapIyaOT63y nMPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z7TFSBa7; 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 f2-v6si7028937pgh.661.2018.07.11.00.46.31; Wed, 11 Jul 2018 00:46:31 -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=Z7TFSBa7; 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 S1726737AbeGKHt0 (ORCPT + 22 others); Wed, 11 Jul 2018 03:49:26 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:41711 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbeGKHtZ (ORCPT ); Wed, 11 Jul 2018 03:49:25 -0400 Received: by mail-pl0-f66.google.com with SMTP id w8-v6so8812189ply.8 for ; Wed, 11 Jul 2018 00:46:27 -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=IOhFeWQKL4l7VSWl48ZwW81Bvvd5Dpc7t8AlhIsqGMU=; b=Z7TFSBa7IXjcR6kZ9BJHPpvk89owgHTZ7JwGbCDUIrxfX77sGORypSLBnIYmoYIpE0 t07RnIVXO5mN1+F9pKBGybuhcj9fl/unOUfIzXyd8B21fAC1aRa1OrDUhdnGS1BitiYk DYw75b7Zp/f7QnOcepf9OuezSu47L6A47tols= 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=IOhFeWQKL4l7VSWl48ZwW81Bvvd5Dpc7t8AlhIsqGMU=; b=Nx5LPZYfRYjdbZeAi/XfbivHLVPIxci82LZmzir4ul1yuHqDQjmOJD3LkJNz+FtDCA eycMAVUog8SxQIqficj9v6m5qM4h2hd93FebsnvoZpzyfpmzLjOtuv5qEKebuEyGlupx q5JjaBcNviPqW7692bmEmKB3gzaIAf+D3xsH+NjYB0zRe7dO4WU1PeZgqJev1KJ2OU8G Ma1j9OmrzlIVYMHi6Ono9SXXpmdPzzJ1b5He36KnVA7tSJXFwOU/FTJlG/ZlWLf5ex1A OrDw1xIn4DSk0BEUfus2olw1lpOHRnyP7JhBWa5NBEIiqcfiYYJXjBf89CG731DfiZDK Hz8w== X-Gm-Message-State: APt69E3K2TfBew6J+jClQFZFs8dtEUGTOTHobL+xTGYrXkEEnNW3Po4L M1tlgouL9RTjSdZ2OwB06Gpv66lFTcQ= X-Received: by 2002:a17:902:7044:: with SMTP id h4-v6mr22421314plt.179.1531295187415; Wed, 11 Jul 2018 00:46:27 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 00:46:26 -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 2/6] perf cs-etm: Bail out immediately for instruction sample failure Date: Wed, 11 Jul 2018 15:45:41 +0800 Message-Id: <1531295145-596-3-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 If the instruction sample failure has happened, it isn't necessary to execute to the end of the function cs_etm__flush(). This commit is to bail out immediately and return the error code. Reviewed-by: Mathieu Poirier Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 822ba91..8b2c099 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -939,6 +939,9 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) err = cs_etm__synth_instruction_sample( etmq, addr, etmq->period_instructions); + if (err) + return err; + etmq->period_instructions = 0; /* From patchwork Wed Jul 11 07:45:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 141685 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4803684ljj; Wed, 11 Jul 2018 00:46:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdLFFarNT4P/cOSlQstPOZS+L6vFXvR+hAzcLM5Mpt1DgDdtIcPQ/jffKcNRyfvekzVzhpJ X-Received: by 2002:a63:5c52:: with SMTP id n18-v6mr25236278pgm.360.1531295199537; Wed, 11 Jul 2018 00:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295199; cv=none; d=google.com; s=arc-20160816; b=akohDoU5g8FlZvIInNCSNHhrJBRVZBOZgQWtHhSq0ZHlPM2N/xBoUIbRGHH02hcWJt nFm+H3fPa3NriyT+63RITjUiihYGpwp6UjC53A7xIq0kjl8gMLtVGlK8ynx4ER4vCush r5SVNcItxK2aFD3kaSDYoJo3CqE4aCdEOgPkODElcnwyhRjLuoCw0WcZ2d07xNo/oJzu ln2m0M/40Qu/cBpFEWcMdpEGPJvz71RZRJqE5ofBhBHMIGqbCeYE0FatKej9Biv/HPyN 2A4rf+0YQLJF+2Njsht6xWi02xYtbY48arNXlgLBDVzf7Iwp0PBh9qIl34k7e6s2wc6L erTQ== 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=nbQNDlVOGZy2QG4EsYIlFoYPd9+L5V/lXajEoE4/YUc=; b=cNGsI7mVVUqPQjFaukHiwObDCV9aejt5Yr2xryPAgWIQ8h1X52/kQyJcYgsjsMI9kw hDZKuCsPzKS2RvOK6auhzO/IxzKDokLznJ8QV7glUBAJsie6UEYU1LzuxQWNsn9Sn8ku GxBuwi1KPCgd1YBOo5i2bNbK9bEPM6xB1X1j0vZJHFFF0/Mgan9Cecn0P/8eZYJEd5RG C0RLHEJWw23lWlM8g8jnoDp+5IVfwdg/TAhBLo7cTVajuRRuzTw8OGWkVb8IcwXfWB0G +wv5+eTPXbtzYPMwxK4IiWVvWHdZtF2iF2TXyxjZyyTU0y5MJ1NoiYe0vDKSIhIZFp9G tYqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtcGRB6h; 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 d11-v6si18314595pll.255.2018.07.11.00.46.39; Wed, 11 Jul 2018 00:46:39 -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=dtcGRB6h; 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 S1726803AbeGKHte (ORCPT + 22 others); Wed, 11 Jul 2018 03:49:34 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39531 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbeGKHte (ORCPT ); Wed, 11 Jul 2018 03:49:34 -0400 Received: by mail-pl0-f68.google.com with SMTP id s24-v6so8809272plq.6 for ; Wed, 11 Jul 2018 00:46:36 -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=nbQNDlVOGZy2QG4EsYIlFoYPd9+L5V/lXajEoE4/YUc=; b=dtcGRB6hcydihMoQVZY0RMpBmfyAotIfsyezFIcF054L0tdbd2UZCDdD0R071SnLwj +5atqBg/hulDdnSS5VbYCae5BrKzalC8tMAvU64cZ10rqJf7cJpj4zlVj9XgJP4CuWeZ OajHpvk9idG9XPyFCzfyyLo9OMzuIYtUna7p8= 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=nbQNDlVOGZy2QG4EsYIlFoYPd9+L5V/lXajEoE4/YUc=; b=X8kZaT+7BNbpt0akbMHKcrYhMNz7adosEshSJRVBA8GC364moeZywP+UXS468GOg0Y KxP9M9NxfJkdpdA7YspUA+rprygFCZseizmkaP7za45C5YSkgwbJylP1bHl2X0Eoj+Zx V6qgL/Sw8eX6qJae+Tx9pDsjdsk/Fg3usyB3FjdtB2eXdUfzP+giqPJ0ePBQo+69mw11 LLRHC8DrOMBgypyVhrqnnPx5qy2zgLt+Xpv81ckAKA5UbLefpNn4Z6LKLjtUaYsLGlBd tIKpeyCksP6BYRfeQpoMa8wrP5lah6r9NZgvHnU/cqmwdKPsqtEGPoUMSf+9bm4092zP XFBA== X-Gm-Message-State: APt69E0EEyT63F36az5M7eYFBaQ3GkP3vF2fViDFjMzpBpKyPP/1/QF5 9c/prrWQxhTDLi7p8vjm9IXtcA== X-Received: by 2002:a17:902:600d:: with SMTP id r13-v6mr27952076plj.70.1531295196100; Wed, 11 Jul 2018 00:46:36 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 00:46:35 -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 3/6] perf cs-etm: Fix start tracing packet handling Date: Wed, 11 Jul 2018 15:45:42 +0800 Message-Id: <1531295145-596-4-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 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'. Reviewed-by: Mathieu Poirier Signed-off-by: Leo Yan --- 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.7.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 743f5f4..612b575 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 8b2c099..ae7c9c88 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 Jul 11 07:45:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 141686 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4803791ljj; Wed, 11 Jul 2018 00:46:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVbFmSGGojyuWWtpEvfackPXMkghZb6q3OqBWC/x9nGVJXMG4YFsPQKiCt38xPVFr/kcqd X-Received: by 2002:a63:440a:: with SMTP id r10-v6mr25401570pga.27.1531295207457; Wed, 11 Jul 2018 00:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295207; cv=none; d=google.com; s=arc-20160816; b=Kasa168vdxdfMi//UG23cLbn9Zca3nRIJJJkGcdzMDFKhAerYf55vrmGpQBGEZcw1I pD3BZQ30zaIQL8aGa+l0jQe5C0ZfOJ80pcQ/MqVdaJHF7IOd3VLALFgzqiR8meO7nDwA sjYTf5ttKwfm7cVjk/awIZtb4MOwyxj8X+k60YbhmcG2hNm/DU/YbXQc95wEhNAbubPu 0PCHMwiubxJLZuYC3RPMxpi0SmPiQUua/u6b138AV1vYwu97AjLnxz4zClTXG6aEygcn 33BWGR+Wps1T6nJX416QOIFTGORQ8CXNgBBkXYExY/M6MZdkkUEmQdHc2gXW2ArYMWq2 TarQ== 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 d11-v6si18314595pll.255.2018.07.11.00.46.47; Wed, 11 Jul 2018 00:46:47 -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 S1727063AbeGKHtm (ORCPT + 22 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(-) -- 2.7.4 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; From patchwork Wed Jul 11 07:45:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 141687 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4803894ljj; Wed, 11 Jul 2018 00:46:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJy/MuywFsTkXAu6JIQLY9WNndgoGLrjEXqXI+iv9CyF1GxZbVFI/3TQbbZk0o2YQHvWUs X-Received: by 2002:a63:2c0d:: with SMTP id s13-v6mr26149139pgs.37.1531295214808; Wed, 11 Jul 2018 00:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295214; cv=none; d=google.com; s=arc-20160816; b=MZz2eBCY6lz/4MbYuiJSx0u/+vx55Sis6Jr7gNRh/KpcGAnqdUHA56VumTA7hoTCif 0APxLPKODn8zqzRte/K4WvUCYlA58K6CdP36NBWVb68L2Enw9KCtopswEeYvlA32p/YB lH/DL9JVQS/aSK0DptAR+h1i15U7U8HTbYm1AJo1hfFrHBPHTaeg4Su9GYWs0FbJsLRz THOAAaIfPOq88DcwhUjPGOk4qEtmcD0QAIbMIJ3YYh1mLGITyxx6/PtaccbU5Ujzv9zP fyKvt3m5h7qeW6eTMtr8q7ZFfpEFNdehJkSCPWCNjzSSdUQ+o2lWThlr64bgEIOYJgXL 6d+A== 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=XMQ9y3sIKTBhWg+aMmgR4c+8RQ5KqVUSz/E0xmozD0A=; b=GJ+irP8uoS7RrdBGlk7nZreF08xh7pYfGaJ7Sx5TMRUCXzi1wY7fCrvAzMfAlK4NKX 2/lKv5WGjPDyeXr8qsXUbz9/rHDTM8hiXWdU0LA0dEVotBDru06DKZNVGWq7vHRNiJkO Apsf1xpzNSz1Yg+vvDX7LA5m06zsX2kPB2IEjnzDnpCqLwcMdPkRVRn7aou4XjRAB/08 M5KSblDG/1T8Gf6QZErJ4ZY+8txPdzJz9WhLh2hh4H7ZeIuYWW94LCfybAmfI9ur7TEq yqKgNtx7AkVQb2/o9VlQC4Ris4/cpa37+iAYkNo6cauneQQfcTWZKFoS9qRhv1Eri1Uk jnog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fi9O/5uZ"; 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 q4-v6si18637423plb.251.2018.07.11.00.46.54; Wed, 11 Jul 2018 00:46:54 -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="fi9O/5uZ"; 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 S1732289AbeGKHtt (ORCPT + 22 others); Wed, 11 Jul 2018 03:49:49 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:39547 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbeGKHtt (ORCPT ); Wed, 11 Jul 2018 03:49:49 -0400 Received: by mail-pl0-f67.google.com with SMTP id s24-v6so8809570plq.6 for ; Wed, 11 Jul 2018 00:46:51 -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=XMQ9y3sIKTBhWg+aMmgR4c+8RQ5KqVUSz/E0xmozD0A=; b=fi9O/5uZlfCqJZApmRCZlROkMwiUzTJ1HpFl6g0HkcGHrOWzAgQwd+uu9Y2C7X8Fdl ZwQAS6BFAPmsRYEJYr5sXFmZkZQy9akfL1WEwvpIiqUULeRtv+tspKwjtXmLMN49pB3L uqH+BYc7dsPSFAwENwLBOxIc2z5fxaQUymIrk= 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=XMQ9y3sIKTBhWg+aMmgR4c+8RQ5KqVUSz/E0xmozD0A=; b=PfcWwvri3cUx9Pr6OBkTfzsV5vWmem7N91pAHLRrRK7sY+YrnnQ/xyJoAqhuyesnqg DTtT3N7/iqpaGllcD6YNcDHUg4aAtHsOaaFlxJ+9Bv2tVGSHyhlO0u/Z1L3Vga/YSc1c FokRrZXNGd+fFuxG4Y0By4lUAa9vsWKF/uGcLlEAZjbiG5asjscWbPMKRGa42tx8VRz2 5LzEKedQcLsaVKBUhXDT6CCkR8yk+Nlld4gGRiuUL5SAmFKFkEWdigB++vjRf5Uia3T0 y2ppbOv4lTinV2/yvvMrACT0M95fejHysTCzrQDIls6VAXS6uhv7A7hIQiOJyBWHaS6c rGWQ== X-Gm-Message-State: APt69E1ANCJA09ejiCl74A6+G3t/+VWWjvoNlTlAsFeoVwU9X0VeT560 hbICFg0Ez407Eb3ibbFbj4LU6WholDU= X-Received: by 2002:a17:902:600d:: with SMTP id r13-v6mr27952646plj.70.1531295211467; Wed, 11 Jul 2018 00:46:51 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 00:46:50 -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 5/6] perf cs-etm: Generate branch sample when receiving a CS_ETM_TRACE_ON packet Date: Wed, 11 Jul 2018 15:45:44 +0800 Message-Id: <1531295145-596-6-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 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. Reviewed-by: Mathieu Poirier Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 976db84..d3b7942 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 Jul 11 07:45:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 141688 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4803973ljj; Wed, 11 Jul 2018 00:47:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd0yQSAkxmpWVutQwan75dPy792dUSw1dvD5R/aWMtCTHAoLHOeF5ycpuvLx689YJllNG1b X-Received: by 2002:a65:4249:: with SMTP id d9-v6mr25735953pgq.362.1531295220289; Wed, 11 Jul 2018 00:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295220; cv=none; d=google.com; s=arc-20160816; b=NcfUB6mQ9bBQsGgbMV1BYj7QrEC18NhKudYln0BWtJ5Iu3m0jnc6uc4utwFq/X0hhu 9qtT0YnEIUM/lVZdYd1agjll7jEd41MbfogpS/csVfCc8Br5Fyt27dV2vRR/KRwTdph9 Yh9H6NJDjbSgNtFSbbibnvbj04w+Onzu/M9C0h5eFVE6CI0P+sViZOAJ+dVj3+B5+iEf xqiE5l3q6Cp4uCvR4NxWJfD686/vY7M4fmf46yKT8gmf0GLclJ7kYJ9yLcoFPL7YvZkg VOVuCRlkZTOqb6w2/CaQqzvXkdlFjJEFwB824fAaKK7fP2FRY8fHFTYt3QOJYj0jc/++ XYgw== 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=q2cz7hS4ymUe508HKlZEdy7VtTg+KDUjwdA1vqoP2wM=; b=RBZ086aocE4uNDytdCroHCBNnm+vuM/+Y+KGSqPYku2POVdN9pxvEXpI6m4XQH6LQa l2Lsb75IpDXK2CtVCXM7xTJU74v+DnNVi6Ra8sGPTEDFD11pFFZQohPxK0HzxBFtXUis hJbNSFB+eUb5w80v3zllJmRZ93NnYIK1dYHq/J44W78P+8AroE2sobAHWZ+9rTF/iWs3 oBBH6LnDs5+/azC+1eJiJG4QS2f1tSQMbimXWMXr9e/5hppRhX/SZxsgTTBBO0XM6vyI ksWEfVtJCANLoM/K77VVxhwUINSH7wn6QqsNEWkciIZLSUsGTJC+IgFn5NqIS7PirtZY uDww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h7Xtv+YT; 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 w1-v6si20534852pfl.215.2018.07.11.00.47.00; Wed, 11 Jul 2018 00:47:00 -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=h7Xtv+YT; 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 S1732331AbeGKHtz (ORCPT + 22 others); Wed, 11 Jul 2018 03:49:55 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33665 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732303AbeGKHtz (ORCPT ); Wed, 11 Jul 2018 03:49:55 -0400 Received: by mail-pg1-f195.google.com with SMTP id r5-v6so2648475pgv.0 for ; Wed, 11 Jul 2018 00:46:57 -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=q2cz7hS4ymUe508HKlZEdy7VtTg+KDUjwdA1vqoP2wM=; b=h7Xtv+YTPIWuCzsvcxgE0fOLvKn7EC/Vst3Nvg1vSZHKr1BAsymKCEM5YMpsPQyibq adk44DUmKMhhVqhkgH0OWps1Y6/XAzaCp2jz6Xte+YcjC5U6Xa/ki1cjpNyEPzQxcv35 UqHMOUAuWx58WGjqhUwwAsfoXANPK+OeJ+ZKo= 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=q2cz7hS4ymUe508HKlZEdy7VtTg+KDUjwdA1vqoP2wM=; b=SbvOG1vaW7KNUXZ4M2900zLSpiJCR0bg4kWhkfOYJ+0SVRY+1GgVNIfWSZTMoSe46p 5h/A4pLKSglm0z9ly0cYL+CmEgD/fNNx53JRfWRO64HV4BtpvrslWDquNnaeAoRKUhMX 6QfCra/5O3qUCvHAxdHi5X2HOO3d+74Pas/8erh9xZfFH+bUdJCMxqkgOs/A2fbOJcPu 4wgYwDYLp3C+y7i46COZGs80iFR/YVNuVL/4+UMVqYxRjx5/wEs31/nXSzSraK4g6cY3 8hT7A8UwQ4m3rEC3BVmU5lfJUn7p09FcjWxln+Q4YL3xlpprAchstZ7N1JzvSqh6qozS aSgA== X-Gm-Message-State: APt69E1EQjV0Ap5mkrqfkB8n62dOb5aY86VkSaV+xuowpGLVSsZL3+Rt mkptmKRAUW0pdEeqcW7woqVu1A== X-Received: by 2002:a65:64cf:: with SMTP id t15-v6mr25393915pgv.79.1531295216858; Wed, 11 Jul 2018 00:46:56 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 00:46:56 -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 6/6] perf cs-etm: Generate branch sample for CS_ETM_TRACE_ON packet Date: Wed, 11 Jul 2018 15:45:45 +0800 Message-Id: <1531295145-596-7-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 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. Reviewed-by: Mathieu Poirier Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d3b7942..2ae6402 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) {