Skip to content

Commit 02b99b3

Browse files
committed
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 <[email protected]>
1 parent 46deb74 commit 02b99b3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/linux/list_nulls.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,33 @@ static inline unsigned long get_nulls_value(const struct hlist_nulls_node *ptr)
5656
return ((unsigned long)ptr) >> 1;
5757
}
5858

59+
/**
60+
* hlist_nulls_unhashed - Has node been removed and reinitialized?
61+
* @h: Node to be checked
62+
*
63+
* Not that not all removal functions will leave a node in unhashed state.
64+
* For example, hlist_del_init_rcu() leaves the node in unhashed state,
65+
* but hlist_nulls_del() does not.
66+
*/
5967
static inline int hlist_nulls_unhashed(const struct hlist_nulls_node *h)
6068
{
6169
return !h->pprev;
6270
}
6371

72+
/**
73+
* hlist_nulls_unhashed_lockless - Has node been removed and reinitialized?
74+
* @h: Node to be checked
75+
*
76+
* Not that not all removal functions will leave a node in unhashed state.
77+
* For example, hlist_del_init_rcu() leaves the node in unhashed state,
78+
* but hlist_nulls_del() does not. Unlike hlist_nulls_unhashed(), this
79+
* function may be used locklessly.
80+
*/
81+
static inline int hlist_nulls_unhashed_lockless(const struct hlist_nulls_node *h)
82+
{
83+
return !READ_ONCE(h->pprev);
84+
}
85+
6486
static inline int hlist_nulls_empty(const struct hlist_nulls_head *h)
6587
{
6688
return is_a_nulls(READ_ONCE(h->first));

0 commit comments

Comments
 (0)