summaryrefslogtreecommitdiff
path: root/include/linux/list_nulls.h
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2019-11-09 10:45:47 -0800
committerPaul E. McKenney <paulmck@kernel.org>2020-01-10 14:00:57 -0800
commit02b99b38f3d96c77cf0a368d99952aa372dfe58a (patch)
tree42f680311cf722e1d1a58256f784700bed339046 /include/linux/list_nulls.h
parent46deb7449d99f37bebf5cbd7f95c136c6fafeaa5 (diff)
rcu: Add a hlist_nulls_unhashed_lockless() function
This commit adds an hlist_nulls_unhashed_lockless() to allow lockless checking for whether or note an hlist_nulls_node is hashed or not. While in the area, this commit also adds a docbook comment to the existing hlist_nulls_unhashed() function. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'include/linux/list_nulls.h')
-rw-r--r--include/linux/list_nulls.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h
index 1ecd35664e0d..fa6e8471bd22 100644
--- a/include/linux/list_nulls.h
+++ b/include/linux/list_nulls.h
@@ -56,11 +56,33 @@ static inline unsigned long get_nulls_value(const struct hlist_nulls_node *ptr)
return ((unsigned long)ptr) >> 1;
}
+/**
+ * hlist_nulls_unhashed - Has node been removed and reinitialized?
+ * @h: Node to be checked
+ *
+ * Not that not all removal functions will leave a node in unhashed state.
+ * For example, hlist_del_init_rcu() leaves the node in unhashed state,
+ * but hlist_nulls_del() does not.
+ */
static inline int hlist_nulls_unhashed(const struct hlist_nulls_node *h)
{
return !h->pprev;
}
+/**
+ * hlist_nulls_unhashed_lockless - Has node been removed and reinitialized?
+ * @h: Node to be checked
+ *
+ * Not that not all removal functions will leave a node in unhashed state.
+ * For example, hlist_del_init_rcu() leaves the node in unhashed state,
+ * but hlist_nulls_del() does not. Unlike hlist_nulls_unhashed(), this
+ * function may be used locklessly.
+ */
+static inline int hlist_nulls_unhashed_lockless(const struct hlist_nulls_node *h)
+{
+ return !READ_ONCE(h->pprev);
+}
+
static inline int hlist_nulls_empty(const struct hlist_nulls_head *h)
{
return is_a_nulls(READ_ONCE(h->first));