Re: [Linuxptp-devel] [PATCH RFC] Add new servo for NTP SHM reference clock.

2014-06-12 Thread Richard Cochran
On Wed, Jun 11, 2014 at 06:07:08PM +0200, Miroslav Lichvar wrote:
 
 This is mainly useful when other time sources are available on the
 system (e.g. NTP, hardware reference clocks, or other PTP domains)
 and a fallback to/from PTP is needed.

So, this would let ntpd mix PTP and NTP sources together?

What about adjusting the PHC?

Rebase? I get:
   Applying: Add new servo for NTP SHM reference clock.
   error: patch failed: phc2sys.c:43
   error: phc2sys.c: patch does not apply

 +static double ntpshm_sample(struct servo *servo,
 + int64_t offset,
 + uint64_t local_ts,
 + enum servo_state *state)
 +{
 + struct ntpshm_servo *s = container_of(servo, struct ntpshm_servo, 
 servo);
 + uint64_t clock_ts = local_ts - offset;
 +
 + s-shm-mode = 1;
 + s-shm-count++;
 + s-shm-valid = 0;
 + /* TODO: write memory barrier */

How can this be done in user space?

Thanks,
Richard

--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing  Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH RFC] Add new servo for NTP SHM reference clock.

2014-06-12 Thread Miroslav Lichvar
On Thu, Jun 12, 2014 at 11:44:42AM +0200, Richard Cochran wrote:
 On Wed, Jun 11, 2014 at 06:07:08PM +0200, Miroslav Lichvar wrote:
  
  This is mainly useful when other time sources are available on the
  system (e.g. NTP, hardware reference clocks, or other PTP domains)
  and a fallback to/from PTP is needed.
 
 So, this would let ntpd mix PTP and NTP sources together?

Yes, ntpd (or preferably chronyd to get better accuracy) can compare
the sources, find falsetickers, select the one with best statistics or
combine a number of them together, and use that to synchronize the
clock.

 What about adjusting the PHC?

It's intended to be used with the system clock, ptp4l with software
time stamping or phc2sys. With PHC it should be possible too, but I'm
not aware of any program that can read SHM and synchronize PHC.

 Rebase? I get:
Applying: Add new servo for NTP SHM reference clock.
error: patch failed: phc2sys.c:43
error: phc2sys.c: patch does not apply

I was working on branch with the patches from Jiri adding automatic
phc2sys configuration.

  +   s-shm-mode = 1;
  +   s-shm-count++;
  +   s-shm-valid = 0;
  +   /* TODO: write memory barrier */
 
 How can this be done in user space?

In gpsd they use these gcc builtins:

#if (__GNUC__  4) || (__GNUC__ == 4  __GNUC_MINOR__ = 7)
__atomic_thread_fence(__ATOMIC_SEQ_CST);
#elif (__GNUC__ == 4  __GNUC_MINOR__ = 4)
__sync_synchronize();
#endif

I'm not sure if there is something better. Any suggestions?

I think it will work well even if no barriers are used here. On the
rare event that a sample is read as a mix of the old and new sample,
it will have a large offset and the filters implemented in
ntpd/chronyd should discard it.

-- 
Miroslav Lichvar

--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing  Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel