[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8dc13cf0-42f4-9ef1-1e22-de58ff743a0d@linux.intel.com>
Date: Tue, 14 Feb 2023 12:46:06 -0500
From: "Liang, Kan" <kan.liang@...ux.intel.com>
To: Peter Zijlstra <peterz@...radead.org>,
John Stultz <jstultz@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, mingo@...hat.com,
linux-kernel@...r.kernel.org, sboyd@...nel.org, eranian@...gle.com,
namhyung@...nel.org, ak@...ux.intel.com, adrian.hunter@...el.com
Subject: Re: [RFC PATCH V2 2/9] perf: Extend ABI to support post-processing
monotonic raw conversion
On 2023-02-14 5:43 a.m., Peter Zijlstra wrote:
> On Mon, Feb 13, 2023 at 02:22:39PM -0800, John Stultz wrote:
>> The interpoloation is pretty easy to do:
>>
>> do {
>> start= readtsc();
>> clock_gett(CLOCK_MONOTONIC_RAW, &ts);
>> end = readtsc();
>> delta = end-start;
>> } while (delta > THRESHOLD) // make sure the reads were not preempted
>> mid = start + (delta +(delta/2))/2; //round-closest
>>
>> and be able to get you a fairly close matching of TSC to
>> CLOCK_MONOTONIC_RAW value.
>>
>> Once you have that mapping you can take a few samples and establish
>> the linear function.
>
> Right, this is how we do the TSC calibration in the first place, and if
> NTP can achieve high correctness over a network, then surely we can do
> better locally.
>
> That is, this scheme should work for all CLOCKs, not only MONOTONIC_RAW.
If I understand correctly, the TSC calibration is done in the kernel.
The kernel keeps updating the mul/shift. We dump the mul/shift into the
perf mmap page for the user tools.
But for the CLOCKs, the mul/shift is kernel internal values which we
don't want to expose to the user space.
If we only apply the scheme in the user space, it brings some observable
errors based on my test mentioned in the other thread.
Thanks,
Kan
Powered by blists - more mailing lists