qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug
@ 2018-10-29  6:29 Li Qiang
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized Li Qiang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Li Qiang @ 2018-10-29  6:29 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang

The first corrent the refcount and second fix a memory leak.

Li Qiang (2):
  nvme: don't unref ctrl_mem when device unrealized
  nvme: free cmbuf in nvme_exit

 hw/block/nvme.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.11.0

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

* [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized
  2018-10-29  6:29 [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Li Qiang
@ 2018-10-29  6:29 ` Li Qiang
  2018-11-05 14:57   ` Li Qiang
  2018-11-06 15:58   ` Igor Mammedov
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 2/2] nvme: free cmbuf in nvme_exit Li Qiang
  2018-11-07  9:54 ` [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Kevin Wolf
  2 siblings, 2 replies; 7+ messages in thread
From: Li Qiang @ 2018-10-29  6:29 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang

Currently, when hotplug/unhotplug nvme device, it will cause an
assert in object.c. Following is the backtrack:

ERROR:qom/object.c:981:object_unref: assertion failed: (obj->ref > 0)

Thread 2 "qemu-system-x86" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffcbd32700 (LWP 18844)]
0x00007fffdb9e4fff in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
/lib/x86_64-linux-gnu/libglib-2.0.so.0
/lib/x86_64-linux-gnu/libglib-2.0.so.0
qom/object.c:981
/home/liqiang02/qemu-upstream/qemu/memory.c:1732
/home/liqiang02/qemu-upstream/qemu/memory.c:285
util/qemu-thread-posix.c:504
/lib/x86_64-linux-gnu/libpthread.so.0

This is caused by memory_region_unref in nvme_exit.

Remove it to make the PCIdevice refcount correct.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 hw/block/nvme.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index fc7dacb816..359a06d0ad 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1331,9 +1331,6 @@ static void nvme_exit(PCIDevice *pci_dev)
     g_free(n->namespaces);
     g_free(n->cq);
     g_free(n->sq);
-    if (n->cmbsz) {
-        memory_region_unref(&n->ctrl_mem);
-    }
 
     msix_uninit_exclusive_bar(pci_dev);
 }
-- 
2.11.0

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

* [Qemu-devel] [PATCH 2/2] nvme: free cmbuf in nvme_exit
  2018-10-29  6:29 [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Li Qiang
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized Li Qiang
@ 2018-10-29  6:29 ` Li Qiang
  2018-10-29 12:32   ` Philippe Mathieu-Daudé
  2018-11-07  9:54 ` [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Kevin Wolf
  2 siblings, 1 reply; 7+ messages in thread
From: Li Qiang @ 2018-10-29  6:29 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-block, qemu-devel, Li Qiang

This avoid a memory leak in unhotplug nvme device.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 hw/block/nvme.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 359a06d0ad..09d7c90259 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1332,6 +1332,9 @@ static void nvme_exit(PCIDevice *pci_dev)
     g_free(n->cq);
     g_free(n->sq);
 
+    if (n->cmb_size_mb) {
+        g_free(n->cmbuf);
+    }
     msix_uninit_exclusive_bar(pci_dev);
 }
 
-- 
2.11.0

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

* Re: [Qemu-devel] [PATCH 2/2] nvme: free cmbuf in nvme_exit
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 2/2] nvme: free cmbuf in nvme_exit Li Qiang
@ 2018-10-29 12:32   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-29 12:32 UTC (permalink / raw)
  To: Li Qiang, keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block

On 29/10/18 7:29, Li Qiang wrote:
> This avoid a memory leak in unhotplug nvme device.
> 
> Signed-off-by: Li Qiang <liq3ea@gmail.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   hw/block/nvme.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 359a06d0ad..09d7c90259 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1332,6 +1332,9 @@ static void nvme_exit(PCIDevice *pci_dev)
>       g_free(n->cq);
>       g_free(n->sq);
>   
> +    if (n->cmb_size_mb) {
> +        g_free(n->cmbuf);
> +    }
>       msix_uninit_exclusive_bar(pci_dev);
>   }
>   
> 

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

* Re: [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized Li Qiang
@ 2018-11-05 14:57   ` Li Qiang
  2018-11-06 15:58   ` Igor Mammedov
  1 sibling, 0 replies; 7+ messages in thread
From: Li Qiang @ 2018-11-05 14:57 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-block, Qemu Developers

Ping...

I think this is a serious issue, can go 3.1

Thanks,
Li Qiang

Li Qiang <liq3ea@gmail.com> 于2018年10月29日周一 下午2:29写道:

> Currently, when hotplug/unhotplug nvme device, it will cause an
> assert in object.c. Following is the backtrack:
>
> ERROR:qom/object.c:981:object_unref: assertion failed: (obj->ref > 0)
>
> Thread 2 "qemu-system-x86" received signal SIGABRT, Aborted.
> [Switching to Thread 0x7fffcbd32700 (LWP 18844)]
> 0x00007fffdb9e4fff in raise () from /lib/x86_64-linux-gnu/libc.so.6
> (gdb) bt
> /lib/x86_64-linux-gnu/libglib-2.0.so.0
> /lib/x86_64-linux-gnu/libglib-2.0.so.0
> qom/object.c:981
> /home/liqiang02/qemu-upstream/qemu/memory.c:1732
> /home/liqiang02/qemu-upstream/qemu/memory.c:285
> util/qemu-thread-posix.c:504
> /lib/x86_64-linux-gnu/libpthread.so.0
>
> This is caused by memory_region_unref in nvme_exit.
>
> Remove it to make the PCIdevice refcount correct.
>
> Signed-off-by: Li Qiang <liq3ea@gmail.com>
> ---
>  hw/block/nvme.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index fc7dacb816..359a06d0ad 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1331,9 +1331,6 @@ static void nvme_exit(PCIDevice *pci_dev)
>      g_free(n->namespaces);
>      g_free(n->cq);
>      g_free(n->sq);
> -    if (n->cmbsz) {
> -        memory_region_unref(&n->ctrl_mem);
> -    }
>
>      msix_uninit_exclusive_bar(pci_dev);
>  }
> --
> 2.11.0
>
>

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

* Re: [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized Li Qiang
  2018-11-05 14:57   ` Li Qiang
@ 2018-11-06 15:58   ` Igor Mammedov
  1 sibling, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2018-11-06 15:58 UTC (permalink / raw)
  To: Li Qiang; +Cc: keith.busch, kwolf, mreitz, qemu-devel, qemu-block

On Sun, 28 Oct 2018 23:29:40 -0700
Li Qiang <liq3ea@gmail.com> wrote:

> Currently, when hotplug/unhotplug nvme device, it will cause an
> assert in object.c. Following is the backtrack:
> 
> ERROR:qom/object.c:981:object_unref: assertion failed: (obj->ref > 0)
> 
> Thread 2 "qemu-system-x86" received signal SIGABRT, Aborted.
> [Switching to Thread 0x7fffcbd32700 (LWP 18844)]
> 0x00007fffdb9e4fff in raise () from /lib/x86_64-linux-gnu/libc.so.6
> (gdb) bt
> /lib/x86_64-linux-gnu/libglib-2.0.so.0
> /lib/x86_64-linux-gnu/libglib-2.0.so.0
> qom/object.c:981
> /home/liqiang02/qemu-upstream/qemu/memory.c:1732
> /home/liqiang02/qemu-upstream/qemu/memory.c:285
> util/qemu-thread-posix.c:504
> /lib/x86_64-linux-gnu/libpthread.so.0
> 
> This is caused by memory_region_unref in nvme_exit.
> 
> Remove it to make the PCIdevice refcount correct.
> 
> Signed-off-by: Li Qiang <liq3ea@gmail.com>
nvme device holds a reference to ctrl_mem MemoryRegion as a parent
so MemoryRegion will be destroyed later during destruction of
nvme object when its cildren are un-parented.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/block/nvme.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index fc7dacb816..359a06d0ad 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1331,9 +1331,6 @@ static void nvme_exit(PCIDevice *pci_dev)
>      g_free(n->namespaces);
>      g_free(n->cq);
>      g_free(n->sq);
> -    if (n->cmbsz) {
> -        memory_region_unref(&n->ctrl_mem);
> -    }
>  
>      msix_uninit_exclusive_bar(pci_dev);
>  }

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

* Re: [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug
  2018-10-29  6:29 [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Li Qiang
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized Li Qiang
  2018-10-29  6:29 ` [Qemu-devel] [PATCH 2/2] nvme: free cmbuf in nvme_exit Li Qiang
@ 2018-11-07  9:54 ` Kevin Wolf
  2 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2018-11-07  9:54 UTC (permalink / raw)
  To: Li Qiang; +Cc: keith.busch, mreitz, qemu-block, qemu-devel

Am 29.10.2018 um 07:29 hat Li Qiang geschrieben:
> The first corrent the refcount and second fix a memory leak.

Thanks, applied to the block branch.

Kevin

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

end of thread, other threads:[~2018-11-07  9:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-29  6:29 [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Li Qiang
2018-10-29  6:29 ` [Qemu-devel] [PATCH 1/2] nvme: don't unref ctrl_mem when device unrealized Li Qiang
2018-11-05 14:57   ` Li Qiang
2018-11-06 15:58   ` Igor Mammedov
2018-10-29  6:29 ` [Qemu-devel] [PATCH 2/2] nvme: free cmbuf in nvme_exit Li Qiang
2018-10-29 12:32   ` Philippe Mathieu-Daudé
2018-11-07  9:54 ` [Qemu-devel] [PATCH 0/2] nvme: fix two issues in nvme unhotplug Kevin Wolf

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).