]> git.proxmox.com Git - mirror_ovs.git/commit - vswitchd/ovs-vswitchd.c
ovs-vswitchd: Fire RCU callbacks before exit to reduce memory leak warnings.
authorBen Pfaff <blp@ovn.org>
Thu, 25 Jan 2018 23:39:48 +0000 (15:39 -0800)
committerBen Pfaff <blp@ovn.org>
Thu, 1 Feb 2018 19:26:58 +0000 (11:26 -0800)
commit9a3cf0ac3397555b38acd6ed7fed6e7eea5c0335
treee096cd22e02f11145abef02b53ab37fc58175d32
parent500db308e2704fa9fc5ff69cdcd9cb3b22116e99
ovs-vswitchd: Fire RCU callbacks before exit to reduce memory leak warnings.

ovs-vswitchd makes extensive use of RCU to defer freeing memory past the
latest time that it could be in use by a thread.  Until now, ovs-vswitchd
has not waited for RCU callbacks to fire before exiting.  This meant that
in many cases, when ovs-vswitchd exits, many blocks of memory are stuck in
RCU callback queues, which valgrind often reports as "possible" memory
leaks.

This commit adds a new function ovsrcu_exit() that waits and fires as many
RCU callbacks as it reasonably can.  It can only do so for the thread that
calls it and the thread that calls the callbacks, but generally speaking
ovs-vswitchd shuts down other threads before it exits anyway, so this is
pretty good.

In my testing this eliminates most valgrind warnings for tests that run
ovs-vswitchd.  This ought to make it easier to distinguish new leaks that
are real from existing non-leaks.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmai.com>
lib/ovs-rcu.c
lib/ovs-rcu.h
vswitchd/ovs-vswitchd.c