1. 22 Mar, 2020 1 commit
    • Paul E. McKenney's avatar
      Merge branches 'doc.2020.02.27a', 'fixes.2020.03.21a',... · aa93ec62
      Paul E. McKenney authored
      Merge branches 'doc.2020.02.27a', 'fixes.2020.03.21a', 'kfree_rcu.2020.02.20a', 'locktorture.2020.02.20a', 'ovld.2020.02.20a', 'rcu-tasks.2020.02.20a', 'srcu.2020.02.20a' and 'torture.2020.02.20a' into HEAD
      
      doc.2020.02.27a: Documentation updates.
      fixes.2020.03.21a: Miscellaneous fixes.
      kfree_rcu.2020.02.20a: Updates to kfree_rcu().
      locktorture.2020.02.20a: Lock torture-test updates.
      ovld.2020.02.20a: Updates to callback-overload handling.
      rcu-tasks.2020.02.20a: RCU-tasks updates.
      srcu.2020.02.20a: SRCU updates.
      torture.2020.02.20a: Torture-test updates.
      aa93ec62
  2. 21 Mar, 2020 2 commits
    • Paul E. McKenney's avatar
      rcu: Make rcu_barrier() account for offline no-CBs CPUs · 127e2981
      Paul E. McKenney authored
      Currently, rcu_barrier() ignores offline CPUs,  However, it is possible
      for an offline no-CBs CPU to have callbacks queued, and rcu_barrier()
      must wait for those callbacks.  This commit therefore makes rcu_barrier()
      directly invoke the rcu_barrier_func() with interrupts disabled for such
      CPUs.  This requires passing the CPU number into this function so that
      it can entrain the rcu_barrier() callback onto the correct CPU's callback
      list, given that the code must instead execute on the current CPU.
      
      While in the area, this commit fixes a bug where the first CPU's callback
      might have been invoked before rcu_segcblist_entrain() returned, which
      would also result in an early wakeup.
      
      Fixes: 5d6742b3 ("rcu/nocb: Use rcu_segcblist for no-CBs CPUs")
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      [ paulmck: Apply optimization feedback from Boqun Feng. ]
      Cc: <stable@vger.kernel.org> # 5.5.x
      127e2981
    • Paul E. McKenney's avatar
      rcu: Mark rcu_state.gp_seq to detect concurrent writes · 0f11ad32
      Paul E. McKenney authored
      The rcu_state structure's gp_seq field is only to be modified by the RCU
      grace-period kthread, which is single-threaded.  This commit therefore
      enlists KCSAN's help in enforcing this restriction.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      0f11ad32
  3. 27 Feb, 2020 9 commits
  4. 21 Feb, 2020 28 commits
    • Paul E. McKenney's avatar
      rcutorture: Set KCSAN Kconfig options to detect more data races · a144935c
      Paul E. McKenney authored
      This commit enables the KCSAN Kconfig options that (1) detect data
      races between reads and writes even when the writes do not change the
      variable's value and (2) detect data races involving plain C-language
      writes.  These changes only affect scripted rcutorture runs and can be
      overridden using the kvm.sh --kconfig argument.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      a144935c
    • Paul E. McKenney's avatar
      rcutorture: Manually clean up after rcu_barrier() failure · 9470a18f
      Paul E. McKenney authored
      Currently, if rcu_barrier() returns too soon, the test waits 100ms and
      then does another instance of the test.  However, if rcu_barrier() were
      to have waited for more than 100ms too short a time, this could cause
      the test's rcu_head structures to be reused while they were still on
      RCU's callback lists.  This can result in knock-on errors that obscure
      the original rcu_barrier() test failure.
      
      This commit therefore adds code that attempts to wait until all of
      the test's callbacks have been invoked.  Of course, if RCU completely
      lost track of the corresponding rcu_head structures, this wait could be
      forever.  This commit therefore also complains if this attempted recovery
      takes more than one second, and it also gives up when the test ends.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      9470a18f
    • Paul E. McKenney's avatar
      rcutorture: Make rcu_torture_barrier_cbs() post from corresponding CPU · 50d4b629
      Paul E. McKenney authored
      Currently, rcu_torture_barrier_cbs() posts callbacks from whatever CPU
      it is running on, which means that all these kthreads might well be
      posting from the same CPU, which would drastically reduce the effectiveness
      of this test.  This commit therefore uses IPIs to make the callbacks be
      posted from the corresponding CPU (given by local variable myid).
      
      If the IPI fails (which can happen if the target CPU is offline or does
      not exist at all), the callback is posted on whatever CPU is currently
      running.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      50d4b629
    • Joel Fernandes (Google)'s avatar
      rcuperf: Measure memory footprint during kfree_rcu() test · 12af6603
      Joel Fernandes (Google) authored
      During changes to kfree_rcu() code, we often check the amount of free
      memory.  As an alternative to checking this manually, this commit adds a
      measurement in the test itself.  It measures four times during the test
      for available memory, digitally filters these measurements to produce a
      running average with a weight of 0.5, and compares this digitally filtered
      value with the amount of available memory at the beginning of the test.
      
      Something like the following is printed at the end of the run:
      
      Total time taken by all kfree'ers: 6369738407 ns, loops: 10000, batches: 764, memory footprint: 216MB
      Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      12af6603
    • Paul E. McKenney's avatar
      rcutorture: Annotation lockless accesses to rcu_torture_current · 5396d31d
      Paul E. McKenney authored
      The rcutorture global variable rcu_torture_current is accessed locklessly,
      so it must use the RCU pointer load/store primitives.  This commit
      therefore adds several that were missed.
      
      This data race was reported by KCSAN.  Not appropriate for backporting due
      to failure being unlikely and due to this being used only by rcutorture.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      5396d31d
    • Paul E. McKenney's avatar
      rcutorture: Add READ_ONCE() to rcu_torture_count and rcu_torture_batch · f042a436
      Paul E. McKenney authored
      The rcutorture rcu_torture_count and rcu_torture_batch per-CPU variables
      are read locklessly, so this commit adds the READ_ONCE() to a load in
      order to avoid various types of compiler vandalism^Woptimization.
      
      This data race was reported by KCSAN. Not appropriate for backporting
      due to failure being unlikely and due to this being rcutorture.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      f042a436
    • Paul E. McKenney's avatar
      rcutorture: Fix stray access to rcu_fwd_cb_nodelay · 102c14d2
      Paul E. McKenney authored
      The rcu_fwd_cb_nodelay variable suppresses excessively long read-side
      delays while carrying out an rcutorture forward-progress test.  As such,
      it is accessed both by readers and updaters, and most of the accesses
      therefore use *_ONCE().  Except for one in rcu_read_delay(), which this
      commit fixes.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to this being rcutorture.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      102c14d2
    • Paul E. McKenney's avatar
      rcutorture: Fix rcu_torture_one_read()/rcu_torture_writer() data race · 20248910
      Paul E. McKenney authored
      The ->rtort_pipe_count field in the rcu_torture structure checks for
      too-short grace periods, and is therefore read by rcutorture's readers
      while being updated by rcutorture's writers.  This commit therefore
      adds the needed READ_ONCE() and WRITE_ONCE() invocations.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to failure being unlikely and due to this being rcutorture.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      20248910
    • Paul E. McKenney's avatar
      rcutorture: Make kvm-find-errors.sh abort on bad directory · beabc806
      Paul E. McKenney authored
      Currently, kvm-find-errors.sh gives a usage prompt when given a bad
      directory, but then soldiers on, giving a series of confusing error
      messages.  This commit therefore prints an error message and exits when
      given a bad directory, hopefully reducing confusion.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      beabc806
    • Paul E. McKenney's avatar
      rcutorture: Summarize summary of build and run results · c0b94ffb
      Paul E. McKenney authored
      When running the default list of tests, the run summary of a successful
      (that is, failed to find any errors) run fits easily on a 24-line screen.
      But a run with something like "--configs '5*CFLIST'" will be 80 lines long,
      and it is all too easy to miss a failure message when scrolling back.
      This commit therefore prints out the number of runs with failing builds
      or runtime failures, but only if there are any such failures.
      
      For example, a run with a single build error and a single runtime error
      would print two lines like this:
      
      1 runs with build errors.
      1 runs with runtime errors.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      c0b94ffb
    • Paul E. McKenney's avatar
      rcutorture: Add 100-CPU configuration · e0714247
      Paul E. McKenney authored
      The small-system rcutorture configurations have served us well for a great
      many years, but it is now time to add a larger one.  This commit does
      just that, but does not add it to the defaults in CFLIST.  This allows
      the kvm.sh argument '--configs "4*CFLIST TREE10" to run four instances
      of each of the default configurations concurrently with one instance of
      the large configuration.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      e0714247
    • Paul E. McKenney's avatar
      torture: Allow disabling of boottime CPU-hotplug torture operations · 8171d3e0
      Paul E. McKenney authored
      In theory, RCU-hotplug operations are supposed to work as soon as there
      is more than one CPU online.  However, in practice, in normal production
      there is no way to make them happen until userspace is up and running.
      Besides which, on smaller systems, rcutorture doesn't start doing hotplug
      operations until 30 seconds after the start of boot, which on most
      systems also means the better part of 30 seconds after the end of boot.
      This commit therefore provides a new torture.disable_onoff_at_boot kernel
      boot parameter that suppresses CPU-hotplug torture operations until
      about the time that init is spawned.
      
      Of course, if you know of a need for boottime CPU-hotplug operations,
      then you should avoid passing this argument to any of the torture tests.
      You might also want to look at the splats linked to below.
      
      Link: https://lore.kernel.org/lkml/20191206185208.GA25636@paulmck-ThinkPad-P72/Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      8171d3e0
    • Paul E. McKenney's avatar
      rcutorture: Suppress boottime bad-sequence warnings · 4ab00bdd
      Paul E. McKenney authored
      In normal production, an excessively long wait on a grace period
      (synchronize_rcu(), for example) at boottime is often just as bad
      as at any other time.  In fact, given the desire for fast boot, any
      sort of long wait at boot is a bad idea.  However, heavy rcutorture
      testing on large hyperthreaded systems can generate such long waits
      during boot as a matter of course.  This commit therefore causes
      the rcupdate.rcu_cpu_stall_suppress_at_boot kernel boot parameter to
      suppress reporting of bootime bad-sequence warning due to excessively
      long grace-period waits.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      4ab00bdd
    • Paul E. McKenney's avatar
      rcutorture: Allow boottime stall warnings to be suppressed · 58c53360
      Paul E. McKenney authored
      In normal production, an RCU CPU stall warning at boottime is often
      just as bad as at any other time.  In fact, given the desire for fast
      boot, any sort of long-term stall at boot is a bad idea.  However,
      heavy rcutorture testing on large hyperthreaded systems can generate
      boottime RCU CPU stalls as a matter of course.  This commit therefore
      provides a kernel boot parameter that suppresses reporting of boottime
      RCU CPU stall warnings and similarly of rcutorture writer stalls.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      58c53360
    • Paul E. McKenney's avatar
      torture: Forgive -EBUSY from boottime CPU-hotplug operations · a59ee765
      Paul E. McKenney authored
      During boot, CPU hotplug is often disabled, for example by PCI probing.
      On large systems that take substantial time to boot, this can result
      in spurious RCU_HOTPLUG errors.  This commit therefore forgives any
      boottime -EBUSY CPU-hotplug failures by adjusting counters to pretend
      that the corresponding attempt never happened.  A non-splat record
      of the failed attempt is emitted to the console with the added string
      "(-EBUSY forgiven during boot)".
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      a59ee765
    • Paul E. McKenney's avatar
      rcutorture: Refrain from callback flooding during boot · 43550809
      Paul E. McKenney authored
      Additional rcutorture aggression can result in, believe it or not,
      boot times in excess of three minutes on large hyperthreaded systems.
      This is long enough for rcutorture to decide to do some callback flooding,
      which seems a bit excessive given that userspace cannot have started
      until long after boot, and it is userspace that does the real-world
      callback flooding.  Worse yet, because Tiny RCU lacks forward-progress
      functionality, the looping-in-the-kernel tests can also be problematic
      during early boot.
      
      This commit therefore causes rcutorture to hold off on callback
      flooding until about the time that init is spawned, and the same
      for looping-in-the-kernel tests for Tiny RCU.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      43550809
    • Paul E. McKenney's avatar
      torture: Make results-directory date format completion-friendly · 90e23b6b
      Paul E. McKenney authored
      The names of the per-test results directories are of the form
      2019.11.29-20:42:19.  This works, but the ":" characters make
      tab-based shell name completion a bit onerous because the user must
      remember to include a quote character somewhere before the first ":".
      This commit therefore changes the ":" characters to periods, as in
      2019.12.01-20.48.01", which allows tab-based completion to work more
      naturally.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      90e23b6b
    • Paul E. McKenney's avatar
      rcutorture: Suppress forward-progress complaints during early boot · 59ee0326
      Paul E. McKenney authored
      Some larger systems can take in excess of 50 seconds to complete their
      early boot initcalls prior to spawing init.  This does not in any way
      help the forward-progress judgments of built-in rcutorture (when
      rcutorture is built as a module, the insmod or modprobe command normally
      cannot happen until some time after boot completes).  This commit
      therefore suppresses such complaints until about the time that init
      is spawned.
      
      This also includes a fix to a stupid error located by kbuild test robot.
      
      [ paulmck: Apply kbuild test robot feedback. ]
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      [ paulmck: Fix to nohz_full slow-expediting recovery logic, per bpetkov. ]
      [ paulmck: Restrict splat to CONFIG_PREEMPT_RT=y kernels and simplify. ]
      Tested-by: default avatarBorislav Petkov <bp@alien8.de>
      59ee0326
    • Paul E. McKenney's avatar
      srcu: Hold srcu_struct ->lock when updating ->srcu_gp_seq · 71042606
      Paul E. McKenney authored
      A read of the srcu_struct structure's ->srcu_gp_seq field should not
      need READ_ONCE() when that structure's ->lock is held.  Except that this
      lock is not always held when updating this field.  This commit therefore
      acquires the lock around updates and removes a now-unneeded READ_ONCE().
      
      This data race was reported by KCSAN.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      [ paulmck: Switch from READ_ONCE() to lock per Peter Zilstra question. ]
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      71042606
    • Paul E. McKenney's avatar
      srcu: Fix process_srcu()/srcu_batches_completed() datarace · 39f91504
      Paul E. McKenney authored
      The srcu_struct structure's ->srcu_idx field is accessed locklessly,
      so reads must use READ_ONCE().  This commit therefore adds the needed
      READ_ONCE() invocation where it was missed.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to failure being unlikely.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      39f91504
    • Paul E. McKenney's avatar
      srcu: Fix __call_srcu()/srcu_get_delay() datarace · 8c9e0cb3
      Paul E. McKenney authored
      The srcu_struct structure's ->srcu_gp_seq_needed_exp field is accessed
      locklessly, so updates must use WRITE_ONCE().  This commit therefore
      adds the needed WRITE_ONCE() invocations.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to failure being unlikely.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      8c9e0cb3
    • Paul E. McKenney's avatar
      srcu: Fix __call_srcu()/process_srcu() datarace · 7ff8b450
      Paul E. McKenney authored
      The srcu_node structure's ->srcu_gp_seq_needed_exp field is accessed
      locklessly, so updates must use WRITE_ONCE().  This commit therefore
      adds the needed WRITE_ONCE() invocations.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to failure being unlikely.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      7ff8b450
    • Jules Irenge's avatar
      rcu: Add missing annotation for exit_tasks_rcu_finish() · 90ba11ba
      Jules Irenge authored
      Sparse reports a warning at exit_tasks_rcu_finish(void)
      
      |warning: context imbalance in exit_tasks_rcu_finish()
      |- wrong count at exit
      
      To fix this, this commit adds a __releases(&tasks_rcu_exit_srcu).
      Given that exit_tasks_rcu_finish() does actually call __srcu_read_lock(),
      this not only fixes the warning but also improves on the readability of
      the code.
      Signed-off-by: default avatarJules Irenge <jbi.octave@gmail.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      90ba11ba
    • Jules Irenge's avatar
      rcu: Add missing annotation for exit_tasks_rcu_start() · e1e9bdc0
      Jules Irenge authored
      Sparse reports a warning at exit_tasks_rcu_start(void)
      
      |warning: context imbalance in exit_tasks_rcu_start() - wrong count at exit
      
      To fix this, this commit adds an __acquires(&tasks_rcu_exit_srcu).
      Given that exit_tasks_rcu_start() does actually call __srcu_read_lock(),
      this not only fixes the warning but also improves on the readability of
      the code.
      Signed-off-by: default avatarJules Irenge <jbi.octave@gmail.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      e1e9bdc0
    • Paul E. McKenney's avatar
      rcu-tasks: *_ONCE() for rcu_tasks_cbs_head · fcb73812
      Paul E. McKenney authored
      The RCU tasks list of callbacks, rcu_tasks_cbs_head, is sampled locklessly
      by rcu_tasks_kthread() when waiting for work to do.  This commit therefore
      applies READ_ONCE() to that lockless sampling and WRITE_ONCE() to the
      single potential store outside of rcu_tasks_kthread.
      
      This data race was reported by KCSAN.  Not appropriate for backporting
      due to failure being unlikely.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      fcb73812
    • Paul E. McKenney's avatar
      rcu: Update __call_rcu() comments · b692dc4a
      Paul E. McKenney authored
      The __call_rcu() function's header comment refers to a cpu argument
      that no longer exists, and the comment of the return path from
      rcu_nocb_try_bypass() ignores the non-no-CBs CPU case.  This commit
      therefore update both comments.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      b692dc4a
    • Colin Ian King's avatar
      rcu: Fix spelling mistake "leval" -> "level" · aa96a93b
      Colin Ian King authored
      This commit fixes a spelling mistake in a pr_info() message.
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      aa96a93b
    • Paul E. McKenney's avatar
      rcu: React to callback overload by boosting RCU readers · 8c14263d
      Paul E. McKenney authored
      RCU priority boosting currently is not applied until the grace period
      is at least 250 milliseconds old (or the number of milliseconds specified
      by the CONFIG_RCU_BOOST_DELAY Kconfig option).  Although this has worked
      well, it can result in OOM under conditions of RCU callback flooding.
      One can argue that the real-time systems using RCU priority boosting
      should carefully avoid RCU callback flooding, but one can just as well
      argue that an OOM is a rather obnoxious error message.
      
      This commit therefore disables the RCU priority boosting delay when
      there are excessive numbers of callbacks queued.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      8c14263d