1. 03 Feb, 2023 14 commits
  2. 24 Jan, 2023 1 commit
    • Joel Fernandes (Google)'s avatar
      rcu: Disable laziness if lazy-tracking says so · cf7066b9
      Joel Fernandes (Google) authored
      During suspend, we see failures to suspend 1 in 300-500 suspends.
      Looking closer, it appears that asynchronous RCU callbacks are being
      queued as lazy even though synchronous callbacks are expedited. These
      delays appear to not be very welcome by the suspend/resume code as
      evidenced by these occasional suspend failures.
      
      This commit modifies call_rcu() to check if rcu_async_should_hurry(),
      which will return true if we are in suspend or in-kernel boot.
      
      [ paulmck: Alphabetize local variables. ]
      
      Ignoring the lazy hint makes the 3000 suspend/resume cycles pass
      reliably on a 12th gen 12-core Intel CPU, and there is some evidence
      that it also slightly speeds up boot performance.
      
      Fixes: 3cb278e7 ("rcu: Make call_rcu() lazy to save power")
      Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      cf7066b9
  3. 18 Jan, 2023 1 commit
    • Joel Fernandes (Google)'s avatar
      rcu: Track laziness during boot and suspend · 6efdda8b
      Joel Fernandes (Google) authored
      Boot and suspend/resume should not be slowed down in kernels built with
      CONFIG_RCU_LAZY=y.  In particular, suspend can sometimes fail in such
      kernels.
      
      This commit therefore adds rcu_async_hurry(), rcu_async_relax(), and
      rcu_async_should_hurry() functions that track whether or not either
      a boot or a suspend/resume operation is in progress.  This will
      enable a later commit to refrain from laziness during those times.
      
      Export rcu_async_should_hurry(), rcu_async_hurry(), and rcu_async_relax()
      for later use by rcutorture.
      
      [ paulmck: Apply feedback from Steve Rostedt. ]
      
      Fixes: 3cb278e7 ("rcu: Make call_rcu() lazy to save power")
      Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      6efdda8b
  4. 12 Jan, 2023 1 commit
  5. 05 Jan, 2023 16 commits
  6. 04 Jan, 2023 7 commits
    • Paul E. McKenney's avatar
      rcu: Permit string-valued Kconfig options in kvm.sh · 5a6cd56a
      Paul E. McKenney authored
      This commit upgrades the kvm.sh script's --kconfig parameter to accept
      string-valued Kconfig options with double-quoted string values.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      5a6cd56a
    • Paul E. McKenney's avatar
      torture: Permit double-quoted-string Kconfig options · ac71c3dd
      Paul E. McKenney authored
      Currently, the presence of any quoted-string Kconfig option in the
      scenario files or the CFcommon file (aside from the special-cased
      CONFIG_INITRAMFS_SOURCE option) will result in an "improperly set"
      diagnostic.  This commit updates configcheck.sh to strip double quotes
      in order to permit string-valued Kconfig options to be handled correctly.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      ac71c3dd
    • Tiezhu Yang's avatar
      selftests: rcutorture: Use "grep -E" instead of "egrep" · eeb4dd9e
      Tiezhu Yang authored
      The latest version of grep is deprecating the egrep command, so that
      its output contains warnings as follows:
      
      	egrep: warning: egrep is obsolescent; using grep -E
      
      Fix this using "grep -E" instead.
      
        sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/testing/selftests/rcutorture`
      
      Here are the steps to install the latest grep:
      
        wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
        tar xf grep-3.8.tar.gz
        cd grep-3.8 && ./configure && make
        sudo make install
        export PATH=/usr/local/bin:$PATH
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      eeb4dd9e
    • Paul E. McKenney's avatar
      torture: make kvm-find-errors.sh check for compressed vmlinux files · 3e4c07b9
      Paul E. McKenney authored
      Under some conditions, a given run's vmlinux file will be compressed,
      so that it is named vmlinux.xz rather than vmlinux.  in such cases,
      kvm-find-errors.sh will complain about the nonexistence of vmlinux.
      This commit therefore causes kvm-find-errors.sh to check for vmlinux.xz
      as well as for vmlinux.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      3e4c07b9
    • Paul E. McKenney's avatar
      refscale: Provide for initialization failure · 3c6496c8
      Paul E. McKenney authored
      Current tests all have init() functions that are guaranteed to succeed.
      But upcoming tests will need to allocate memory, thus possibly failing.
      This commit therefore handles init() function failure.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      3c6496c8
    • Paul E. McKenney's avatar
      torture: Seed torture_random_state on CPU · 95f93e97
      Paul E. McKenney authored
      The DEFINE_TORTURE_RANDOM_PERCPU() macro defines per-CPU random-number
      generators for torture testing, but the seeds for each CPU's instance
      will be identical if they are first used at the same time.  This commit
      therefore adds the CPU number to the mix when reseeding.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      95f93e97
    • Zqiang's avatar
      rcu-tasks: Handle queue-shrink/callback-enqueue race condition · a4fcfbee
      Zqiang authored
      The rcu_tasks_need_gpcb() determines whether or not: (1) There are
      callbacks needing another grace period, (2) There are callbacks ready
      to be invoked, and (3) It would be a good time to shrink back down to a
      single-CPU callback list.  This third case is interesting because some
      other CPU might be adding new callbacks, which might suddenly make this
      a very bad time to be shrinking.
      
      This is currently handled by requiring call_rcu_tasks_generic() to
      enqueue callbacks under the protection of rcu_read_lock() and requiring
      rcu_tasks_need_gpcb() to wait for an RCU grace period to elapse before
      finalizing the transition.  This works well in practice.
      
      Unfortunately, the current code assumes that a grace period whose end is
      detected by the poll_state_synchronize_rcu() in the second "if" condition
      actually ended before the earlier code counted the callbacks queued on
      CPUs other than CPU 0 (local variable "ncbsnz").  Given the current code,
      it is possible that a long-delayed call_rcu_tasks_generic() invocation
      will queue a callback on a non-zero CPU after these CPUs have had their
      callbacks counted and zero has been stored to ncbsnz.  Such a callback
      would trigger the WARN_ON_ONCE() in the second "if" statement.
      
      To see this, consider the following sequence of events:
      
      o	CPU 0 invokes rcu_tasks_one_gp(), and counts fewer than
      	rcu_task_collapse_lim callbacks.  It sees at least one
      	callback queued on some other CPU, thus setting ncbsnz
      	to a non-zero value.
      
      o	CPU 1 invokes call_rcu_tasks_generic() and loads 42 from
      	->percpu_enqueue_lim.  It therefore decides to enqueue its
      	callback onto CPU 1's callback list, but is delayed.
      
      o	CPU 0 sees the rcu_task_cb_adjust is non-zero and that the number
      	of callbacks does not exceed rcu_task_collapse_lim.  It therefore
      	checks percpu_enqueue_lim, and sees that its value is greater
      	than the value one.  CPU 0 therefore  starts the shift back
      	to a single callback list.  It sets ->percpu_enqueue_lim to 1,
      	but CPU 1 has already read the old value of 42.  It also gets
      	a grace-period state value from get_state_synchronize_rcu().
      
      o	CPU 0 sees that ncbsnz is non-zero in its second "if" statement,
      	so it declines to finalize the shrink operation.
      
      o	CPU 0 again invokes rcu_tasks_one_gp(), and counts fewer than
      	rcu_task_collapse_lim callbacks.  It also sees that there are
      	no callback queued on any other CPU, and thus sets ncbsnz to zero.
      
      o	CPU 1 resumes execution and enqueues its callback onto its own
      	list.  This invalidates the value of ncbsnz.
      
      o	CPU 0 sees the rcu_task_cb_adjust is non-zero and that the number
      	of callbacks does not exceed rcu_task_collapse_lim.  It therefore
      	checks percpu_enqueue_lim, but sees that its value is already
      	unity.	It therefore does not get a new grace-period state value.
      
      o	CPU 0 sees that rcu_task_cb_adjust is non-zero, ncbsnz is zero,
      	and that poll_state_synchronize_rcu() says that the grace period
      	has completed.  it therefore finalizes the shrink operation,
      	setting ->percpu_dequeue_lim to the value one.
      
      o	CPU 0 does a debug check, scanning the other CPUs' callback lists.
      	It sees that CPU 1's list has a callback, so it (rightly)
      	triggers the WARN_ON_ONCE().  After all, the new value of
      	->percpu_dequeue_lim says to not bother looking at CPU 1's
      	callback list, which means that this callback will never be
      	invoked.  This can result in hangs and maybe even OOMs.
      
      Based on long experience with rcutorture, this is an extremely
      low-probability race condition, but it really can happen, especially in
      preemptible kernels or within guest OSes.
      
      This commit therefore checks for completion of the grace period
      before counting callbacks.  With this change, in the above failure
      scenario CPU 0 would know not to prematurely end the shrink operation
      because the grace period would not have completed before the count
      operation started.
      
      [ paulmck: Adjust grace-period end rather than adding RCU reader. ]
      [ paulmck: Avoid spurious WARN_ON_ONCE() with ->percpu_dequeue_lim check. ]
      Signed-off-by: default avatarZqiang <qiang1.zhang@intel.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      a4fcfbee