git: kernel - Fix realtime inconsistency

Matthew Dillon dillon at crater.dragonflybsd.org
Mon Jul 18 18:26:18 PDT 2016


commit 2ed5872335d21bb1404f3502436e5461264444ee
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Mon Jul 18 18:15:11 2016 -0700

    kernel - Fix realtime inconsistency
    
    * The original hardclock() code assumed that an IPI (which can't get lost)
      would distribute the tick across all cpus, but that no longer happens.
    
      Code that incremented gd->gd_time_second and maintained the compensation
      base gd->gd_cpuclock_base for relative calculations via cpu_systimer()
      could slowly lose seconds.  Once enough seconds accumulated,
      gd_cpuclock_base would overflow and one or more cpu's would wind up with
      a wildly incorrect (~40 seconds off) real time.
    
    * Fix this by having CPU N just copy the compensation base from CPU 0.  That
      is, the base might be up to one tick off, but that is well within the
      overflow range (which is ~40 seconds) and the time code will deal with it
      properly.  We use the same FIFO trick that we use for basetime[] to avoid
      catching CPU 0 in the act of updating the timebase.
    
    * Add missing lfence()s.  These are required because if we catch the
      basetime_index just after it changed, a pre-fetch of older array
      content will be very wrong.

Summary of changes:
 sys/kern/kern_clock.c | 72 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 17 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/2ed5872335d21bb1404f3502436e5461264444ee


-- 
DragonFly BSD source repository



More information about the Commits mailing list