qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rcu: Call drain_call_rcu at exit
@ 2024-10-13  7:31 Akihiko Odaki
  2025-01-11  5:40 ` Akihiko Odaki
  0 siblings, 1 reply; 2+ messages in thread
From: Akihiko Odaki @ 2024-10-13  7:31 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Akihiko Odaki

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(+)

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();
 }
 

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

Best regards,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-11  5:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-13  7:31 [PATCH] rcu: Call drain_call_rcu at exit Akihiko Odaki
2025-01-11  5:40 ` Akihiko Odaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).