Make some list functions RCU safe in the LinuxKPI.

While at it rename hlist_add_after() into hlist_add_behind().

Submitted by:	Johannes Lundberg <johalun0@gmail.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
This commit is contained in:
Hans Petter Selasky 2018-06-06 15:49:01 +00:00
parent 1a43cff92a
commit 40ddfc7604

View File

@ -337,16 +337,16 @@ static inline int
hlist_empty(const struct hlist_head *h)
{
return !h->first;
return !READ_ONCE(h->first);
}
static inline void
hlist_del(struct hlist_node *n)
{
if (n->next)
WRITE_ONCE(*(n->pprev), n->next);
if (n->next != NULL)
n->next->pprev = n->pprev;
*n->pprev = n->next;
}
static inline void
@ -364,9 +364,9 @@ hlist_add_head(struct hlist_node *n, struct hlist_head *h)
{
n->next = h->first;
if (h->first)
if (h->first != NULL)
h->first->pprev = &n->next;
h->first = n;
WRITE_ONCE(h->first, n);
n->pprev = &h->first;
}
@ -377,18 +377,19 @@ hlist_add_before(struct hlist_node *n, struct hlist_node *next)
n->pprev = next->pprev;
n->next = next;
next->pprev = &n->next;
*(n->pprev) = n;
WRITE_ONCE(*(n->pprev), n);
}
static inline void
hlist_add_after(struct hlist_node *n, struct hlist_node *next)
hlist_add_behind(struct hlist_node *n, struct hlist_node *prev)
{
next->next = n->next;
n->next = next;
next->pprev = &n->next;
if (next->next)
next->next->pprev = &next->next;
n->next = prev->next;
WRITE_ONCE(prev->next, n);
n->pprev = &prev->next;
if (n->next != NULL)
n->next->pprev = &n->next;
}
static inline void