Commit 65e56032 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Paul E. McKenney

rcu/nocb: Turn enabled/offload states into a common flag

This commit gathers the rcu_segcblist ->enabled and ->offloaded property
field into a single ->flags bitmask to avoid further proliferation of
individual u8 fields in the structure.  This change prepares for the
state formerly known as ->offloaded state to be modified at runtime.

Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Neeraj Upadhyay <neeraju@codeaurora.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Inspired-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Tested-by: default avatarBoqun Feng <boqun.feng@gmail.com>
Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent b4e6039e
...@@ -63,6 +63,9 @@ struct rcu_cblist { ...@@ -63,6 +63,9 @@ struct rcu_cblist {
#define RCU_NEXT_TAIL 3 #define RCU_NEXT_TAIL 3
#define RCU_CBLIST_NSEGS 4 #define RCU_CBLIST_NSEGS 4
#define SEGCBLIST_ENABLED BIT(0)
#define SEGCBLIST_OFFLOADED BIT(1)
struct rcu_segcblist { struct rcu_segcblist {
struct rcu_head *head; struct rcu_head *head;
struct rcu_head **tails[RCU_CBLIST_NSEGS]; struct rcu_head **tails[RCU_CBLIST_NSEGS];
...@@ -73,8 +76,7 @@ struct rcu_segcblist { ...@@ -73,8 +76,7 @@ struct rcu_segcblist {
long len; long len;
#endif #endif
long seglen[RCU_CBLIST_NSEGS]; long seglen[RCU_CBLIST_NSEGS];
u8 enabled; u8 flags;
u8 offloaded;
}; };
#define RCU_SEGCBLIST_INITIALIZER(n) \ #define RCU_SEGCBLIST_INITIALIZER(n) \
......
...@@ -246,7 +246,7 @@ void rcu_segcblist_init(struct rcu_segcblist *rsclp) ...@@ -246,7 +246,7 @@ void rcu_segcblist_init(struct rcu_segcblist *rsclp)
rcu_segcblist_set_seglen(rsclp, i, 0); rcu_segcblist_set_seglen(rsclp, i, 0);
} }
rcu_segcblist_set_len(rsclp, 0); rcu_segcblist_set_len(rsclp, 0);
rsclp->enabled = 1; rcu_segcblist_set_flags(rsclp, SEGCBLIST_ENABLED);
} }
/* /*
...@@ -257,7 +257,7 @@ void rcu_segcblist_disable(struct rcu_segcblist *rsclp) ...@@ -257,7 +257,7 @@ void rcu_segcblist_disable(struct rcu_segcblist *rsclp)
{ {
WARN_ON_ONCE(!rcu_segcblist_empty(rsclp)); WARN_ON_ONCE(!rcu_segcblist_empty(rsclp));
WARN_ON_ONCE(rcu_segcblist_n_cbs(rsclp)); WARN_ON_ONCE(rcu_segcblist_n_cbs(rsclp));
rsclp->enabled = 0; rcu_segcblist_clear_flags(rsclp, SEGCBLIST_ENABLED);
} }
/* /*
...@@ -266,7 +266,7 @@ void rcu_segcblist_disable(struct rcu_segcblist *rsclp) ...@@ -266,7 +266,7 @@ void rcu_segcblist_disable(struct rcu_segcblist *rsclp)
*/ */
void rcu_segcblist_offload(struct rcu_segcblist *rsclp) void rcu_segcblist_offload(struct rcu_segcblist *rsclp)
{ {
rsclp->offloaded = 1; rcu_segcblist_set_flags(rsclp, SEGCBLIST_OFFLOADED);
} }
/* /*
......
...@@ -53,19 +53,38 @@ static inline long rcu_segcblist_n_cbs(struct rcu_segcblist *rsclp) ...@@ -53,19 +53,38 @@ static inline long rcu_segcblist_n_cbs(struct rcu_segcblist *rsclp)
#endif #endif
} }
static inline void rcu_segcblist_set_flags(struct rcu_segcblist *rsclp,
int flags)
{
rsclp->flags |= flags;
}
static inline void rcu_segcblist_clear_flags(struct rcu_segcblist *rsclp,
int flags)
{
rsclp->flags &= ~flags;
}
static inline bool rcu_segcblist_test_flags(struct rcu_segcblist *rsclp,
int flags)
{
return READ_ONCE(rsclp->flags) & flags;
}
/* /*
* Is the specified rcu_segcblist enabled, for example, not corresponding * Is the specified rcu_segcblist enabled, for example, not corresponding
* to an offline CPU? * to an offline CPU?
*/ */
static inline bool rcu_segcblist_is_enabled(struct rcu_segcblist *rsclp) static inline bool rcu_segcblist_is_enabled(struct rcu_segcblist *rsclp)
{ {
return rsclp->enabled; return rcu_segcblist_test_flags(rsclp, SEGCBLIST_ENABLED);
} }
/* Is the specified rcu_segcblist offloaded? */ /* Is the specified rcu_segcblist offloaded? */
static inline bool rcu_segcblist_is_offloaded(struct rcu_segcblist *rsclp) static inline bool rcu_segcblist_is_offloaded(struct rcu_segcblist *rsclp)
{ {
return IS_ENABLED(CONFIG_RCU_NOCB_CPU) && rsclp->offloaded; return IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&
rcu_segcblist_test_flags(rsclp, SEGCBLIST_OFFLOADED);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment