1. 26 Feb, 2024 3 commits
  2. 22 Feb, 2024 21 commits
  3. 21 Feb, 2024 2 commits
    • Feng Tang's avatar
      clocksource: Scale the watchdog read retries automatically · 2ed08e4b
      Feng Tang authored
      On a 8-socket server the TSC is wrongly marked as 'unstable' and disabled
      during boot time on about one out of 120 boot attempts:
      
          clocksource: timekeeping watchdog on CPU227: wd-tsc-wd excessive read-back delay of 153560ns vs. limit of 125000ns,
          wd-wd read-back delay only 11440ns, attempt 3, marking tsc unstable
          tsc: Marking TSC unstable due to clocksource watchdog
          TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
          sched_clock: Marking unstable (119294969739, 159204297)<-(125446229205, -5992055152)
          clocksource: Checking clocksource tsc synchronization from CPU 319 to CPUs 0,99,136,180,210,542,601,896.
          clocksource: Switched to clocksource hpet
      
      The reason is that for platform with a large number of CPUs, there are
      sporadic big or huge read latencies while reading the watchog/clocksource
      during boot or when system is under stress work load, and the frequency and
      maximum value of the latency goes up with the number of online CPUs.
      
      The cCurrent code already has logic to detect and filter such high latency
      case by reading the watchdog twice and checking the two deltas. Due to the
      randomness of the latency, there is a low probabilty that the first delta
      (latency) is big, but the second delta is small and looks valid. The
      watchdog code retries the readouts by default twice, which is not
      necessarily sufficient for systems with a large number of CPUs.
      
      There is a command line parameter 'max_cswd_read_retries' which allows to
      increase the number of retries, but that's not user friendly as it needs to
      be tweaked per system. As the number of required retries is proportional to
      the number of online CPUs, this parameter can be calculated at runtime.
      
      Scale and enlarge the number of retries according to the number of online
      CPUs and remove the command line parameter completely.
      
      [ tglx: Massaged change log and comments ]
      Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarJin Wang <jin1.wang@intel.com>
      Tested-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Reviewed-by: default avatarWaiman Long <longman@redhat.com>
      Reviewed-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Link: https://lore.kernel.org/r/20240221060859.1027450-1-feng.tang@intel.com
      2ed08e4b
    • David Gow's avatar
      time/kunit: Use correct format specifier · e0a1284b
      David Gow authored
      'days' is a s64 (from div_s64), and so should use a %lld specifier.
      
      This was found by extending KUnit's assertion macros to use gcc's
      __printf attribute.
      
      Fixes: 27601055 ("time: Improve performance of time64_to_tm()")
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20240221092728.1281499-5-davidgow@google.com
      e0a1284b
  4. 20 Feb, 2024 10 commits
  5. 19 Feb, 2024 4 commits
    • Ingo Molnar's avatar
      Merge tag 'v6.8-rc5' into timers/core, to resolve conflict · 94bf12af
      Ingo Molnar authored
      There's a conflict between this recent upstream fix:
      
        dad6a09f ("hrtimer: Report offline hrtimer enqueue")
      
      and a pending commit in the timers tree:
      
        1a4729ec ("hrtimers: Move hrtimer base related definitions into hrtimer_defs.h")
      
      Resolve it by applying the upstream fix to the new <linux/hrtimer_defs.h> header.
      
       Conflict:
      	include/linux/hrtimer.h
       Semantic conflict:
      	include/linux/hrtimer_defs.h
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      94bf12af
    • Peter Hilber's avatar
      timekeeping: Fix cross-timestamp interpolation for non-x86 · 14274d0b
      Peter Hilber authored
      So far, get_device_system_crosststamp() unconditionally passes
      system_counterval.cycles to timekeeping_cycles_to_ns(). But when
      interpolating system time (do_interp == true), system_counterval.cycles is
      before tkr_mono.cycle_last, contrary to the timekeeping_cycles_to_ns()
      expectations.
      
      On x86, CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE will mitigate on
      interpolating, setting delta to 0. With delta == 0, xtstamp->sys_monoraw
      and xtstamp->sys_realtime are then set to the last update time, as
      implicitly expected by adjust_historical_crosststamp(). On other
      architectures, the resulting nonsense xtstamp->sys_monoraw and
      xtstamp->sys_realtime corrupt the xtstamp (ts) adjustment in
      adjust_historical_crosststamp().
      
      Fix this by deriving xtstamp->sys_monoraw and xtstamp->sys_realtime from
      the last update time when interpolating, by using the local variable
      "cycles". The local variable already has the right value when
      interpolating, unlike system_counterval.cycles.
      
      Fixes: 2c756feb ("time: Add history to cross timestamp interface supporting slower devices")
      Signed-off-by: default avatarPeter Hilber <peter.hilber@opensynergy.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarJohn Stultz <jstultz@google.com>
      Link: https://lore.kernel.org/r/20231218073849.35294-4-peter.hilber@opensynergy.com
      14274d0b
    • Peter Hilber's avatar
      timekeeping: Fix cross-timestamp interpolation corner case decision · 87a41130
      Peter Hilber authored
      The cycle_between() helper checks if parameter test is in the open interval
      (before, after). Colloquially speaking, this also applies to the counter
      wrap-around special case before > after. get_device_system_crosststamp()
      currently uses cycle_between() at the first call site to decide whether to
      interpolate for older counter readings.
      
      get_device_system_crosststamp() has the following problem with
      cycle_between() testing against an open interval: Assume that, by chance,
      cycles == tk->tkr_mono.cycle_last (in the following, "cycle_last" for
      brevity). Then, cycle_between() at the first call site, with effective
      argument values cycle_between(cycle_last, cycles, now), returns false,
      enabling interpolation. During interpolation,
      get_device_system_crosststamp() will then call cycle_between() at the
      second call site (if a history_begin was supplied). The effective argument
      values are cycle_between(history_begin->cycles, cycles, cycles), since
      system_counterval.cycles == interval_start == cycles, per the assumption.
      Due to the test against the open interval, cycle_between() returns false
      again. This causes get_device_system_crosststamp() to return -EINVAL.
      
      This failure should be avoided, since get_device_system_crosststamp() works
      both when cycles follows cycle_last (no interpolation), and when cycles
      precedes cycle_last (interpolation). For the case cycles == cycle_last,
      interpolation is actually unneeded.
      
      Fix this by changing cycle_between() into timestamp_in_interval(), which
      now checks against the closed interval, rather than the open interval.
      
      This changes the get_device_system_crosststamp() behavior for three corner
      cases:
      
      1. Bypass interpolation in the case cycles == tk->tkr_mono.cycle_last,
         fixing the problem described above.
      
      2. At the first timestamp_in_interval() call site, cycles == now no longer
         causes failure.
      
      3. At the second timestamp_in_interval() call site, history_begin->cycles
         == system_counterval.cycles no longer causes failure.
         adjust_historical_crosststamp() also works for this corner case,
         where partial_history_cycles == total_history_cycles.
      
      These behavioral changes should not cause any problems.
      
      Fixes: 2c756feb ("time: Add history to cross timestamp interface supporting slower devices")
      Signed-off-by: default avatarPeter Hilber <peter.hilber@opensynergy.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20231218073849.35294-3-peter.hilber@opensynergy.com
      87a41130
    • Peter Hilber's avatar
      timekeeping: Fix cross-timestamp interpolation on counter wrap · 84dccadd
      Peter Hilber authored
      cycle_between() decides whether get_device_system_crosststamp() will
      interpolate for older counter readings.
      
      cycle_between() yields wrong results for a counter wrap-around where after
      < before < test, and for the case after < test < before.
      
      Fix the comparison logic.
      
      Fixes: 2c756feb ("time: Add history to cross timestamp interface supporting slower devices")
      Signed-off-by: default avatarPeter Hilber <peter.hilber@opensynergy.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarJohn Stultz <jstultz@google.com>
      Link: https://lore.kernel.org/r/20231218073849.35294-2-peter.hilber@opensynergy.com
      84dccadd