@@ -94,13 +94,16 @@ struct srcu_struct {
/* Values for size state variable (->srcu_size_state). */
#define SRCU_SIZE_SMALL 0
#define SRCU_SIZE_ALLOC 1
+/* If snp tree is initialized */
#define SRCU_SIZE_WAIT_BARRIER 2
-#define SRCU_SIZE_WAIT_CALL 3
-#define SRCU_SIZE_WAIT_CBS1 4
-#define SRCU_SIZE_WAIT_CBS2 5
-#define SRCU_SIZE_WAIT_CBS3 6
-#define SRCU_SIZE_WAIT_CBS4 7
-#define SRCU_SIZE_BIG 8
+/*
+ * The following two states for the in-flight seq snap, who may not see
+ * the snp tree is active.
+ */
+#define SRCU_SIZE_WAIT_CBS1 3
+#define SRCU_SIZE_WAIT_CBS2 4
+/* All seq snap see the active tree */
+#define SRCU_SIZE_BIG 5
/* Values for state variable (bottom bits of ->srcu_gp_seq). */
#define SRCU_STATE_IDLE 0
@@ -1652,11 +1652,8 @@ static const char * const srcu_size_state_name[] = {
"SRCU_SIZE_SMALL",
"SRCU_SIZE_ALLOC",
"SRCU_SIZE_WAIT_BARRIER",
- "SRCU_SIZE_WAIT_CALL",
"SRCU_SIZE_WAIT_CBS1",
"SRCU_SIZE_WAIT_CBS2",
- "SRCU_SIZE_WAIT_CBS3",
- "SRCU_SIZE_WAIT_CBS4",
"SRCU_SIZE_BIG",
"SRCU_SIZE_???",
};
With the previous patch, srcu_cb_mutex is held when setting SRCU_SIZE_WAIT_BARRIER. It means that only two seq snap value can exist. And these two snaps can not see the active snp tree if srcu_gp_start_if_needed() fetches the srcu_size_state before it is updated to SRCU_SIZE_WAIT_BARRIER. After dispatching these two snap value's callbacks, the mask in snp->srcu_data_have_cbs[idx] is assured to be right. Hence the size state following SRCU_SIZE_WAIT_BARRIER can be shrink to three. Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: "Paul E. McKenney" <paulmck@kernel.org> Cc: Frederic Weisbecker <frederic@kernel.org> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com> To: rcu@vger.kernel.org --- include/linux/srcutree.h | 15 +++++++++------ kernel/rcu/srcutree.c | 3 --- 2 files changed, 9 insertions(+), 9 deletions(-)