diff options
author | Adrian Moreno <amorenoz@redhat.com> | 2022-12-05 09:41:21 +0100 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-12-06 16:29:18 +0100 |
commit | 793709a856a8342abe1c594c94a2a55de8e349b4 (patch) | |
tree | f0e0ea4d337c0f8859a51ad93799df873f553533 | |
parent | abb9d3482e5586d69c8f962f2a01beadd2bffba8 (diff) | |
download | openvswitch-793709a856a8342abe1c594c94a2a55de8e349b4.tar.gz |
rculist: Use rculist_back_protected to access prev.
The .prev member of a rculist should not be used directly by users
because it's not rcu-safe. A convenient fake mutex (rculist_fake_mutex)
helps ensuring that in conjunction with clang's thread safety
extensions.
Only writers with exclusive access to the rculist should access .prev
via some of the provided *_protected() accessors.
Use rculist_back_protected() in REVERSE_PROTECTED iterators to avoid
clang's compilation warning.
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r-- | lib/rculist.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/rculist.h b/lib/rculist.h index 9bb8cbf3e..6df963eb2 100644 --- a/lib/rculist.h +++ b/lib/rculist.h @@ -378,12 +378,14 @@ rculist_is_singleton_protected(const struct rculist *list) UPDATE_MULTIVAR(ITER, rculist_next(ITER_VAR(ITER)))) #define RCULIST_FOR_EACH_REVERSE_PROTECTED(ITER, MEMBER, RCULIST) \ - for (INIT_MULTIVAR(ITER, MEMBER, (RCULIST)->prev, struct rculist); \ + for (INIT_MULTIVAR(ITER, MEMBER, rculist_back_protected(RCULIST), \ + struct rculist); \ CONDITION_MULTIVAR(ITER, MEMBER, ITER_VAR(ITER) != (RCULIST)); \ - UPDATE_MULTIVAR(ITER, ITER_VAR(ITER)->prev)) + UPDATE_MULTIVAR(ITER, rculist_back_protected(ITER_VAR(ITER)))) #define RCULIST_FOR_EACH_REVERSE_PROTECTED_CONTINUE(ITER, MEMBER, RCULIST) \ - for (INIT_MULTIVAR(ITER, MEMBER, (ITER)->MEMBER.prev, struct rculist); \ + for (INIT_MULTIVAR(ITER, MEMBER, rculist_back_protected(ITER->MEMBER), \ + struct rculist); \ CONDITION_MULTIVAR(ITER, MEMBER, ITER_VAR(ITER) != (RCULIST)); \ UPDATE_MULTIVAR(ITER, ITER_VAR(ITER)->prev)) |