Merge tag 'timers-urgent-2020-08-14' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Aug 2020 21:26:08 +0000 (14:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Aug 2020 21:26:08 +0000 (14:26 -0700)
Pull timekeeping updates from Thomas Gleixner:
 "A set of timekeeping/VDSO updates:

   - Preparatory work to allow S390 to switch over to the generic VDSO
     implementation.

     S390 requires that the VDSO data pointer is handed in to the
     counter read function when time namespace support is enabled.
     Adding the pointer is a NOOP for all other architectures because
     the compiler is supposed to optimize that out when it is unused in
     the architecture specific inline. The change also solved a similar
     problem for MIPS which fortunately has time namespaces not yet
     enabled.

     S390 needs to update clock related VDSO data independent of the
     timekeeping updates. This was solved so far with yet another
     sequence counter in the S390 implementation. A better solution is
     to utilize the already existing VDSO sequence count for this. The
     core code now exposes helper functions which allow to serialize
     against the timekeeper code and against concurrent readers.

     S390 needs extra data for their clock readout function. The initial
     common VDSO data structure did not provide a way to add that. It
     now has an embedded architecture specific struct embedded which
     defaults to an empty struct.

     Doing this now avoids tree dependencies and conflicts post rc1 and
     allows all other architectures which work on generic VDSO support
     to work from a common upstream base.

   - A trivial comment fix"

* tag 'timers-urgent-2020-08-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  time: Delete repeated words in comments
  lib/vdso: Allow to add architecture-specific vdso data
  timekeeping/vsyscall: Provide vdso_update_begin/end()
  vdso/treewide: Add vdso_data pointer argument to __arch_get_hw_counter()

1  2 
arch/Kconfig
kernel/time/timekeeping.c

diff --combined arch/Kconfig
@@@ -481,6 -481,9 +481,6 @@@ config HAVE_STACKPROTECTO
          An arch should select this symbol if:
          - it has implemented a stack canary (e.g. __stack_chk_guard)
  
 -config CC_HAS_STACKPROTECTOR_NONE
 -      def_bool $(cc-option,-fno-stack-protector)
 -
  config STACKPROTECTOR
        bool "Stack Protector buffer overflow detection"
        depends on HAVE_STACKPROTECTOR
@@@ -972,6 -975,9 +972,9 @@@ config HAVE_SPARSE_SYSCALL_N
          entries at 4000, 5000 and 6000 locations. This option turns on syscall
          related optimizations for a given architecture.
  
+ config ARCH_HAS_VDSO_DATA
+       bool
  source "kernel/gcov/Kconfig"
  
  source "scripts/gcc-plugins/Kconfig"
@@@ -39,19 -39,18 +39,19 @@@ enum timekeeping_adv_mode 
        TK_ADV_FREQ
  };
  
- static DEFINE_RAW_SPINLOCK(timekeeper_lock);
++DEFINE_RAW_SPINLOCK(timekeeper_lock);
 +
  /*
   * The most important data for readout fits into a single 64 byte
   * cache line.
   */
  static struct {
 -      seqcount_t              seq;
 +      seqcount_raw_spinlock_t seq;
        struct timekeeper       timekeeper;
  } tk_core ____cacheline_aligned = {
 -      .seq = SEQCNT_ZERO(tk_core.seq),
 +      .seq = SEQCNT_RAW_SPINLOCK_ZERO(tk_core.seq, &timekeeper_lock),
  };
  
 -DEFINE_RAW_SPINLOCK(timekeeper_lock);
  static struct timekeeper shadow_timekeeper;
  
  /**
@@@ -64,7 -63,7 +64,7 @@@
   * See @update_fast_timekeeper() below.
   */
  struct tk_fast {
 -      seqcount_t              seq;
 +      seqcount_raw_spinlock_t seq;
        struct tk_read_base     base[2];
  };
  
@@@ -81,13 -80,11 +81,13 @@@ static struct clocksource dummy_clock 
  };
  
  static struct tk_fast tk_fast_mono ____cacheline_aligned = {
 +      .seq     = SEQCNT_RAW_SPINLOCK_ZERO(tk_fast_mono.seq, &timekeeper_lock),
        .base[0] = { .clock = &dummy_clock, },
        .base[1] = { .clock = &dummy_clock, },
  };
  
  static struct tk_fast tk_fast_raw  ____cacheline_aligned = {
 +      .seq     = SEQCNT_RAW_SPINLOCK_ZERO(tk_fast_raw.seq, &timekeeper_lock),
        .base[0] = { .clock = &dummy_clock, },
        .base[1] = { .clock = &dummy_clock, },
  };
@@@ -160,7 -157,7 +160,7 @@@ static inline void tk_update_sleep_time
   * tk_clock_read - atomic clocksource read() helper
   *
   * This helper is necessary to use in the read paths because, while the
 - * seqlock ensures we don't return a bad value while structures are updated,
 + * seqcount ensures we don't return a bad value while structures are updated,
   * it doesn't protect from potential crashes. There is the possibility that
   * the tkr's clocksource may change between the read reference, and the
   * clock reference passed to the read function.  This can cause crashes if
@@@ -225,10 -222,10 +225,10 @@@ static inline u64 timekeeping_get_delta
        unsigned int seq;
  
        /*
 -       * Since we're called holding a seqlock, the data may shift
 +       * Since we're called holding a seqcount, the data may shift
         * under us while we're doing the calculation. This can cause
         * false positives, since we'd note a problem but throw the
 -       * results away. So nest another seqlock here to atomically
 +       * results away. So nest another seqcount here to atomically
         * grab the points we are checking with.
         */
        do {
@@@ -489,7 -486,7 +489,7 @@@ EXPORT_SYMBOL_GPL(ktime_get_raw_fast_ns
   *
   * To keep it NMI safe since we're accessing from tracing, we're not using a
   * separate timekeeper with updates to monotonic clock and boot offset
 - * protected with seqlocks. This has the following minor side effects:
 + * protected with seqcounts. This has the following minor side effects:
   *
   * (1) Its possible that a timestamp be taken after the boot offset is updated
   * but before the timekeeper is updated. If this happens, the new boot offset
@@@ -2004,7 -2001,7 +2004,7 @@@ static inline unsigned int accumulate_n
   * logarithmic_accumulation - shifted accumulation of cycles
   *
   * This functions accumulates a shifted interval of cycles into
-  * into a shifted interval nanoseconds. Allows for O(log) accumulation
+  * a shifted interval nanoseconds. Allows for O(log) accumulation
   * loop.
   *
   * Returns the unconsumed cycles.