From: Saumil Merchant Subject: Re: perf trace timestamps Date: Tue, 20 Nov 2012 11:33:56 +0000 (UTC) Message-ID: References: <50A6502C.9030900@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from plane.gmane.org ([80.91.229.3]:60833 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033Ab2KTLeN (ORCPT ); Tue, 20 Nov 2012 06:34:13 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Tam5t-0006HM-AL for linux-perf-users@vger.kernel.org; Tue, 20 Nov 2012 12:34:21 +0100 Received: from 122.248.161.59 ([122.248.161.59]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 20 Nov 2012 12:34:21 +0100 Received: from msaumil by 122.248.161.59 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 20 Nov 2012 12:34:21 +0100 Sender: linux-perf-users-owner@vger.kernel.org List-ID: To: linux-perf-users@vger.kernel.org David Ahern gmail.com> writes: > > > > > My original impression was that this timestamp (eg, 1746678.550895) would > > with time reported clk_gettime(MONOTONIC,...) function, but it does not. My > > function above prints out timestamps from clk_gettime(MONOTONIC,..) > > and there is a delta of >15 mins. > > > > Here is the printout on console: > > CLKTIME (MONOTONIC): 1748132.102228068 > > At one time many, many releases ago perf timestamps did align with the > monotonic clock. I have tried (unsuccessfully) to get an option into > perf to correlate perf events with time-of-day stamps. > Since clk_gettime and perf timestamps do not align, I tried synchronizing timestamps at start my code. I used a syscall that I can track in the perf trace. I can then normalize perf trace output timestamps using the delta between perf timestamp and clk_gettime timestamp for the syscall. I chose to use nanosleep for this. While doing this I realized that this normalizing delta between the perf and clk_gettime timestamps linearly increases with time. Here is a simple C code that I used to check this behavior: #include #include #include int ITERATIONS=600; struct timespec sleepy, t1, t2; int main(int argc, char **argv) { int i; sleepy.tv_sec=0; sleepy.tv_nsec=1000000; for(i=0; i > > > This delta has been varying from 5 mins to 15+ mins. My objective is to > > correlate events in a kernel trace with the execution of our user program. > > understanding is that both perf and clk_gettime functions on newer x86 > > use TSC as the clock source and hence I was confused why they do not align. > > > > Can someone please help? > > See John's explanations in this thread: > https://lkml.org/lkml/2012/10/16/173 > > David >