From patchwork Mon Jun 18 05:09:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 138844 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3529759lji; Sun, 17 Jun 2018 22:10:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtjUdcywTtvsb5cU4Ji3WYXypibjz+M978ksuv/yYENqixZnpZCTb5ALDrTtGOranYGvit X-Received: by 2002:a17:902:343:: with SMTP id 61-v6mr12377314pld.344.1529298651842; Sun, 17 Jun 2018 22:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529298651; cv=none; d=google.com; s=arc-20160816; b=xcv+eVL0e4ADdoeldtx+6TTMSTB8mlcNJDMX2vmgudSuYiqLSgT5l135K19lHMpeJX H+kCcYdX7IhhMzW9XtDFZfs0VxUO6yOBq54zpQzBjzMrreSE8ojYlceRJFx1rnw5gh3g 0y20cg9AhS5biGkw9DHuy7p3mJhdKp2ZBdg7eJ0wryR8jvBx3yl9hzUFzznr4j4Wa9ft zrxGrcJI3iQI69Llp5iyse+mub58UTpn92G70fDCiLurksB2PwM0gRxg/Q1g36w5+u+m 08OYhTnZXCMk4w32A8xPi/Jj/P4sdKBmTMvYqBPnFCOQMncc3QOlLAM9mCtvP4YqbitZ TgWA== 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=PTyHBCkH2jOA41M04ze7TFjT8uK1c0mYi0ne/zqeRPI=; b=zmAwgnjCAASNz/mUMfKVbfVvosamF7WlbfY5cfa54GqSWtte47ZXEsvvifzJMep0HC uwBQwsP8ptY/pcm/QmH9g7JQrRz5nstKtY7mX1nL4FOj3hC3pWXPmTh/6ru27B6yF9Zk Xgs8uSoxJWy0YgguVCN2SrLcxiXr2NSKT7wzhulhVPt3hT5tYbFEBT/ZM3ijwbdkleQF 869fGaO9pn2IZz3Dn5qtclmhpxoxSl2XlM6zg8dxM9oOF52OFRkF/eENCHxwNRyDPwho L0NTT3LY5s1DLPu1zH5wDQfaCTNwH1I+v7mrYe3dJG2E+FWREjJcSGOkSdWMX28p6PbF T1aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PxXTeWDY; 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 n5-v6si13831125pfi.360.2018.06.17.22.10.51; Sun, 17 Jun 2018 22:10:51 -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=PxXTeWDY; 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 S1754573AbeFRFKk (ORCPT + 30 others); Mon, 18 Jun 2018 01:10:40 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:43065 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbeFRFKg (ORCPT ); Mon, 18 Jun 2018 01:10:36 -0400 Received: by mail-pf0-f178.google.com with SMTP id y8-v6so7550208pfm.10 for ; Sun, 17 Jun 2018 22:10: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=PTyHBCkH2jOA41M04ze7TFjT8uK1c0mYi0ne/zqeRPI=; b=PxXTeWDYr/i8hZWOLby54jizoK8xzVqNvY+Ahl2ktjGMpmtH3xyi8R1KVqO2QPaa+Y cDb5w7kjS6KfsHl063PkD4LcgOHzgQ+A99Z1++1xm4BiKIrg1SBxTSUxPt1L2wRuYLUP AcakncmuOycBLX8GalaLQZZKqeSCKgBUFoBPY= 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=PTyHBCkH2jOA41M04ze7TFjT8uK1c0mYi0ne/zqeRPI=; b=lpR+Kas8OK33LGIZZ+eDauavDaqbwNCQ9W1tkyUrEdY9cJvp52r8PYFNXbaXxXL3dN WWumG6LH9+NjxraUs9HOHK2je6wkDf1UX6i7h5H6cqfmJKc9KQdE5S3NLwYIhUT4UVAJ kmFpESyHQw7WLcx529bCKR2ojjtx76A4LQjKtaDxDg1SX22RdJHv/asrpPPdv+G4Xmwi /HX9FbVtk7UiuPW1ycKfJh2r9gzxHrR/IfmE3UvEa6fmiNpoZ6jb8bKO1QXeKN4rBU3f FDxl3XlYgGtwbCbXFWOTY4oRp0leFQywtDP74CYUXeWGlebpER9Nm3NRO5ojt1GrKHs+ kbpA== X-Gm-Message-State: APt69E3wQPe7+PLb63T0w/obn/auurYCq1dnyyXrwhZS1GkvhPDXAcqP j428vnrVkZb5jyqd4mEVg3L1mkSmYts= X-Received: by 2002:a63:2c94:: with SMTP id s142-v6mr9466225pgs.39.1529298636353; Sun, 17 Jun 2018 22:10:36 -0700 (PDT) Received: from localhost.localdomain (li1181-92.members.linode.com. [45.79.82.92]) by smtp.gmail.com with ESMTPSA id l15-v6sm29051710pfg.88.2018.06.17.22.10.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 22:10: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 v1 1/6] perf cs-etm: Introduce invalid address macro Date: Mon, 18 Jun 2018 13:09:54 +0800 Message-Id: <1529298599-3876-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529298599-3876-1-git-send-email-leo.yan@linaro.org> References: <1529298599-3876-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'. 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 Mon Jun 18 05:09:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 138845 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3529764lji; Sun, 17 Jun 2018 22:10:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLguqlAKvwB8x6KKIqEzl+vpici4wPoL4JZFkXNyiG+OiGAZtrj2orzxOWZhAEUCFJJjtXF X-Received: by 2002:a17:902:2927:: with SMTP id g36-v6mr12274460plb.303.1529298652185; Sun, 17 Jun 2018 22:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529298652; cv=none; d=google.com; s=arc-20160816; b=bWB59cvTGozSsuYNfibJyhKr4/Uxpe1D+4akZA19K3XK6bUbRUKFzHwpDDzsZTYe9n UtfuLu+nsxQoOO07B5kNoeDxD65vH6jMrJh3qQ4Px3XzXgggpz3qsCv087lAmcyS3mVj rgZwNRH5WLzG9J3ZQVZZMXvOLeFqoKcPeZipN37xpIQCt8UEEcvru0F+DMhcagO2X93r XyxpcMWCcWZAI2kJtzr7DT3As2hE5KPPDi3vfa+TiiE/Pb/eiDL5undhh5AQKWgU021Z w8E7MX68BNqddEnKXWrYMYDzCB4YLbwJfA44rNh8R40BSrDMWPRZ3FfTyTDZQxk15sfV lDAw== 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=P8F/rdx0Dg+tbAP4xRKVzOUZryhhTxWfkI38tLb+Eck=; b=B6IwuvgqmeAedTgV+Jg+VfjkvVspCe0z+d+XfHn6JljA/6StOAUHR/+E9/DTQHcJSm lWPaD/IrRofWnh8EKFtO5bOCa3M0nv8rLkd36UuJa62D1EmXQ3awmmJPk6RXkSvd2IRZ NfvNAbG9Rf1ZP9GbpxwTtj24FrzpRgtaVoNkGavNPWXUZfp58DDPGkB+agKQxoiIVuTF eRrQ0gRT6x1igHOX/mZK10s6RLozYxsCxnyN6l8vx97IV5DxTsJvDKD5d9uGmHL8eQf2 PktNoe3iwCTIbcjaFXzKjm0BpvKZj2Bkimou7KsyFm5n+w0Bb/XpnIrJ4pTuBBAPwBk0 x9fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AJPw/IX/"; 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 n5-v6si13831125pfi.360.2018.06.17.22.10.51; Sun, 17 Jun 2018 22:10:52 -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="AJPw/IX/"; 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 S1754712AbeFRFKn (ORCPT + 30 others); Mon, 18 Jun 2018 01:10:43 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36587 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbeFRFKk (ORCPT ); Mon, 18 Jun 2018 01:10:40 -0400 Received: by mail-pg0-f66.google.com with SMTP id m5-v6so6966261pgd.3 for ; Sun, 17 Jun 2018 22:10:40 -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=P8F/rdx0Dg+tbAP4xRKVzOUZryhhTxWfkI38tLb+Eck=; b=AJPw/IX/VN0XwcK1Ched1kGfQBYDjuanEYGEs/y4J+hLXkavQTnpY6xZNhinOXqWvP PE1fQ4QPcFombM4wCpzkn2u7sslK0CiLeOW1//tilXlowC3BtVpVJ1LtSLA8qeyaiduA xrgUHPr0fPSe175W02wB8+lHCUmhx1OiZiucM= 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=P8F/rdx0Dg+tbAP4xRKVzOUZryhhTxWfkI38tLb+Eck=; b=CZL5uwNfWexJheLtjbU8t9nTnrCJxx5ZRQswJMeo+kwW+KBZRpaKBNiCLDj70UWN73 93yT1QfK1E0OfpfILsXA2UtEqcbL7PborF7SuqIxFTEBcR6DjC6xgb1uaVqTKQSCR8sq v2wx7cJ/8tDWJuiwTzxwchDqRjIgobHfUL7I275n7nC0erbCr9rE/sZ1RtuBLbGKkGFk +Ho1rCbzWcpg91q1i84A/PSZ55/ImSLgY/R7JXA+syIepOIRNFvrI/daFmPsRTzABNC6 Xdcd6kJoHPFuIh06npD0j953X/IduqxcPR2r5+Ojsn8hmuPm5yIFBPv0yBiMq9XKRcB6 eZsQ== X-Gm-Message-State: APt69E35WcooU7/B2kv7emgM2DqTJVBY+DVGduLqLIHrNslxFr1IFHKb cH61ghzTFC5IzZwyNIHmblLpRQ== X-Received: by 2002:a63:902:: with SMTP id 2-v6mr9540897pgj.3.1529298640259; Sun, 17 Jun 2018 22:10:40 -0700 (PDT) Received: from localhost.localdomain (li1181-92.members.linode.com. [45.79.82.92]) by smtp.gmail.com with ESMTPSA id l15-v6sm29051710pfg.88.2018.06.17.22.10.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 22:10:39 -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 v1 2/6] perf cs-etm: Bail out immediately for instruction sample failure Date: Mon, 18 Jun 2018 13:09:55 +0800 Message-Id: <1529298599-3876-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529298599-3876-1-git-send-email-leo.yan@linaro.org> References: <1529298599-3876-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. 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 Mon Jun 18 05:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 138846 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3529793lji; Sun, 17 Jun 2018 22:10:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCbWIaBvU2VVus67S0f0z3lOgCbjdTxWHgNfmMhjfZCjGmjDWt5ipQKwnZ78RyipmxzAXL X-Received: by 2002:a62:f705:: with SMTP id h5-v6mr12053966pfi.169.1529298654863; Sun, 17 Jun 2018 22:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529298654; cv=none; d=google.com; s=arc-20160816; b=HHIuc/HfL9XWEFSlBQAGAtOpV7cH4cRkfyY/Ux1FhLKGJwPh8oWA+2DW05flbeF5BR He2Of5smzmPaEhzBytB5syDFU2PNgLlaRev4KMVJM/Otxcyk72JBZ92rgYnTNkTH1KpG IHaXHVZnsakNBbHmKTtYBWqV+q5+NTLV3P4cOrK/S4WNGIWWKRS5whvGwL5UCjq4CiNg fgqmx/GBqi+PGDVaBgzK76fJyU1jYLwvD1Zui36p11vpNZwOujWKVWVBP2tvoqgXqJYI p7TdPXyWw3PXVFbb+X7G5n7YZLYHNhmOAZosFu9shrzIZg8UEvGyjtbU205gxzUm4igz +9Xw== 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=RhXey0Jlqp5lMh1Tvv94h72eqzeQPgFS1KWBXkgo+88=; b=gmW3Wj6p9Hs56c5ycqyIj91nfm1x5nRJi92n9dTbdvlsSVxyU9F/aDLLIKIPIbrzl/ mkPWiNFrG0MOaDyuIL8wHpm368shkeX7ei5sBBdJ5ITZ18iethaaaTAg223gIPQY8jzE PEWFh9wqxcnKI44EXAfkD373gUzXljar808iGfmwEm6oohh1A24C7rAkFictFtRdWGfq Mfm5+esA6TB8BmlHLQr5EIVVb/6qX5O2wS1kWHILxmY2PeEZz0n2fuHP76Msy36vEDbX DpDUKR1mPnlvmb4Oht/sRVH5yWYQEr3zDIkIP/k5n1Xed9c0chgJNH4GMORMavjNfu7e UH0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sy8DMrZ+; 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 w10-v6si14499211pfk.14.2018.06.17.22.10.54; Sun, 17 Jun 2018 22:10: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=Sy8DMrZ+; 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 S1754739AbeFRFKv (ORCPT + 30 others); Mon, 18 Jun 2018 01:10:51 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:40735 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754714AbeFRFKp (ORCPT ); Mon, 18 Jun 2018 01:10:45 -0400 Received: by mail-pl0-f67.google.com with SMTP id t12-v6so8348976plo.7 for ; Sun, 17 Jun 2018 22:10:45 -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=RhXey0Jlqp5lMh1Tvv94h72eqzeQPgFS1KWBXkgo+88=; b=Sy8DMrZ+0L8KlPCHh3m6ZxpNJvameyteO5e2eariergV3cFQiXG71LmQaUWKOMpz9q uIqJmfpH6/DiryKCLnhSqJwAAy/jWqbwRBu5z9LgKWULVtlxBlkkMZPehdxsOQQCF74/ WdRcJnbHLd/0+YaZPjdqh/Wtie/b+tJXiYnhA= 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=RhXey0Jlqp5lMh1Tvv94h72eqzeQPgFS1KWBXkgo+88=; b=RsC3zRzfsrK6H04nVWBSjD4izP3SpqeTAV7Q+wWLwnQFDnFZyDH8/3G4603zG9bjfl ZqJq3Rlqzw8KFOJQ8e9fehDOF0jgiFFx4n9tEsGUldNEBe7cR/LrgAoia5/pG0mFudvo dtQeReYvJ2UWFdT0JEvHoXnp2c9W5Ji/XsMNmULsOSTwnsNC7bkP27A5CBfDbcV84EDQ 6Cq5X/+/lnQ+PAJzejmlrqxruVzzDoBFzNzWz8jgPwhgQevE4/zsRiebA52FLNYJ7TZy Ftb5+Tl0WeiAv+xws7b5yF2W7jmnVqCOZjjY9+tRDFZbT5drFsXE3Jor3bqUzrJTYkIs zLWQ== X-Gm-Message-State: APt69E3SNuXDu479CicTpJHwTONA0761Oxf7nS9+Z1RGKdae1Vfqalxx x8XKoysDBjnRHWwwhWkiINj7pdK8TtA= X-Received: by 2002:a17:902:9685:: with SMTP id n5-v6mr12366608plp.15.1529298645013; Sun, 17 Jun 2018 22:10:45 -0700 (PDT) Received: from localhost.localdomain (li1181-92.members.linode.com. [45.79.82.92]) by smtp.gmail.com with ESMTPSA id l15-v6sm29051710pfg.88.2018.06.17.22.10.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 22:10:44 -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 v1 3/6] perf cs-etm: Fix start tracing packet handling Date: Mon, 18 Jun 2018 13:09:56 +0800 Message-Id: <1529298599-3876-4-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529298599-3876-1-git-send-email-leo.yan@linaro.org> References: <1529298599-3876-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'. 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 Mon Jun 18 05:09:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 138849 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3530322lji; Sun, 17 Jun 2018 22:11:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKqXGVq69/dYxGcEBEwg9OUrbbCeIW0f9q2PqJg287egVmS86VTytmfjG2HNuk3CFv6kT9t X-Received: by 2002:a63:9a52:: with SMTP id e18-v6mr9723705pgo.188.1529298702760; Sun, 17 Jun 2018 22:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529298702; cv=none; d=google.com; s=arc-20160816; b=ke1JUWgOKtOsxtvn+KLfjwSflKytcYq8M+JSuZoOx4fYMHElyzVzc3DBW2DkEvJcuC qCXpr1FDY31/Z9lmosn35D0sC65fbv44sHUim4Sbg3MoV6IMN8tmjQBgS4gcJhhA2bSx E108ATigL/pe+B2GG0R4Jn2IZHcrGa3dQoUgz5ziqGXAeDVAxQL1R2MA1ryLr/4Rkg9h PiB1nEEfx10+at5bBPAGlkfF9jQM9bUe2ychC1UNqwKeOBBjfRaKeciVBG/rcgzb+xJ0 E4uU8OpcRoyEFIegJY/GFSfJMFIKukX61S7xJ8l7CoSxpxHvsuytaHYXWCckRSC2IPYH jqdA== 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=VluCxox9i+3sQWY1zqCtkHVxp5JhXszaU7yPvjVQVQo=; b=ROUTNFFR85hnB15cnyz8SCY83QsCaP6T2rFZNUUvED/Mgi8tCPK6VS/tD7k9TF3E3s ZkuboiTY/8+4ScGWJrH1qWtvy8wDns1nL1olJo6hg/hrTB1Oa7wcYv5eSnDC9BCAbU37 UL92RyEiPHFwMa6LGMSb4yne50t8DXyNgHkiPF0fruiA8HIggGZKrfJ6b5OYuY0nGKYi Dv1vrGray/fq4r6g2HfFEJRDpVlME5nqGnMVvE4Iq3elt6zVmbQaduc+9+dGu/rejLBf BwHxOlqjm+k+3Yms06Qc3mY2xm7xPn4XSQqlI38f8+KC2pXkcoXKWzHfhQ4wRyaaiq5T JQxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZYOhmqgm; 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 v4-v6si13832994pfk.116.2018.06.17.22.11.42; Sun, 17 Jun 2018 22:11:42 -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=ZYOhmqgm; 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 S1754856AbeFRFLl (ORCPT + 30 others); Mon, 18 Jun 2018 01:11:41 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:44572 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbeFRFKt (ORCPT ); Mon, 18 Jun 2018 01:10:49 -0400 Received: by mail-pf0-f196.google.com with SMTP id h12-v6so7546816pfk.11 for ; Sun, 17 Jun 2018 22:10:49 -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=VluCxox9i+3sQWY1zqCtkHVxp5JhXszaU7yPvjVQVQo=; b=ZYOhmqgmlPCpkPaX3GPPro7Z9Dne6z9R2muhpb7SRLqgtHtTDwzlw11aC5A3wJXdXd +feNQaz4vlmvHWj27G2ltDDCY4Bn7n3r6xXiJprbntvsmqc/PUlGtCYwekFJAxFhq+57 KUPGkSbsXnUJ9q7FYBFmf+koTxEJRMDVmSZOA= 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=VluCxox9i+3sQWY1zqCtkHVxp5JhXszaU7yPvjVQVQo=; b=TJ0dDMpOOhyyv7RTPmTRmHdXkb+26q040kKCR9eVc6GelFYM+LtkjiK+SpnwKAIkBO yTxDVnGQy4Iu8hSn3S5hfDKFSwKVEtoDa9Aa7bXYwGlte06Y3k3GIwknN4Vvl1DoSyCY 98yrbdE+tSLflWWxPO2HNggRk6M7fJxP19GuGnasyv6nzVXrRtfV/NJ9xDyDS4hStCcn p0Nx13y2wIkcCeJAx30hpqZkLAjgBTU7AFYfGSQo4jAwCsE4+cFhZg0hEzdf2fc7Tjhd E59pGYYhwBLUbS6VREHrYwOwcSQFAG8qoKF9Ce8B6SKvSydEwxbH/RcG98Wz/pEWK2wM f9PQ== X-Gm-Message-State: APt69E3w1Tq6WbzIyhnMEveqpnc+sC+yfV3m/bIrjEVvQVR1jeUIeieL FMngpTweKDT7IkcMGSJpXv+nhg== X-Received: by 2002:a63:449:: with SMTP id 70-v6mr9788230pge.229.1529298648903; Sun, 17 Jun 2018 22:10:48 -0700 (PDT) Received: from localhost.localdomain (li1181-92.members.linode.com. [45.79.82.92]) by smtp.gmail.com with ESMTPSA id l15-v6sm29051710pfg.88.2018.06.17.22.10.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 22:10:48 -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 v1 4/6] perf cs-etm: Support dummy address value for CS_ETM_TRACE_ON packet Date: Mon, 18 Jun 2018 13:09:57 +0800 Message-Id: <1529298599-3876-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529298599-3876-1-git-send-email-leo.yan@linaro.org> References: <1529298599-3876-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. 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 Mon Jun 18 05:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 138847 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3529866lji; Sun, 17 Jun 2018 22:11:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHKGrWS0b8tshmX4RkI4bYBTfSemkKDFxHMYXXtSRdg9W0KSwohKY8oaSFSYqCU8eGcCDd X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr6996529plo.337.1529298661624; Sun, 17 Jun 2018 22:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529298661; cv=none; d=google.com; s=arc-20160816; b=FPX8RDDQVQYSqrU92/Uv8X5ImnNaThTDcnY9fE5CsS225bRVwGz+kkHMQibauEBwJR JgykBz+keNyVqzTVRoBlwkjZgHZGGzHni0FMilNhcTTJUHRgvmdu0I7F59RtQUZ0pt27 WweqCmfhjxlBxQxucML/jO+WYtbC49w0ao2f6pMjgyzTokixlNhKDp61OdwFrEWhEeCQ MX1KlvrPKBRlO/ab8CaqB+wU9L65SkVS4joaiixNK4frTgacaiP8M2tWxlWOQVJDjkls LjB/qa/l2av6+bKT9t4lb/4V5R2b1w1GqHs9QZQz1su/959d1GI77y61U7QfGezfghQ1 9ddQ== 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=x4bCg0+QmGBErc/o9N6g33Yfeba+eCNRT/trwWTp3QM=; b=k5aDeTnUNYd1Nnm7F8jcfd+LOspyN2orhdOEA0M1mcWqt7/IqtpFf8ONOpwqsi0sdT Yh/kEec5huNXN3O2OmkyAZ4lUc2MQhOcCbBxTc2Hqb3LBjMX2/X4wyAiGl6KXvx6BRqD pCVKGtIkSPUiEWf6E420E1mdDKuhRvU7EVSGYsxKEvCxjPWyHUSclzpnzf3zq1wVy7dP 6xcNV484jGEuuscV9rZMS2gE8ea1xjV3PCyVrdElnFQTaXtn3unOTjqRY4vopIKmJpDn pDHdqm+Kw2o+KZdJ6GoH6FIWnrD6ijg0ZUlaDhn2+ismJD4fXoaegsPbYxf18xcvAKxW eUBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OyyjVDI+; 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 b125-v6si10161711pgc.514.2018.06.17.22.11.01; Sun, 17 Jun 2018 22:11:01 -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=OyyjVDI+; 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 S1754814AbeFRFK6 (ORCPT + 30 others); Mon, 18 Jun 2018 01:10:58 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:41932 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754759AbeFRFKx (ORCPT ); Mon, 18 Jun 2018 01:10:53 -0400 Received: by mail-pg0-f68.google.com with SMTP id l65-v6so6961507pgl.8 for ; Sun, 17 Jun 2018 22:10:53 -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=x4bCg0+QmGBErc/o9N6g33Yfeba+eCNRT/trwWTp3QM=; b=OyyjVDI+JmXNJCagSbatad/T/dqDZJk1jZWxeKF4K7sl7emYbGYdrFsfcKHSmf/Qcf cfxExGlwfxdBWfvgvRLcR9abTdyhQJGQ4igbfZR9nCgBGJrGGRDxQ9a7CvRx/Xh8XXCS dKty8p8y2v4Zc8wq/tNb6kwGBmctX/2tSV7IE= 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=x4bCg0+QmGBErc/o9N6g33Yfeba+eCNRT/trwWTp3QM=; b=onczX00gwdWpii0FD1jPnRczk+nolsREDsaDXvY15kxZWTsjS/9xG+XrY0koUl+G6B jU6FaVotVinTPuNT8Qx6ZzP9I9Z2FhmtvUVrv3R2iqZpqP359NFr21OMgzUHWEgUSF0S 2JiCHZgebo3V/7pzGUnt4QhUIvwmX9DGNOAxCloeAr6vyMmSmrNj4fFBsLGejb897wON bSnsjD0u5WkZkiYHw+ornbi09/k2aLUZzoN+3s7XZf6xdBDiYGTzMqZ3KQrV7v1AIpww khpn/ZdHbaQkbMBYRfARNQbiAS9cP/b59cMfZXTihc8mu9jUKSPGh5Jqs7uVHsiGtoPy Jjfg== X-Gm-Message-State: APt69E2Rjd3Sh1IQFLke195CY/cNfjmLuqUh+A4g7JBRvjFC/8yqtZzD ZVdQtd7tCasqRWfppWQ8+1E4Vw== X-Received: by 2002:a65:6343:: with SMTP id p3-v6mr9803912pgv.63.1529298652894; Sun, 17 Jun 2018 22:10:52 -0700 (PDT) Received: from localhost.localdomain (li1181-92.members.linode.com. [45.79.82.92]) by smtp.gmail.com with ESMTPSA id l15-v6sm29051710pfg.88.2018.06.17.22.10.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 22:10:52 -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 v1 5/6] perf cs-etm: Generate branch sample when receiving a CS_ETM_TRACE_ON packet Date: Mon, 18 Jun 2018 13:09:58 +0800 Message-Id: <1529298599-3876-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529298599-3876-1-git-send-email-leo.yan@linaro.org> References: <1529298599-3876-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. 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 Mon Jun 18 05:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 138848 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3530014lji; Sun, 17 Jun 2018 22:11:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL67v5MNqlARRM2o34bxGh9WSxMODSjMqjdDr/wqW8VJyhgyOHlPZgfSuyK5DpTcMujFpXF X-Received: by 2002:a63:5014:: with SMTP id e20-v6mr9680162pgb.133.1529298672238; Sun, 17 Jun 2018 22:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529298672; cv=none; d=google.com; s=arc-20160816; b=GlyVREeoz/n7SqukR1uFNwWh5flxnAiGtiEd4W8qV7Q6TywsuVVtpZ95hLyxepxxfP 6fHN4AroEStURs3zXBe0ZNURpKNnF3FTl7M8DNLMD69zOq47/NyfU7q1WkQpFKItx9MP Xrqd4qrNjwOElrDchBANFVnCGLLhsI2cgk+t9pMs2e+jpnUt//NdM4yF0Q6REwOfeNR1 478sSNEhtVIiZCXSK12I8dFiS353Kib7FqlgeDX4F+ceDo14LFXCx45OpwVYjYjzWbsE OOVYTwGp8s7oP+WRSga+MX+JUGvk3agh8TLlo5bJhSIx5w115+2li7PlZUaljAgk5p7K Xqhg== 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=Gd2fy0/Z7eDf8iwKzTR/pYByVowIHmmoYAASyMjR3u4=; b=EJd9Iijp7rDBJI3Eta/txfXvVlEIL9fBqgeiufn41DpUO4OBvgmkAqclu8sUDYaYPj p6XLXyY5mvAPVEAG3GapS4JQbVlxbnYQ54CpzjjUeWZMGh9xQUy/FslNt0YSO3+UQp7V hGtoGczdOf7CwRMp2PYHmmDq+5+JCGfZhMOSphUVBkpnBIj5q+yYN4O8EkitmaNPqhxG 1ReD7GFFl81snv4/1fvV0RfwBVTv4rE9MfmGFQcY69vNU94TCjFgY5iyZjWwNZzcigGY bowizeDwGheTbY8K9iW39GRrNqFyIrFJF4YNZBHZFjGAXP89e5Buq9cp6FQxfEDiYLrS ogtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QU0ptk9R; 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 97-v6si10377717pla.155.2018.06.17.22.11.11; Sun, 17 Jun 2018 22:11:12 -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=QU0ptk9R; 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 S1754846AbeFRFLK (ORCPT + 30 others); Mon, 18 Jun 2018 01:11:10 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35270 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754793AbeFRFK5 (ORCPT ); Mon, 18 Jun 2018 01:10:57 -0400 Received: by mail-pl0-f67.google.com with SMTP id k1-v6so8368252plt.2 for ; Sun, 17 Jun 2018 22:10: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=Gd2fy0/Z7eDf8iwKzTR/pYByVowIHmmoYAASyMjR3u4=; b=QU0ptk9RwODRXdDVXA6KMqe/5VRxS/nIgh0gTSbLtLTrup+r6IPVnLoybL1Vgfjm5p Zrzd4Icsb4sDwruJCTtv4TWzRVOhQHspoDdiPkfvNg5ZHQBp4M3Zc2tjL1e8SB5DIr9S dmu/nz9pWFB5kWe1DgXRjxGlW/5q5cTNwf92A= 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=Gd2fy0/Z7eDf8iwKzTR/pYByVowIHmmoYAASyMjR3u4=; b=XEnocCx63TgW21pVIOkZ8vsWJrclWJlElmRIMTDujm7tTmKutowcAxI1FcZVggA+y7 cZ/R5kPZ03kyQaFTB63NL//36hcClLAC2R7tConT2C0N131VpFHN03h/3GfeItdwjsMR weBuHBn7ZxolWmzCfpnyIGxP9Ri8R+nw9UMu3WFhppTF2yXzvbmHgtYv04WtBANYLcMc yENEI/2v/faJa4B9mmFLx7xGvGMeLD7FC+Ky+6meQIieSbPofyR0muER9vxYYrp6cesd Bt4xpqrS1Ps8uCuts/N1GE0zvKwngqMmZESLVWcXe/9nV1cLkE6x/V1S5c7NrK5rdpd9 S8fw== X-Gm-Message-State: APt69E2UwIGBBeRObkw1TN+xeqnbbYUzTwA0d0DDBfIMkQohRsp2EfIX l8MS8GoK6Vq/4ouUzBj3atPiNQ== X-Received: by 2002:a17:902:7891:: with SMTP id q17-v6mr12676679pll.186.1529298657213; Sun, 17 Jun 2018 22:10:57 -0700 (PDT) Received: from localhost.localdomain (li1181-92.members.linode.com. [45.79.82.92]) by smtp.gmail.com with ESMTPSA id l15-v6sm29051710pfg.88.2018.06.17.22.10.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 22:10: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 v1 6/6] perf cs-etm: Generate branch sample for CS_ETM_TRACE_ON packet Date: Mon, 18 Jun 2018 13:09:59 +0800 Message-Id: <1529298599-3876-7-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529298599-3876-1-git-send-email-leo.yan@linaro.org> References: <1529298599-3876-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. 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) {