All of lore.kernel.org
 help / color / mirror / Atom feed
* QEMU device refcounting when device creates a container MR
@ 2022-03-09 10:33 Peter Maydell
  2022-03-09 10:40 ` Philippe Mathieu-Daudé
  2022-03-09 16:21 ` Paolo Bonzini
  0 siblings, 2 replies; 13+ messages in thread
From: Peter Maydell @ 2022-03-09 10:33 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Paolo Bonzini

Hi; does anybody know how device reference counting is supposed
to work when the device creates a "container" MemoryRegion which
it then puts some of its own subregions in to?

As far as I can see when you do memory_region_add_subregion it
increases the refcount on the owner of the subregion. So if a
device creates a container MR in its own init or realize method
and adds sub-MRs that it owns to that container, this increases
the refcount on the device permanently, and so the device won't
ever be deinited.

As a specific example, the usb-chipidea device does this in its
init method, so if you run the arm device-introspect-test under
leak-sanitizer it complains about a memory leak that happens
when the device is put through the "init-introspect-deref" cycle.

-- PMM


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

end of thread, other threads:[~2022-03-18 17:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 10:33 QEMU device refcounting when device creates a container MR Peter Maydell
2022-03-09 10:40 ` Philippe Mathieu-Daudé
2022-03-10 13:19   ` Peter Xu
2022-03-10 13:45     ` Peter Maydell
2022-03-11  2:19       ` Peter Xu
2022-03-09 16:21 ` Paolo Bonzini
2022-03-09 16:53   ` Peter Maydell
2022-03-09 16:56     ` Peter Maydell
2022-03-10 15:36       ` Igor Mammedov
2022-03-10 16:05         ` Peter Maydell
2022-03-10 16:30           ` Igor Mammedov
2022-03-10 17:11             ` Peter Maydell
2022-03-18 17:13               ` Igor Mammedov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.