1. 09 3月, 2008 1 次提交
  2. 09 2月, 2008 2 次提交
  3. 02 2月, 2008 1 次提交
  4. 30 1月, 2008 2 次提交
    • J
      NTP: correct inconsistent ntp interval/tick_length usage · bbe4d18a
      john stultz 提交于
      I recently noticed on one of my boxes that when synched with an NTP
      server, the drift value reported for the system was ~283ppm. While in
      some cases, clock hardware can be that bad, it struck me as unusual as
      the system was using the acpi_pm clocksource, which is one of the more
      trustworthy and accurate clocksources on x86 hardware.
      
      I brought up another system and let it sync to the same NTP server, and
      I noticed a similar 280some ppm drift.
      
      In looking at the code, I found that the acpi_pm's constant frequency
      was being computed correctly at boot-up, however once the system was up,
      even without the ntp daemon running, the clocksource's frequency was
      being modified by the clocksource_adjust() function.
      
      Digging deeper, I realized that in the code that keeps track of how much
      the clocksource is skewing from the ntp desired time, we were using
      different lengths to establish how long an time interval was.
      
      The clocksource was being setup with the following interval:
      	NTP_INTERVAL_LENGTH = NSEC_PER_SEC/NTP_INTERVAL_FREQ
      
      While the ntp code was using the tick_length_base value:
      	tick_length_base ~= (tick_usec * NSEC_PER_USEC * USER_HZ)
      					/NTP_INTERVAL_FREQ
      
      The subtle difference is:
      	(tick_usec * NSEC_PER_USEC * USER_HZ) != NSEC_PER_SEC
      
      This difference in calculation was causing the clocksource correction
      code to apply a correction factor to the clocksource so the two
      intervals were the same, however this results in the actual frequency of
      the clocksource to be made incorrect. I believe this difference would
      affect all clocksources, although to differing degrees depending on the
      clocksource resolution.
      
      The issue was introduced when my HZ free ntp patch landed in 2.6.21-rc1,
      so my apologies for the mistake, and for not noticing it until now.
      
      The following patch, corrects the clocksource's initialization code so
      it uses the same interval length as the code in ntp.c. After applying
      this patch, the drift value for the same system went from ~283ppm to
      only 2.635ppm.
      
      I believe this patch to be good, however it does affect all arches and
      I've only tested on x86, so some caution is advised. I do think it would
      be a likely candidate for a stable 2.6.24.x release.
      
      Any thoughts or feedback would be appreciated.
      Signed-off-by: NJohn Stultz <johnstul@us.ibm.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      bbe4d18a
    • G
      time: fold __get_realtime_clock_ts() into getnstimeofday() · efd9ac86
      Geert Uytterhoeven 提交于
        - getnstimeofday() was just a wrapper around __get_realtime_clock_ts()
        - Replace calls to __get_realtime_clock_ts() by calls to getnstimeofday()
        - Fix bogus reference to get_realtime_clock_ts(), which never existed
      Signed-off-by: NGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
      Cc: john stultz <johnstul@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      efd9ac86
  5. 25 1月, 2008 1 次提交
  6. 17 10月, 2007 2 次提交
    • A
      kernel/time/timekeeping.c: cleanups · ba2a631b
      Adrian Bunk 提交于
      - remove the no longer required __attribute__((weak)) of xtime_lock
      - remove the following no longer used EXPORT_SYMBOL's:
        - xtime
        - xtime_lock
      Signed-off-by: NAdrian Bunk <bunk@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: john stultz <johnstul@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ba2a631b
    • I
      time: introduce xtime_seconds · f20bf612
      Ingo Molnar 提交于
      improve performance of sys_time(). sys_time() returns time in seconds,
      but it does so by calling do_gettimeofday() and then returning the
      tv_sec portion of the GTOD time. But the data structure "xtime", which
      is updated by every timer/scheduler tick, already offers HZ granularity
      time.
      
      the patch improves the sysbench oltp macrobenchmark by 4-5% on an AMD
      dual-core system:
      
      v2.6.23:
      
      #threads
      
         1:     transactions:                        4073   (407.23 per sec.)
         2:     transactions:                        8530   (852.81 per sec.)
         3:     transactions:                        8321   (831.88 per sec.)
         4:     transactions:                        8407   (840.58 per sec.)
         5:     transactions:                        8070   (806.74 per sec.)
      
      v2.6.23 + sys_time-speedup.patch:
      
         1:     transactions:                        4281   (428.09 per sec.)
         2:     transactions:                        8910   (890.85 per sec.)
         3:     transactions:                        8659   (865.79 per sec.)
         4:     transactions:                        8676   (867.34 per sec.)
         5:     transactions:                        8532   (852.91 per sec.)
      
      and by 4-5% on an Intel dual-core system too:
      
      2.6.23:
      
        1:     transactions:                        4560   (455.94 per sec.)
        2:     transactions:                        10094  (1009.30 per sec.)
        3:     transactions:                        9755   (975.36 per sec.)
        4:     transactions:                        9859   (985.78 per sec.)
        5:     transactions:                        9701   (969.72 per sec.)
      
      2.6.23 + sys_time-speedup.patch:
      
        1:     transactions:                        4779   (477.84 per sec.)
        2:     transactions:                        10103  (1010.14 per sec.)
        3:     transactions:                        10141  (1013.93 per sec.)
        4:     transactions:                        10371  (1036.89 per sec.)
        5:     transactions:                        10178  (1017.50 per sec.)
      
      (the more CPUs the system has, the more speedup this patch gives for
      this particular workload.)
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f20bf612
  7. 16 9月, 2007 2 次提交
    • T
      timekeeping: Prevent time going backwards on resume · 6a669ee8
      Thomas Gleixner 提交于
      Timekeeping resume adjusts xtime by adding the slept time in seconds and
      resets the reference value of the clock source (clock->cycle_last).
      clock->cycle last is used to calculate the delta between the last xtime
      update and the readout of the clock source in __get_nsec_offset(). xtime
      plus the offset is the current time. The resume code ignores the delta
      which had already elapsed between the last xtime update and the actual
      time of suspend. If the suspend time is short, then we can see time
      going backwards on resume.
      
      Suspend:
      offs_s = clock->read() - clock->cycle_last;
      now = xtime + offs_s;
      timekeeping_suspend_time = read_rtc();
      
      Resume:
      sleep_time = read_rtc() - timekeeping_suspend_time;
      xtime.tv_sec += sleep_time;
      clock->cycle_last = clock->read();
      offs_r = clock->read() - clock->cycle_last;
      now = xtime + offs_r;
      
      if sleep_time_seconds == 0 and offs_r < offs_s, then time goes
      backwards.
      
      Fix this by storing the offset from the last xtime update and add it to
      xtime during resume, when we reset clock->cycle_last:
      
      sleep_time = read_rtc() - timekeeping_suspend_time;
      xtime.tv_sec += sleep_time;
      xtime += offs_s;	/* Fixup xtime offset at suspend time */
      clock->cycle_last = clock->read();
      offs_r = clock->read() - clock->cycle_last;
      now = xtime + offs_r;
      
      Thanks to Marcelo for tracking this down on the OLPC and providing the
      necessary details to analyze the root cause.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: John Stultz <johnstul@us.ibm.com>
      Cc: Tosatti <marcelo@kvack.org>
      6a669ee8
    • T
      timekeeping: access rtc outside of xtime lock · 3be90950
      Thomas Gleixner 提交于
      Lockdep complains about the access of rtc in timekeeping_suspend
      inside the interrupt disabled region of the write locked xtime lock.
      Move the access outside.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: John Stultz <johnstul@us.ibm.com>
      3be90950
  8. 26 7月, 2007 2 次提交
    • J
      Cache xtime every call to update_wall_time · 17c38b74
      john stultz 提交于
      This avoids xtime lag seen with dynticks, because while 'xtime' itself
      is still not updated often, we keep a 'xtime_cache' variable around that
      contains the approximate real-time that _is_ updated each time we do a
      'update_wall_time()', and is thus never off by more than one tick.
      
      IOW, this restores the original semantics for 'xtime' users, as long as
      you use the proper abstraction functions (ie 'current_kernel_time()' or
      'get_seconds()' depending on whether you want a timespec or just the
      seconds field).
      
      [ Updated Patch.  As penance for my sins I've also yanked another #ifdef
        that was added to avoid the xtime lag w/ hrtimers.  ]
      Signed-off-by: NJohn Stultz <johnstul@us.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      17c38b74
    • J
      Cleanup non-arch xtime uses, use get_seconds() or current_kernel_time(). · 2c6b47de
      john stultz 提交于
      This avoids use of the kernel-internal "xtime" variable directly outside
      of the actual time-related functions.  Instead, use the helper functions
      that we already have available to us.
      
      This doesn't actually change any behaviour, but this will allow us to
      fix the fact that "xtime" isn't updated very often with CONFIG_NO_HZ
      (because much of the realtime information is maintained as separate
      offsets to 'xtime'), which has caused interfaces that use xtime directly
      to get a time that is out of sync with the real-time clock by up to a
      third of a second or so.
      Signed-off-by: NJohn Stultz <johnstul@us.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2c6b47de
  9. 21 7月, 2007 1 次提交
  10. 20 7月, 2007 1 次提交
  11. 17 7月, 2007 1 次提交
    • T
      Introduce boot based time · 7c3f1a57
      Tomas Janousek 提交于
      The commits
      
        411187fb (GTOD: persistent clock support)
        c1d370e1 (i386: use GTOD persistent clock
          support)
      
      changed the monotonic time so that it no longer jumps after resume, but it's
      not possible to use it for boot time and process start time calculations then.
       Also, the uptime no longer increases during suspend.
      
      I add a variable to track the wall_to_monotonic changes, a function to get the
      real boot time and a function to get the boot based time from the monotonic
      one.
      
      [akpm@linux-foundation.org: remove exports, add comment]
      Signed-off-by: NTomas Janousek <tjanouse@redhat.com>
      Cc: Tomas Smetana <tsmetana@redhat.com>
      Cc: John Stultz <johnstul@us.ibm.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7c3f1a57
  12. 15 5月, 2007 1 次提交
  13. 09 5月, 2007 1 次提交