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=-9.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DD929C433ED for ; Mon, 10 May 2021 05:43:03 +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 5811B6135D for ; Mon, 10 May 2021 05:43:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5811B6135D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AlA9Z/LX1veICCggng+0/Ntr0rsLyFUthxKtEqNTyo4=; b=aLngYqZ727v/JNiT0k2e5KLbm KONzzarhWkrw7TrNo3iQEo9TaKuvdqugT7OS7FkwR+n63QNvYhAbimbEcFPd7ehJmVio+0DDjpKyN qxUdDr8/6qPKxrib091ctFZalAZcs0Yn3yFJWvNMhqVqt9GW/mSypYWMlODeUyzSEQAAg5pQ8TDan AkZwTJkhNppUTC/y47njbU5q0xdnayAX15q3GpKalN4WocGV+vVeHFN20jpxyfaq82n/URGSHRG0U Ou1JUoVV+7zcg+VCWtB8+ZtKWpcrFsrM78t9j++VzV+ND9pG9pbWe78jaooknN/1KmS7Zvp3YLQP4 Hhb1cJqnw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lfyfE-00DE6r-1p; Mon, 10 May 2021 05:41:08 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfydQ-00DE1b-EQ for linux-arm-kernel@desiato.infradead.org; Mon, 10 May 2021 05:39:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9QjThyFdbfEEV7YSdHD2NDT9j0pnbAN4OFRmYnpNSIo=; b=Lqq2HP/UzuYUajK872r+zlRiaK HVWg4bbbIQz29IkBJkJaW3KaCepr+rL/pI4kEh1iPidGz1sVYDGzrq0kowYko+IV9KWKgcJzKPDKP nck1HBfCqCNPI3az7YXGvL8stDPvgWMlQu4kXni0c2fl2DBQWeOSIFk3Wk4pXMxRomxxrwvd0Evx0 ZnvJ8rSxSMuF4Pd2Ms1bJcX7YGVCrSlmGHS/CmFkuZqi22VJtWCxNB2BDOA8f2ZzoSsZNF1DwINxB n9u6L9Z6LcT4DZAdIu4s6O1sNBB0Nv9hv5fiIpqAPm69XyRtTmX8v0HKVX6Dun10AsTxc5XnEeq9A K1CUQNBw==; Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfydN-008J0r-Dp for linux-arm-kernel@lists.infradead.org; Mon, 10 May 2021 05:39:14 +0000 Received: by mail-pf1-x429.google.com with SMTP id q2so12782580pfh.13 for ; Sun, 09 May 2021 22:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9QjThyFdbfEEV7YSdHD2NDT9j0pnbAN4OFRmYnpNSIo=; b=DKMxWczXLRPdyDMhH+2pAoS1NdrO047RvAa8WncZUx2FUyJuMKjct6U1MGuwcKf7cr VauDMDqhf9NmEQWm/wEECCvM0nJ6eWzC4eQW/JCOEbe/5z9wPzf8O4tpoHyNqS77XW3Q SXK2fmtlAJP9gZ1PSj6n9xgvxdJNy3ZQGBPpP9CP9kfFaLvIloQlrCviSCBR303IlpSb KAuQZpfBuBLzPQQ3zhW9s9gN9NzVcC767e8xv4kOG9Ef56xbU6cFnmznaN3GQ2H1IJJv GDDtlOxpsWr8tfspvWLM25f2JO2oi0KTKfnNvTZrRCaPBOKt1m7J4+bZ6sWs/MwkAGPn i6sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9QjThyFdbfEEV7YSdHD2NDT9j0pnbAN4OFRmYnpNSIo=; b=IcD3z++ESKdRoTMgVthplq1VS2E4hJwi8ZRVaTWn7FY9vyGFTPwbIrWKA89g6TeKuW 5wAfXER7fIwAZ6bVCXDDNGq4DR5awuypj5iu+YdbhHWXmtE1WfUPbgJtw+l+7fCo3hoQ OH1zGg54tGODmWjTx37uPgFbZRsIjE6I91A4IoMSkm1JhKHxg9jGPXN/w5tiW5NoINER /FeI9cTKlklkKuvRFR69e43pRGEMPQG1PayDTXoRiOq5SnPvNSFmjOjCf3uYuwprLv8X fwdDok5X8kqlJ5U5kKCJTwCByoT9HSJQdMuAWhrmCH2TSw2KQf0s4/7ehGdaDyJ1fLm/ 2npQ== X-Gm-Message-State: AOAM533A9L4RWeBqw2ZzWnuw3ZVUZN+IJIlYTnNCOOyMnZzn3lMlAPhx 1Y1fIa3Z9/Gg0afO/fOXajP/XQ== X-Google-Smtp-Source: ABdhPJxL55uYLzlLBONLZRKY3c1FonDeJ3FtOdbAxVYVL+2eHBP7EPjqAldCxGZF7Kptg6CqOMgSAA== X-Received: by 2002:a63:175e:: with SMTP id 30mr23397809pgx.48.1620625151365; Sun, 09 May 2021 22:39:11 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([103.207.71.35]) by smtp.gmail.com with ESMTPSA id gw7sm10270030pjb.57.2021.05.09.22.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 May 2021 22:39:10 -0700 (PDT) Date: Mon, 10 May 2021 13:39:04 +0800 From: Leo Yan To: James Clark Cc: coresight@lists.linaro.org, mathieu.poirier@linaro.org, al.grant@arm.com, branislav.rankov@arm.com, denik@chromium.org, suzuki.poulose@arm.com, anshuman.khandual@arm.com, Mike Leach , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] perf cs-etm: Handle valid-but-zero timestamps Message-ID: <20210510053904.GB4835@leoy-ThinkPad-X240s> References: <20210507095814.17933-1-james.clark@arm.com> <3926c523-3fdb-66de-8b9c-b68290a5053e@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3926c523-3fdb-66de-8b9c-b68290a5053e@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210509_223913_571845_9345C32A X-CRM114-Status: GOOD ( 25.81 ) 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 James, On Fri, May 07, 2021 at 01:02:35PM +0300, 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. Just remind, as Mike has mentioned that if the timestamp is zero, it means the hardware setting for timestamp is not enabled properly. So for system wide or per CPU mode tracing, it's better to double check what's the reason the timestamp is not enabled properly. IIUC, this patch breaks the existed rational in the code. Let's think about there have 4 CPUs, every CPU has its own AUX trace buffer, and when decode the trace data, it will use 4 queues to track the packets and every queue has its timestamp. CPU0: cs_etm_queue -> ... -> packet_queue->timestamp CPU1: cs_etm_queue -> ... -> packet_queue->timestamp CPU2: cs_etm_queue -> ... -> packet_queue->timestamp CPU3: cs_etm_queue -> ... -> packet_queue->timestamp The issue is if all CPUs' timestamp are zero, it's impossible to find a way to synthesize samples in the right time order. [...] > > 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; Actually here have two situations: one case is "elem->timestamp" is zero, another case is the overflow for "elem->timestamp". So the change should be like: if (!elem->timestamp) packet_queue->cs_timestamp = 0; else if (packet_queue->instr_count >= elem->timestamp) /* handle overflow? */ else packet_queue->cs_timestamp = elem->timestamp - packet_queue->instr_count; It's better to think about how to handle the overflow in this case. Thanks, Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel