]> git.proxmox.com Git - mirror_ovs.git/commit - lib/pvector.c
pvector: Use acquire-release semantics for size.
authorYanqin Wei <Yanqin.Wei@arm.com>
Thu, 27 Feb 2020 16:12:21 +0000 (00:12 +0800)
committerIlya Maximets <i.maximets@ovn.org>
Sun, 15 Mar 2020 12:42:57 +0000 (13:42 +0100)
commit4e1ce6f66e0a97781284e3ea41a3ad3e9a0f83a3
tree6abffc03f14e2b6ae81dfd85a7b7d4581fe21fde
parent6f37078481bc31b53090aa85bc45ce10206c3569
pvector: Use acquire-release semantics for size.

Read/write concurrency of pvector library is implemented by a temp vector
and RCU protection. Considering performance reason, insertion does not
follow this scheme.
In insertion function, a thread fence ensures size increment is done
after new entry is stored. But there is no barrier in the iteration
fuction(pvector_cursor_init). Entry point access may be reordered before
loading vector size, so the invalid entry point may be loaded when vector
iteration.
This patch fixes it by acquire-release pair. It can guarantee new size is
observed by reader after new entry stored by writer. And this is
implemented by one-way barrier instead of two-way memory fence.

Fixes: fe7cfa5c3f19 ("lib/pvector: Non-intrusive RCU priority vector.")
Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
Reviewed-by: Lijian Zhang <Lijian.Zhang@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
lib/pvector.c
lib/pvector.h