All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
	fweisbec@gmail.com, oleg@redhat.com, joel.opensrc@gmail.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 14/22] rcu: Add leaf-node macros
Date: Sun, 22 Apr 2018 19:32:19 -0700	[thread overview]
Message-ID: <1524450747-22778-14-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180423023150.GA21533@linux.vnet.ibm.com>

This commit adds rcu_first_leaf_node() that returns a pointer to
the first leaf rcu_node structure in the specified RCU flavor and an
rcu_is_leaf_node() that returns true iff the specified rcu_node structure
is a leaf.  This commit also uses these macros where appropriate.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/rcu.h         | 11 ++++++++---
 kernel/rcu/tree.c        |  4 ++--
 kernel/rcu/tree_plugin.h |  4 ++--
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 7a693e31184a..5b5bb9ee2e20 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -270,6 +270,12 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
 	}
 }
 
+/* Returns first leaf rcu_node of the specified RCU flavor. */
+#define rcu_first_leaf_node(rsp) ((rsp)->level[rcu_num_lvls - 1])
+
+/* Is this rcu_node a leaf? */
+#define rcu_is_leaf_node(rnp) ((rnp)->level == rcu_num_lvls - 1)
+
 /*
  * Do a full breadth-first scan of the rcu_node structures for the
  * specified rcu_state structure.
@@ -284,8 +290,7 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
  * rcu_node tree with but one rcu_node structure, this loop is a no-op.
  */
 #define rcu_for_each_nonleaf_node_breadth_first(rsp, rnp) \
-	for ((rnp) = &(rsp)->node[0]; \
-	     (rnp) < (rsp)->level[rcu_num_lvls - 1]; (rnp)++)
+	for ((rnp) = &(rsp)->node[0]; !rcu_is_leaf_node(rsp, rnp); (rnp)++)
 
 /*
  * Scan the leaves of the rcu_node hierarchy for the specified rcu_state
@@ -294,7 +299,7 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
  * It is still a leaf node, even if it is also the root node.
  */
 #define rcu_for_each_leaf_node(rsp, rnp) \
-	for ((rnp) = (rsp)->level[rcu_num_lvls - 1]; \
+	for ((rnp) = rcu_first_leaf_node(rsp); \
 	     (rnp) < &(rsp)->node[rcu_num_nodes]; (rnp)++)
 
 /*
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 19d9475d74f2..08b72dd02d88 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2405,7 +2405,7 @@ rcu_report_qs_rnp(unsigned long mask, struct rcu_state *rsp,
 			return;
 		}
 		WARN_ON_ONCE(oldmask); /* Any child must be all zeroed! */
-		WARN_ON_ONCE(rnp->level != rcu_num_lvls - 1 &&
+		WARN_ON_ONCE(!rcu_is_leaf_node(rnp) &&
 			     rcu_preempt_blocked_readers_cgp(rnp));
 		rnp->qsmask &= ~mask;
 		trace_rcu_quiescent_state_report(rsp->name, rnp->gpnum,
@@ -4063,7 +4063,7 @@ static void __init rcu_init_one(struct rcu_state *rsp)
 
 	init_swait_queue_head(&rsp->gp_wq);
 	init_swait_queue_head(&rsp->expedited_wq);
-	rnp = rsp->level[rcu_num_lvls - 1];
+	rnp = rcu_first_leaf_node(rsp);
 	for_each_possible_cpu(i) {
 		while (i > rnp->grphi)
 			rnp++;
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index d37b9bb3f481..b999032e9466 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -182,7 +182,7 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
 
 	raw_lockdep_assert_held_rcu_node(rnp);
 	WARN_ON_ONCE(rdp->mynode != rnp);
-	WARN_ON_ONCE(rnp->level != rcu_num_lvls - 1);
+	WARN_ON_ONCE(!rcu_is_leaf_node(rnp));
 
 	/*
 	 * Decide where to queue the newly blocked task.  In theory,
@@ -533,7 +533,7 @@ void rcu_read_unlock_special(struct task_struct *t)
 		rnp = t->rcu_blocked_node;
 		raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */
 		WARN_ON_ONCE(rnp != t->rcu_blocked_node);
-		WARN_ON_ONCE(rnp->level != rcu_num_lvls - 1);
+		WARN_ON_ONCE(!rcu_is_leaf_node(rnp));
 		empty_norm = !rcu_preempt_blocked_readers_cgp(rnp);
 		empty_exp = sync_rcu_preempt_exp_done(rnp);
 		smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */
-- 
2.5.2

  parent reply	other threads:[~2018-04-23  2:35 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23  2:31 [PATCH tip/core/rcu 0/22] Miscellaneous fixes for v4.18 Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 01/22] sched: Make non-production PREEMPT cond_resched() help Tasks RCU Paul E. McKenney
2018-04-23  8:51   ` Peter Zijlstra
2018-04-23 12:40     ` Paul E. McKenney
2018-04-23 13:47       ` Steven Rostedt
2018-04-23 14:10         ` Peter Zijlstra
2018-04-23 14:35           ` Steven Rostedt
2018-04-23 15:47             ` Paul E. McKenney
2018-04-23 19:12               ` Paul E. McKenney
2018-04-23 14:03       ` Peter Zijlstra
2018-04-23  2:32 ` [PATCH tip/core/rcu 02/22] rcu: Inline rcu_preempt_do_callback() into its sole caller Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 03/22] rcu: Don't allocate rcu_nocb_mask if no one needs it Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 04/22] rcu: Call wake_nocb_leader_defer() with 'FORCE' when nocb_q_count is high Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 05/22] rcu: Remove deprecated RCU debugfs tracing code Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 06/22] rcu: Rename cond_resched_rcu_qs() to cond_resched_tasks_rcu_qs() Paul E. McKenney
2018-04-23  8:53   ` Peter Zijlstra
2018-04-23 12:32     ` Paul E. McKenney
2018-04-23 12:48       ` Peter Zijlstra
2018-04-23 13:12         ` Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 07/22] softirq: Eliminate unused cond_resched_softirq() macro Paul E. McKenney
2018-04-23  8:54   ` Peter Zijlstra
2018-04-23 13:25     ` Eric Dumazet
2018-04-23 19:10       ` Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 08/22] rcu: Move __rcu_read_lock() and __rcu_read_unlock() to tree_plugin.h Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 09/22] rcu: Update rcu_bind_gp_kthread() header comment Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 10/22] rcu: Declare rcu_eqs_special_set() in public header Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 11/22] srcu: Add cleanup_srcu_struct_quiesced() Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 12/22] nvme: Avoid flush dependency in delete controller flow Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 13/22] rcu: Exclude near-simultaneous RCU CPU stall warnings Paul E. McKenney
2018-05-03 18:22   ` Paul E. McKenney
2018-04-23  2:32 ` Paul E. McKenney [this message]
2018-04-23  2:32 ` [PATCH tip/core/rcu 15/22] doc: Ensure whatisRCU.txt actually says what RCU is Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 16/22] EXP: rcu: Add debugging info to assertion Paul E. McKenney
2018-05-03 18:23   ` Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 17/22] EXP: rcu: Abstract addition of debugging information " Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 18/22] EXP: rcu: Add ->boost_tasks " Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 19/22] EXP: rcu: Add debugging info to other assertion Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 20/22] EXP rcu: Add ->qsmask to assertion Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 21/22] EXP rcu: Add checks for setting ->gp_flags Paul E. McKenney
2018-04-23  2:32 ` [PATCH tip/core/rcu 22/22] rcu: Use the proper lockdep annotation in dump_blkd_tasks() Paul E. McKenney

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=1524450747-22778-14-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel.opensrc@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.