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 5D4A9C433B4 for ; Thu, 15 Apr 2021 19:56: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 B8F0F610CB for ; Thu, 15 Apr 2021 19:56:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8F0F610CB 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=jhraycFfEPQvfVrLuC34WwF1Lccsngv8102iW8iTdt0=; b=E3bK6kgHvyfjarDYtxeSb4hmw nJ/1oErZ8Vh6WFNypCKr38lzsk0vwRv4VDWMrdbLQJStslT6EV8s6Wt9DL/rmdU5FZdAjqxuYIVMM KsOJ7xaSpDlkT8AO9xBHCKa65fW26dvH5PRCOoy5+4FRdS6VF/Jm5E/KKpdlWSYaeE/E+8e4mgunY ip2KoKVRIQsBg2hFwnR4//wdEOjvxm8eIJ1e/MCGKBylZ5rEzrQ8YnJbGylEoDD7oQj1VNK9Gx4IF Mj/KQiMUPifnTTWen0h1/Xk7V3agDNiPoiDohzWUidVZskmaG6upDHQ9S8ucql8LoDXY3x8ttzkn5 73QFctfdA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lX84I-00HBjB-Ig; Thu, 15 Apr 2021 19:54:29 +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 1lX84F-00HBiJ-Dt for linux-arm-kernel@desiato.infradead.org; Thu, 15 Apr 2021 19:54:23 +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=Ij4LykCj/Hdbgw3UoGr4uR4CU6tTNOA2JBdD93B4Vhg=; b=xJKZKcg1Rdmy629+9ApbyjAIzw LQkI9N3ysdzmazDDS4yWtG4weDEP74Z/Ox0eQ2f3A/01udEnax7mGONB7Ed+yal/AYdhlrmP2xjUU bFwCJJis2WwDChvxCad9rUhJP2xwCwSsryt+eVY+jf6Ck8QeaqerMY++8ZopC+KCZ+U3eS8fu1IVe ZTaY74NvzHNWDSFvs/s4AKMr+A1FVE/BAsIJBjoUJBwBk0d3AgPNBU54SBkB319ocjT37k9hsR132 BzbuxcqPPjKEp4SaIrCBXoU09I6xDdEWVSgvP1pp0eNoSaoq3ix4AP7OIponHzhf5hG+9OHDKZQ9C CA2CpwEg==; Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lX84C-008rGi-Mj for linux-arm-kernel@lists.infradead.org; Thu, 15 Apr 2021 19:54:22 +0000 Received: by mail-pg1-x533.google.com with SMTP id y32so17621667pga.11 for ; Thu, 15 Apr 2021 12:54:20 -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=Ij4LykCj/Hdbgw3UoGr4uR4CU6tTNOA2JBdD93B4Vhg=; b=mNNHqFpw6Q5WBUl3HalbanadWH0VG5i3svHssyBSgbYV4s+bf13OcziE4QxwumM/pK Q96+ltcCmAiZuozf5MWOOccAFQlEpYUYvbY35KS2LhkllDwBOcYFXypOy/rl6lzdqD4X srZsxXvVuOBgs9Tk2kkGslZ7syTXvLNc9UmIXiil6HOJxsfnxIThyjrBgQRuvqvXjdl/ hTlwyBfA2JWEAyyXECAhurQvP5hoayZYnyh61t+yIxc+54W3KL7yJle9CogIaQM+ReQE Ak3tkghuot/qxiVdKZSf2zP9MLMYrzJ8fY4fMbwObJK0zRqHgcSJBZGbQ7ZKYLYw+SQ5 khHw== 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=Ij4LykCj/Hdbgw3UoGr4uR4CU6tTNOA2JBdD93B4Vhg=; b=pbYLfuhuvw2xUEitScrNz3b49K3YkppzyXYqCQgbjbUceuQDvW/gUTTrCuCcwg+3SY 05XQiekYaxnyXBLHHZ6cufrjO8/xwu6rFfYBT+F+tWqsKvY2i+liFaSj7qwaxNgu+ovv AKLIrJ/PsOYZ066ojO5ige94DeBdywB7/DtZL6nn9SyClMImgPOQsP4MZvebYbI8/GQV eWFpdUYyB9vPSzTvEJou5icXtV/KvsaclUwV7wE2kzjLVDVBVpxUqHyMTu29RolAOuyI D43DoZTqrch1qBK09Q4hFxOHIEQfoQVA2MOTn8hE4lJgmBMQaWd1/PNj2+Jp4JiydDZn aUsw== X-Gm-Message-State: AOAM533S48/FQxHPhZl/RFHo8xUQ1PgxyH/oq3j/M0bfn+appDOeb0h7 wn67vZUp9lDuvVkl1H1v9O8faQ== X-Google-Smtp-Source: ABdhPJzViyaV5qxofFa2dUKQ4VsMWPme8ePOriFDTuMDh8Ji/pPihe30gP3m8Kj2emLOVPwxrZv/7A== X-Received: by 2002:a62:4e96:0:b029:248:effc:9a4d with SMTP id c144-20020a624e960000b0290248effc9a4dmr4659860pfb.71.1618516459693; Thu, 15 Apr 2021 12:54:19 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id d6sm2778016pfn.197.2021.04.15.12.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 12:54:18 -0700 (PDT) Date: Thu, 15 Apr 2021 13:54:16 -0600 From: Mathieu Poirier 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 , Leo Yan , 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: [PATCH 2/2] perf cs-etm: Set time on synthesised samples to preserve ordering Message-ID: <20210415195416.GB937505@xps15> 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_125420_770636_39747A09 X-CRM114-Status: GOOD ( 29.59 ) 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 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. > I understand the problem. Once again an issue caused by CS and the kernel having a different view of time. > 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 Suzuki is correct, your name has to appear after Al's. > --- > 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; It will be fun to fix this when 8.4 comes out but for now it's the best we've got. Reviewed-by: Mathieu Poirier > return cs_etm__process_queues(etm); > + } > > 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