rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
To: linux-kernel@vger.kernel.org
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Corbet <corbet@lwn.net>,
	Josh Triplett <josh@joshtriplett.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	linux-doc@vger.kernel.org,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	neeraju@codeaurora.org, "Paul E. McKenney" <paulmck@kernel.org>,
	peterz@infradead.org, Randy Dunlap <rdunlap@infradead.org>,
	rcu@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
	tglx@linutronix.de, vineethrp@gmail.com
Subject: [PATCH v4 5/5] docs: Update RCU's hotplug requirements with a bit about design
Date: Fri,  7 Aug 2020 13:07:22 -0400	[thread overview]
Message-ID: <20200807170722.2897328-6-joel@joelfernandes.org> (raw)
In-Reply-To: <20200807170722.2897328-1-joel@joelfernandes.org>

RCU's hotplug design will help understand the requirements an RCU
implementation needs to fullfill, such as dead-lock avoidance.

The rcu_barrier() section of the "Hotplug CPU" section already talks
about deadlocks, however the description of what else can deadlock other
than rcu_barrier is rather incomplete.

This commit therefore continues the section by describing how RCU's
design handles CPU hotplug in a deadlock-free way.

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
 .../RCU/Design/Requirements/Requirements.rst  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst
index 16c64a2eff93..0a4148b9f743 100644
--- a/Documentation/RCU/Design/Requirements/Requirements.rst
+++ b/Documentation/RCU/Design/Requirements/Requirements.rst
@@ -1940,6 +1940,28 @@ deadlock. Furthermore, ``rcu_barrier()`` blocks CPU-hotplug operations
 during its execution, which results in another type of deadlock when
 invoked from a CPU-hotplug notifier.
 
+Also, RCU's implementation avoids serious deadlocks which could occur due to
+interaction between hotplug, timers and grace period processing. It does so by
+maintaining its own bookkeeping of every CPU's hotplug state, independent of
+the various CPU masks and by reporting quiescent states at explicit points.  It
+may come across as a surprise, but the force quiescent state loop (FQS) does
+not report quiescent states for offline CPUs and is not required to.
+
+For an offline CPU, the quiescent state will be reported in either of:
+1. During CPU offlining, using RCU's hotplug notifier (``rcu_report_dead()``).
+2. During grace period initialization (``rcu_gp_init``) if it detected a race
+   with CPU offlining, or a race with a task unblocking on a node which
+   previously had all of its CPUs offlined.
+
+The CPU onlining path (``rcu_cpu_starting``) does not need to a report
+quiescent state for an offline CPU in fact it would trigger a warning if a
+quiescent state was not already reported for that CPU.
+
+During the checking/modification of RCU's hotplug bookkeeping, the
+corresponding CPU's leaf node lock is held. This avoids race conditions between
+RCU's hotplug notifier hooks, grace period initialization code and the FQS loop
+which can concurrently refer to or modify the bookkeeping.
+
 Scheduler and RCU
 ~~~~~~~~~~~~~~~~~
 
-- 
2.28.0.236.gb10cc79966-goog


  parent reply	other threads:[~2020-08-07 17:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 17:07 [PATCH v4 0/5] option-subject: RCU and CPU hotplug checks and docs Joel Fernandes (Google)
2020-08-07 17:07 ` [PATCH v4 1/5] rcu/tree: Add a warning if CPU being onlined did not report QS already Joel Fernandes (Google)
2020-08-10 15:46   ` Paul E. McKenney
2020-08-10 17:39     ` Joel Fernandes
2020-08-10 17:57       ` Paul E. McKenney
2020-08-10 19:25         ` Joel Fernandes
2020-08-10 20:20           ` Paul E. McKenney
2020-08-07 17:07 ` [PATCH v4 2/5] rcu/tree: Clarify comments about FQS loop reporting quiescent states Joel Fernandes (Google)
2020-08-10 18:06   ` Paul E. McKenney
2020-08-10 19:22     ` Joel Fernandes
2020-08-07 17:07 ` [PATCH v4 3/5] rcu/tree: Make FQS complaining about offline CPU more aggressive Joel Fernandes (Google)
2020-08-10 20:56   ` Paul E. McKenney
2020-08-07 17:07 ` [PATCH v4 4/5] rcutorture: Force synchronizing of RCU flavor from hotplug notifier Joel Fernandes (Google)
2020-08-10 16:19   ` Paul E. McKenney
2020-08-10 17:31     ` Joel Fernandes
2020-08-10 17:54       ` Paul E. McKenney
2020-08-10 19:41         ` Joel Fernandes
2020-08-07 17:07 ` Joel Fernandes (Google) [this message]
2020-08-08  2:10   ` [PATCH v4 5/5] docs: Update RCU's hotplug requirements with a bit about design Randy Dunlap
2020-08-10 17:41     ` Joel Fernandes
2020-08-07 18:31 ` [PATCH v4 0/5] option-subject: RCU and CPU hotplug checks and docs Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200807170722.2897328-6-joel@joelfernandes.org \
    --to=joel@joelfernandes.org \
    --cc=corbet@lwn.net \
    --cc=dave@stgolabs.net \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=neeraju@codeaurora.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vineethrp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).