diff mbox series

rcu: Call drain_call_rcu at exit

Message ID 20241013-rcu-v1-1-a93b7c5957f3@daynix.com (mailing list archive)
State New
Headers show
Series rcu: Call drain_call_rcu at exit | expand

Commit Message

Akihiko Odaki Oct. 13, 2024, 7:31 a.m. UTC
call_rcu() callbacks may have potential memory leaks, but QEMU may
sometimes exit before draining the callbacks and leave the leaks
undetected by LeakSanitizer. For example, PCI devices register a
call_rcu() callback by calling address_space_destroy() and they will
not be freed until it gets drained. This hides memory leaks that
is going to happen when PCI devices loose references to the memory
allocations.

Call drain_call_rcu at exit to expose memory leaks by call_rcu()
callbacks deterministically.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 util/rcu.c | 1 +
 1 file changed, 1 insertion(+)


---
base-commit: 31669121a01a14732f57c49400bc239cf9fd505f
change-id: 20241013-rcu-b4864052a103

Best regards,
diff mbox series

Patch

diff --git a/util/rcu.c b/util/rcu.c
index fa32c942e4bb..118a974e3438 100644
--- a/util/rcu.c
+++ b/util/rcu.c
@@ -415,6 +415,7 @@  static void rcu_init_complete(void)
     qemu_thread_create(&thread, "call_rcu", call_rcu_thread,
                        NULL, QEMU_THREAD_DETACHED);
 
+    atexit(drain_call_rcu);
     rcu_register_thread();
 }