Date: Wed, 20 Jun 2018 06:50:57 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335427 - stable/11/sys/compat/linuxkpi/common/include/linux Message-ID: <201806200650.w5K6ov0c026800@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Wed Jun 20 06:50:56 2018 New Revision: 335427 URL: https://svnweb.freebsd.org/changeset/base/335427 Log: MFC r334720: 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> Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Modified: stable/11/sys/compat/linuxkpi/common/include/linux/list.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/list.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/list.h Wed Jun 20 06:50:11 2018 (r335426) +++ stable/11/sys/compat/linuxkpi/common/include/linux/list.h Wed Jun 20 06:50:56 2018 (r335427) @@ -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 { 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_no 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806200650.w5K6ov0c026800>