From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F069EC433B4 for ; Tue, 11 May 2021 11:51:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C28F61007 for ; Tue, 11 May 2021 11:51:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C28F61007 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qXnO7GLaGw28XhG8rk6eTveqb7zvmW0DXf7lTIEm9Y0=; b=rE0fJDSrNIspPqj8jPuz5+CEe XAc0zRIzOo2y5Vm9c31cUAQMd/LFsHkYHv+RZPIStPJAnsWZA9CVn6/RDD/Dky1x/Q2Sp0+7moJE1 kfcV4A20xwb90eo0rse6BbTr0eKQrYexDEz6qSkLzR9n+JWYYErwUQHZBIEpssDTDdm7c3OnXcMsX kIbQZtBtSmfe/7FjOOJzied1pw1KDbPWFXcF/Ydxf+mlvjPtI4Qph9iSoeKnrZu16ADou59+CFSdW u6hPsnweOikYjP3RLoeWlgM+1Wfp/CWt+I6r4pkVqpy88cRUzKW7K5qE4XTu/AzmFHdALgtHbhLp3 /D+wtCclw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgQuG-00HDWC-7V; Tue, 11 May 2021 11:50:32 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgN03-00GWpa-7E for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 07:40:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cIBNpTle/O27myJCmciNO53uHzWamFB21GPf0L/RmPo=; b=M3nlgkn59rKzlh06TDeXm0sM3d O9BOwAX5af76odIafZgb+NLjUUDvSXuTOU7U5D8ozuoPM/4KH51PaehQnQp4Y8hDudy+oYmy3yHDB mbfFCYrL+32hHYlvgz1LPU1hvf15YXKY4mVG+yq/TJGkIBoTPIBtfYnaDljbZ9PyfM0pQFBSE+qZZ M/hfmHW5drDx2djZZuyhO5Z0JVu0Sub+hSNISImq6uuX9nJtYSyVR4iGp+i/B/F4ToKJHVgyi3PDT 4MVjJkDlc4JOjhVK9JmVFXgeDroA7MoDfdYiSI8u4JT8/6653xE+6KpjMI+aRR0MMWUKIgijC8tfH HBh0koHg==; Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgMzw-009MrE-AD for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 07:40:10 +0000 Received: by mail-pf1-x42b.google.com with SMTP id 10so15592067pfl.1 for ; Tue, 11 May 2021 00:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cIBNpTle/O27myJCmciNO53uHzWamFB21GPf0L/RmPo=; b=RJtRHgCKZRK4QDHewRkfyYxrwhOpxj8yV1yb8Iv7z/oCATNbCl2sph+jtGJx4rKymC ZRRX1kwKn8Gn0AqITdMIyhCS10fPRafujEF7imKLjE8fJVsnj9oTxjYTLt2IAk6K4ZVz TLUCsU4ELi6LFUedIWg+2HKKBZgxqHA0ZXYphpDAGDpdoqXvY7RH3pt/9Pp5IZh+Iw4I Cz/apFCxmIAZkYitJ6Ziml3T8uNOaW2exysG+KdKS44aWoAIyqPoiNCBmrK9XbCxjeyF 6XjNrhBHgdfsbIBykMWbZ35H/dzVjWnJGqkvmgYrI4hzDYO+TfBFmXmIr4D/l2VyZrQb BdKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cIBNpTle/O27myJCmciNO53uHzWamFB21GPf0L/RmPo=; b=rriGqL0hjAVcb7jTh/SR7diK/0mePfx1nLLL9hdEvTDy/bJhsU9jRM06WWjvqaI7jy s3bz8NNf5c/2y3HIbS4tDZuwSm7bXt+SIx8N5mmbjfuxp65MrDN4ZqM4PaQJc4r6cObT +wq486R0CgX7F67EF11q80/lBwATgLNrVuiHvj2Mw/zyCP8/pTdgKLfmN37TUOWXja6w 8elmSw4xyMMDpNOm4BeIhWYmp/6cizfYfsS5qTHIbPkPBFrKzWob8igCYD+1myj2SEXW tiFReEXX+nunjC0aqDfGb8U4TVx54ec5doO1S+baJVP7bBFFYDXHtMYde/WyDpCUxN1B X9Yg== X-Gm-Message-State: AOAM532sdsKJfHDFwiG9FwaKc52EsVgHR+Jo0sPBEeozaBSBCQLuGMSP tFrMLKBHyW6TLdP/OoY9BK5BPYwP1hnBuETvd9AzHQ== X-Google-Smtp-Source: ABdhPJz2KPy/gL564iw8c6ONdAwkuLnoO5vN1LyC29mdrcPXPSatL3wtEnYgoO4l2pHCSUK/06y8FNQU+cGUKrKLT5I= X-Received: by 2002:aa7:9907:0:b029:28e:ab99:2a75 with SMTP id z7-20020aa799070000b029028eab992a75mr28153237pff.36.1620718804296; Tue, 11 May 2021 00:40:04 -0700 (PDT) MIME-Version: 1.0 References: <20210507095814.17933-1-james.clark@arm.com> <3926c523-3fdb-66de-8b9c-b68290a5053e@arm.com> In-Reply-To: From: Denis Nikitin Date: Tue, 11 May 2021 00:39:52 -0700 Message-ID: Subject: Re: [RFC PATCH] perf cs-etm: Handle valid-but-zero timestamps To: Mike Leach Cc: James Clark , Coresight ML , Mathieu Poirier , Al Grant , Branislav Rankov , Denis Nikitin , "Suzuki K. Poulose" , Anshuman Khandual , Leo Yan , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , linux-arm-kernel , linux-perf-users@vger.kernel.org, Linux Kernel Mailing List X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_004008_402106_86287E50 X-CRM114-Status: GOOD ( 48.66 ) /bin/ln: failed to access 'reaver_cache/texts/20210511_004008_402106_86287E50': No such file or directory X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_004008_402106_86287E50 X-CRM114-Status: GOOD ( 45.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Mike, 1. This is a different issue and it's already confirmed as the hw bug. Reset of the coresight generator may happen at any time and it goes to normal only after the device reboot. Thanks, Denis On Fri, May 7, 2021 at 7:09 AM Mike Leach wrote: > > Hi James, > > 1) Not sure about this particular target - but previously all 0 > timestamps have been the result of not enabling a clock or the > coresight timestamp generator. > > 2) Given that you can synthesise timestamps when all the values are > all 0 - does this not imply that they could be synthesised when they > are not present at all? > > Cheers > > Mike > > On Fri, 7 May 2021 at 11:02, James Clark wrote: > > > > > > > > On 07/05/2021 12:58, James Clark wrote: > > > There is an intermittent issue on Trogdor devices that > > > results in all Coresight timestamps having a value of zero. > > > > I've attached a file here that has the issue. From the dump you > > can see the zero timestamps: > > > > Idx:69; ID:10; I_TIMESTAMP : Timestamp.; Updated val = 0x0 > > Idx:71; ID:10; I_ATOM_F1 : Atom format 1.; E > > Idx:72; ID:10; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0xFFFFFFE723C65824 ~[0x5824] > > > > This doesn't have an impact on decoding as they end up being > > decoded in file order as in with timeless mode. > > > > James > > > > > Because zero is currently treated as "not found" rather > > > than "found but zero", this breaks the decoding flow > > > when it would otherwise work. > > > > > > This patch adds an out parameter and return code so > > > the difference between zero and non-existent timestamps > > > can be determined. > > > > > > There is also a change to fix an underflow. > > > > > > Although this is a workaround, the change is technically > > > a valid way of writing the cs_etm__etmq_get_timestamp() > > > function. It could have been written similarly to this > > > without trying to work around this issue, so it's no less > > > correct. But, because it's a workaround to a problem > > > elsewhere, I will submit this as an RFC for feedback. > > > > > > This patch applies on top of the "[PATCH v2 0/2] perf > > > cs-etm: Set time on synthesised samples to preserve ordering" > > > patchset. > > > > > > Co-developed-by: Denis Nikitin > > > Signed-off-by: Denis Nikitin > > > Signed-off-by: James Clark > > > --- > > > .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 5 ++++- > > > tools/perf/util/cs-etm.c | 22 +++++++++---------- > > > 2 files changed, 15 insertions(+), 12 deletions(-) > > > > > > 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 b01d363b9301..947e44413c6e 100644 > > > --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c > > > +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c > > > @@ -320,7 +320,10 @@ cs_etm_decoder__do_hard_timestamp(struct cs_etm_queue *etmq, > > > * which instructions started by subtracting the number of instructions > > > * executed to the timestamp. > > > */ > > > - packet_queue->cs_timestamp = elem->timestamp - packet_queue->instr_count; > > > + if (packet_queue->instr_count >= elem->timestamp) > > > + packet_queue->cs_timestamp = 0; > > > + else > > > + packet_queue->cs_timestamp = elem->timestamp - packet_queue->instr_count; > > > packet_queue->next_cs_timestamp = elem->timestamp; > > > packet_queue->instr_count = 0; > > > > > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > > > index e5c1a1b22a2a..1969921c406a 100644 > > > --- a/tools/perf/util/cs-etm.c > > > +++ b/tools/perf/util/cs-etm.c > > > @@ -210,13 +210,14 @@ void cs_etm__etmq_set_traceid_queue_timestamp(struct cs_etm_queue *etmq, > > > etmq->pending_timestamp_chan_id = trace_chan_id; > > > } > > > > > > -static u64 cs_etm__etmq_get_timestamp(struct cs_etm_queue *etmq, > > > +static int cs_etm__etmq_get_timestamp(struct cs_etm_queue *etmq, > > > + u64 *timestamp, > > > u8 *trace_chan_id) > > > { > > > struct cs_etm_packet_queue *packet_queue; > > > > > > if (!etmq->pending_timestamp_chan_id) > > > - return 0; > > > + return -ENODATA; > > > > > > if (trace_chan_id) > > > *trace_chan_id = etmq->pending_timestamp_chan_id; > > > @@ -224,13 +225,15 @@ static u64 cs_etm__etmq_get_timestamp(struct cs_etm_queue *etmq, > > > packet_queue = cs_etm__etmq_get_packet_queue(etmq, > > > etmq->pending_timestamp_chan_id); > > > if (!packet_queue) > > > - return 0; > > > + return -ENODATA; > > > > > > /* Acknowledge pending status */ > > > etmq->pending_timestamp_chan_id = 0; > > > > > > /* See function cs_etm_decoder__do_{hard|soft}_timestamp() */ > > > - return packet_queue->cs_timestamp; > > > + if (timestamp) > > > + *timestamp = packet_queue->cs_timestamp; > > > + return 0; > > > } > > > > > > static void cs_etm__clear_packet_queue(struct cs_etm_packet_queue *queue) > > > @@ -864,11 +867,10 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, > > > * Function cs_etm_decoder__do_{hard|soft}_timestamp() does all > > > * the timestamp calculation for us. > > > */ > > > - cs_timestamp = cs_etm__etmq_get_timestamp(etmq, &trace_chan_id); > > > - > > > - /* We found a timestamp, no need to continue. */ > > > - if (cs_timestamp) > > > + if (!cs_etm__etmq_get_timestamp(etmq, &cs_timestamp, &trace_chan_id)) { > > > + /* We found a timestamp, no need to continue. */ > > > break; > > > + } > > > > > > /* > > > * We didn't find a timestamp so empty all the traceid packet > > > @@ -2286,9 +2288,7 @@ static int cs_etm__process_queues(struct cs_etm_auxtrace *etm) > > > if (ret) > > > goto out; > > > > > > - cs_timestamp = cs_etm__etmq_get_timestamp(etmq, &trace_chan_id); > > > - > > > - if (!cs_timestamp) { > > > + if (cs_etm__etmq_get_timestamp(etmq, &cs_timestamp, &trace_chan_id)) { > > > /* > > > * Function cs_etm__decode_data_block() returns when > > > * there is no more traces to decode in the current > > > > > > > -- > Mike Leach > Principal Engineer, ARM Ltd. > Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel