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=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 332E8C433B4 for ; Thu, 15 Apr 2021 12:32:19 +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 879CA610EA for ; Thu, 15 Apr 2021 12:32:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 879CA610EA 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=H6BN73PMsePLHtFmZkwmqAfS9qSHi3bS0VfgXZGjfp4=; b=YosVSfSrgMuyg7Fk3NrbRS456 trtT2c3b34d1GBt6ybfcAV1fclUK7IxVp90c4ZC9l9pja2RLN/LNFknXJF4VPu5JupkbaG00jXDSZ 1kIDgismUeB/A1mpsjv5SFqg7o/eYrsfCjUcB3Bf5vtga7cDEWG9/Y2uUcfwPkewCn5WhJzJlWQ/i EmMKfNzwaeBVlQO7VMD7uaiTVRdqGv11RDARoPLsnIdm3TCbYsqnDYh29SRqRE4jcA84BX/M7PYo8 taBAVCM8rKKIDqJ9g0G13A5+wYSW7SbZ2Ajg+8kDDr8hTcpYTLvlCB+gy95vtZZSRE/Ay25KcszFW 2HxkI7dLA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lX18o-00G7Kq-Ds; Thu, 15 Apr 2021 12:30:38 +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 1lX18k-00G7Ka-GN for linux-arm-kernel@desiato.infradead.org; Thu, 15 Apr 2021 12:30:35 +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=5XyW6c0nj1LTK1cGyNlupGJV32J66cs3TPcbFBh3pgM=; b=Q4/3KhcxDrICCfvPO6lC4Yor/R zUJlGaH5YcGXTYFxOeKawzHyRQT4WhBpeNlCBZV1upQm9OstEc9js5mkEaHEtaq60ZNcMizkGO9sK 7VpD9oU6UqQDzxvnIcb6xkobZ7j90zK7G5U9w0iWX6jvMQYBiWqCi5Gyp6+KwXIqttQnpelpGuk6j oweHihmsGugDHfi3BTAAGYeHtPJioPt6CydoU/aX/9zrrHImt61jzGVaHrwC3HucRerQf6wG27s4y 2//n+OcpbmVTobgYdYhscjBD9YC2jBCrtdjN0cU5flkqp71hMcUKVeYG10LjYxrhX/mFebpf59bO8 ROPVKujQ==; Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lX18h-008ZEA-OV for linux-arm-kernel@lists.infradead.org; Thu, 15 Apr 2021 12:30:33 +0000 Received: by mail-pj1-x1032.google.com with SMTP id z22-20020a17090a0156b029014d4056663fso12626638pje.0 for ; Thu, 15 Apr 2021 05:30:31 -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=5XyW6c0nj1LTK1cGyNlupGJV32J66cs3TPcbFBh3pgM=; b=qEvSZSXY5kP38+23FroIqLisVVrnScuxWSOmSyq7j7sTGDDOhlp/jBadqv5DChvcfT XiW4w0Dzt3Hmsh1BPaRfSYo0jzG3z5Y4aOJtETxd0qr8jJoHNBpJWemRBmGjyW33SOj+ xBEDhmSrF2YsxIF6hnQqOgvBUJgOhQ0SppiJRqe+jTOoaqTb3wsvAhJ8d0BML5tZY1o0 wiP7M1nZ5pcTSjpenJGb7cSzHbbXQc7s3QGPeucunqNWfsBdO+9eQTFnkB81kXAD6e48 j6bf0q663NSB9tPF+hbefkFx1ogx74lVaJ9kITaxfq4mJODoTpLuDorsJBbUubE5xRkD jG2g== 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=5XyW6c0nj1LTK1cGyNlupGJV32J66cs3TPcbFBh3pgM=; b=g8q7pmPLEPecYqusjouTiy0x9SJQQ7bFUWcMaTe22KjXl7LC3cER3wusZtniwdjYjQ hR00V/SjXB71RzuTQvCRLJHbGFW4v1fdVKRPKiu0jqZnW2r5i7Mu97tHwwOLhrR9bY2s EWDtnnnWhy55ojPYy0aHFJUg7jUhqtTMEG8CyhF0bKbWEEmls3jipWyI9ZsPzcI4SaB9 zJPuJVO0Y7qL3Kx4UZenB8onA3IBMwxMpVu/RYp7h8YJ8RfRG6ooSft2h6Glibn6Vt73 hrZZhzW+1kCP8UleMt357kivH+kuqKYoHguviE6myghth8A6CHccrJJdd0/fgEaRmEuI tDQQ== X-Gm-Message-State: AOAM530BxtOvb7eeoMpfSOBE5ZKz9WzPI3DIj/RKsmh3wIYa1R0ETGHm pVVA8NbJdS89J2v5elKvYCKUqw== X-Google-Smtp-Source: ABdhPJwTihxl8OfzQjZbqtclr0zxCRFFYbodeyffLoetQtLiglgg+QCNKkQlydCohq73v5b1Jvgszg== X-Received: by 2002:a17:90a:4e0b:: with SMTP id n11mr3707422pjh.108.1618489830531; Thu, 15 Apr 2021 05:30:30 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([116.206.101.232]) by smtp.gmail.com with ESMTPSA id s21sm2385931pjr.52.2021.04.15.05.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 05:30:29 -0700 (PDT) Date: Thu, 15 Apr 2021 20:30:23 +0800 From: Leo Yan To: James Clark Cc: coresight@lists.linaro.org, al.grant@arm.com, branislav.rankov@arm.com, denik@chromium.org, suzuki.poulose@arm.com, Mike Leach , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , Mathieu Poirier , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] perf cs-etm: Set time on synthesised samples to preserve ordering Message-ID: <20210415123023.GA1011890@leoy-ThinkPad-X240s> References: <20210414143919.12605-1-james.clark@arm.com> <20210414143919.12605-2-james.clark@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210414143919.12605-2-james.clark@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210415_053031_857619_0DBBE230 X-CRM114-Status: GOOD ( 29.86 ) 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 Wed, Apr 14, 2021 at 05:39:19PM +0300, James Clark wrote: > The following attribute is set when synthesising samples in > timed decoding mode: > > attr.sample_type |= PERF_SAMPLE_TIME; > > This results in new samples that appear to have timestamps but > because we don't assign any timestamps to the samples, when the > resulting inject file is opened again, the synthesised samples > will be on the wrong side of the MMAP or COMM events. > > For example this results in the samples being associated with > the perf binary, rather than the target of the record: > > perf record -e cs_etm/@tmc_etr0/u top > perf inject -i perf.data -o perf.inject --itrace=i100il > perf report -i perf.inject > > Where 'Command' == perf should show as 'top': > > # Overhead Command Source Shared Object Source Symbol Target Symbol Basic Block Cycles > # ........ ....... .................... ...................... ...................... .................. > # > 31.08% perf [unknown] [.] 0x000000000040c3f8 [.] 0x000000000040c3e8 - > > If the perf.data file is opened directly with perf, without the > inject step, then this already works correctly because the > events are synthesised after the COMM and MMAP events and > no second sorting happens. Re-sorting only happens when opening > the perf.inject file for the second time so timestamps are > needed. > > Using the timestamp from the AUX record mirrors the current > behaviour when opening directly with perf, because the events > are generated on the call to cs_etm__process_queues(). > > Signed-off-by: James Clark > Co-developed-by: Al Grant > Signed-off-by: Al Grant > --- > tools/perf/util/cs-etm.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index c25da2ffa8f3..d0fa9dce47f1 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -54,6 +54,7 @@ struct cs_etm_auxtrace { > u8 sample_instructions; > > int num_cpu; > + u64 latest_kernel_timestamp; > u32 auxtrace_type; > u64 branches_sample_type; > u64 branches_id; > @@ -1192,6 +1193,8 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, > event->sample.header.misc = cs_etm__cpu_mode(etmq, addr); > event->sample.header.size = sizeof(struct perf_event_header); > > + if (!etm->timeless_decoding) > + sample.time = etm->latest_kernel_timestamp; > sample.ip = addr; > sample.pid = tidq->pid; > sample.tid = tidq->tid; > @@ -1248,6 +1251,8 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq, > event->sample.header.misc = cs_etm__cpu_mode(etmq, ip); > event->sample.header.size = sizeof(struct perf_event_header); > > + if (!etm->timeless_decoding) > + sample.time = etm->latest_kernel_timestamp; > sample.ip = ip; > sample.pid = tidq->pid; > sample.tid = tidq->tid; > @@ -2412,9 +2417,10 @@ static int cs_etm__process_event(struct perf_session *session, > else if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE) > return cs_etm__process_switch_cpu_wide(etm, event); > > - if (!etm->timeless_decoding && > - event->header.type == PERF_RECORD_AUX) > + if (!etm->timeless_decoding && event->header.type == PERF_RECORD_AUX) { > + etm->latest_kernel_timestamp = sample_kernel_timestamp; > return cs_etm__process_queues(etm); > + } The change looks good to me, I went through these two patches for at least twice, and didn't find issue. And given the trace data might be overflow and overwritten, it's reasonable for me to use the PERF_RECORD_AUX timestamp from the tail of trace data. Reviewed-by: Leo Yan > return 0; > } > -- > 2.28.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel