[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b5ceb5b1-ba55-f84c-d332-a4414c22dc9a@redhat.com>
Date: Wed, 18 Jan 2017 16:45:07 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Marcelo Tosatti <mtosatti@...hat.com>
Cc: Miroslav Lichvar <mlichvar@...hat.com>,
Radim Krcmar <rkrcmar@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Richard Cochran <richardcochran@...il.com>
Subject: Re: [patch 3/3] PTP: add kvm PTP driver
On 18/01/2017 15:50, Marcelo Tosatti wrote:
>> Interesting idea! For this to work, KVM needs to implement
>> getcrosstimestamp and ptp_chardev.c can then add an alternative
>> implementation of PTP_SYS_OFFSET, based on precise cross timestamps.
>>
>> Something like
>>
>> for (i = 0; i <= sysoff->n_samples; i++) {
>> // ... call getcrosststamp ...
>> sysns = ktime_to_ns(xtstamp.sys_realtime);
>> if (i > 0) {
>> devns = ktime_to_ns(xtstamp.device);
>> devns -= (sysns - prev_sysns) / 2;
>> devts = ns_to_timespec(devns);
>> pct->sec = devts.tv_sec;
>> pct->nsec = devts.tv_nsec;
>> pct++;
>> }
>> systs = ns_to_timespec(sysns);
>> pct->sec = ts.tv_sec;
>> pct->nsec = ts.tv_nsec;
>> pct++;
>> prev_sysns = sysns;
>> }
>>
>> Marcelo, can you give it a try?
>
> Can convert fine, but problem is the simultaneous read
> of host and guest clocks.
Could the TSC from the hypercall be applied to kvmclock to do this? My
understanding is that get_device_system_crosststamp (which is used in
the sole in-tree implementation of getcrosststamp) already contains all
the logic to do that.
Paolo
Powered by blists - more mailing lists