dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/virtio: clean out_fence on complete_submit
@ 2023-09-12  6:08 José Pekkarinen
  2023-09-19 11:12 ` José Pekkarinen
  2023-09-20 21:13 ` Dmitry Osipenko
  0 siblings, 2 replies; 3+ messages in thread
From: José Pekkarinen @ 2023-09-12  6:08 UTC (permalink / raw)
  To: airlied, kraxel, skhan
  Cc: linux-kernel-mentees, linux-kernel, dri-devel,
	José Pekkarinen, gurchetansingh, virtualization,
	christian.koenig

The removed line prevents the following cleanup function
to execute a dma_fence_put on the out_fence to free its
memory, producing the following output in kmemleak:

unreferenced object 0xffff888126d8ee00 (size 128):
  comm "kwin_wayland", pid 981, jiffies 4295380296 (age 390.060s)
  hex dump (first 32 bytes):
    c8 a1 c2 27 81 88 ff ff e0 14 a9 c0 ff ff ff ff  ...'............
    30 1a e1 2e a6 00 00 00 28 fc 5b 17 81 88 ff ff  0.......(.[.....
  backtrace:
    [<0000000011655661>] kmalloc_trace+0x26/0xa0
    [<0000000055f15b82>] virtio_gpu_fence_alloc+0x47/0xc0 [virtio_gpu]
    [<00000000fa6d96f9>] virtio_gpu_execbuffer_ioctl+0x1a8/0x800 [virtio_gpu]
    [<00000000e6cb5105>] drm_ioctl_kernel+0x169/0x240 [drm]
    [<000000005ad33e27>] drm_ioctl+0x399/0x6b0 [drm]
    [<00000000a19dbf65>] __x64_sys_ioctl+0xc5/0x100
    [<0000000011fa801e>] do_syscall_64+0x5b/0xc0
    [<0000000065c76d8a>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
unreferenced object 0xffff888121930500 (size 128):
  comm "kwin_wayland", pid 981, jiffies 4295380313 (age 390.096s)
  hex dump (first 32 bytes):
    c8 a1 c2 27 81 88 ff ff e0 14 a9 c0 ff ff ff ff  ...'............
    f9 ec d7 2f a6 00 00 00 28 fc 5b 17 81 88 ff ff  .../....(.[.....
  backtrace:
    [<0000000011655661>] kmalloc_trace+0x26/0xa0
    [<0000000055f15b82>] virtio_gpu_fence_alloc+0x47/0xc0 [virtio_gpu]
    [<00000000fa6d96f9>] virtio_gpu_execbuffer_ioctl+0x1a8/0x800 [virtio_gpu]
    [<00000000e6cb5105>] drm_ioctl_kernel+0x169/0x240 [drm]
    [<000000005ad33e27>] drm_ioctl+0x399/0x6b0 [drm]
    [<00000000a19dbf65>] __x64_sys_ioctl+0xc5/0x100
    [<0000000011fa801e>] do_syscall_64+0x5b/0xc0
    [<0000000065c76d8a>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[...]

This memleak will grow quickly, being possible to see the
following line in dmesg after few minutes of life in the
virtual machine:

[  706.217388] kmemleak: 10731 new suspected memory leaks (see /sys/kernel/debug/kmemleak)

The patch will remove the line to allow the cleanup
function do its job.

Signed-off-by: José Pekkarinen <jose.pekkarinen@foxhound.fi>
---
 drivers/gpu/drm/virtio/virtgpu_submit.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_submit.c b/drivers/gpu/drm/virtio/virtgpu_submit.c
index 3c00135ead45..5c514946bbad 100644
--- a/drivers/gpu/drm/virtio/virtgpu_submit.c
+++ b/drivers/gpu/drm/virtio/virtgpu_submit.c
@@ -361,7 +361,6 @@ static void virtio_gpu_complete_submit(struct virtio_gpu_submit *submit)
 	submit->buf = NULL;
 	submit->buflist = NULL;
 	submit->sync_file = NULL;
-	submit->out_fence = NULL;
 	submit->out_fence_fd = -1;
 }
 
-- 
2.39.2


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

* Re: [PATCH] drm/virtio: clean out_fence on complete_submit
  2023-09-12  6:08 [PATCH] drm/virtio: clean out_fence on complete_submit José Pekkarinen
@ 2023-09-19 11:12 ` José Pekkarinen
  2023-09-20 21:13 ` Dmitry Osipenko
  1 sibling, 0 replies; 3+ messages in thread
From: José Pekkarinen @ 2023-09-19 11:12 UTC (permalink / raw)
  To: airlied, kraxel, skhan
  Cc: linux-kernel, dri-devel, virtualization, gurchetansingh,
	linux-kernel-mentees, christian.koenig

On 2023-09-12 09:08, José Pekkarinen wrote:
> The removed line prevents the following cleanup function
> to execute a dma_fence_put on the out_fence to free its
> memory, producing the following output in kmemleak:
> 
> unreferenced object 0xffff888126d8ee00 (size 128):
>   comm "kwin_wayland", pid 981, jiffies 4295380296 (age 390.060s)
>   hex dump (first 32 bytes):
>     c8 a1 c2 27 81 88 ff ff e0 14 a9 c0 ff ff ff ff  ...'............
>     30 1a e1 2e a6 00 00 00 28 fc 5b 17 81 88 ff ff  0.......(.[.....
>   backtrace:
>     [<0000000011655661>] kmalloc_trace+0x26/0xa0
>     [<0000000055f15b82>] virtio_gpu_fence_alloc+0x47/0xc0 [virtio_gpu]
>     [<00000000fa6d96f9>] virtio_gpu_execbuffer_ioctl+0x1a8/0x800 
> [virtio_gpu]
>     [<00000000e6cb5105>] drm_ioctl_kernel+0x169/0x240 [drm]
>     [<000000005ad33e27>] drm_ioctl+0x399/0x6b0 [drm]
>     [<00000000a19dbf65>] __x64_sys_ioctl+0xc5/0x100
>     [<0000000011fa801e>] do_syscall_64+0x5b/0xc0
>     [<0000000065c76d8a>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> unreferenced object 0xffff888121930500 (size 128):
>   comm "kwin_wayland", pid 981, jiffies 4295380313 (age 390.096s)
>   hex dump (first 32 bytes):
>     c8 a1 c2 27 81 88 ff ff e0 14 a9 c0 ff ff ff ff  ...'............
>     f9 ec d7 2f a6 00 00 00 28 fc 5b 17 81 88 ff ff  .../....(.[.....
>   backtrace:
>     [<0000000011655661>] kmalloc_trace+0x26/0xa0
>     [<0000000055f15b82>] virtio_gpu_fence_alloc+0x47/0xc0 [virtio_gpu]
>     [<00000000fa6d96f9>] virtio_gpu_execbuffer_ioctl+0x1a8/0x800 
> [virtio_gpu]
>     [<00000000e6cb5105>] drm_ioctl_kernel+0x169/0x240 [drm]
>     [<000000005ad33e27>] drm_ioctl+0x399/0x6b0 [drm]
>     [<00000000a19dbf65>] __x64_sys_ioctl+0xc5/0x100
>     [<0000000011fa801e>] do_syscall_64+0x5b/0xc0
>     [<0000000065c76d8a>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> [...]
> 
> This memleak will grow quickly, being possible to see the
> following line in dmesg after few minutes of life in the
> virtual machine:
> 
> [  706.217388] kmemleak: 10731 new suspected memory leaks (see
> /sys/kernel/debug/kmemleak)
> 
> The patch will remove the line to allow the cleanup
> function do its job.
> 
> Signed-off-by: José Pekkarinen <jose.pekkarinen@foxhound.fi>
> ---
>  drivers/gpu/drm/virtio/virtgpu_submit.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_submit.c
> b/drivers/gpu/drm/virtio/virtgpu_submit.c
> index 3c00135ead45..5c514946bbad 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_submit.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_submit.c
> @@ -361,7 +361,6 @@ static void virtio_gpu_complete_submit(struct
> virtio_gpu_submit *submit)
>  	submit->buf = NULL;
>  	submit->buflist = NULL;
>  	submit->sync_file = NULL;
> -	submit->out_fence = NULL;
>  	submit->out_fence_fd = -1;
>  }

     Ping.

     José.

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

* Re: [PATCH] drm/virtio: clean out_fence on complete_submit
  2023-09-12  6:08 [PATCH] drm/virtio: clean out_fence on complete_submit José Pekkarinen
  2023-09-19 11:12 ` José Pekkarinen
@ 2023-09-20 21:13 ` Dmitry Osipenko
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Osipenko @ 2023-09-20 21:13 UTC (permalink / raw)
  To: José Pekkarinen, airlied, kraxel, skhan
  Cc: linux-kernel, dri-devel, virtualization, gurchetansingh,
	linux-kernel-mentees, christian.koenig

On 9/12/23 09:08, José Pekkarinen wrote:
> The removed line prevents the following cleanup function
> to execute a dma_fence_put on the out_fence to free its
> memory, producing the following output in kmemleak:
> 
> unreferenced object 0xffff888126d8ee00 (size 128):
>   comm "kwin_wayland", pid 981, jiffies 4295380296 (age 390.060s)
>   hex dump (first 32 bytes):
>     c8 a1 c2 27 81 88 ff ff e0 14 a9 c0 ff ff ff ff  ...'............
>     30 1a e1 2e a6 00 00 00 28 fc 5b 17 81 88 ff ff  0.......(.[.....
>   backtrace:
>     [<0000000011655661>] kmalloc_trace+0x26/0xa0
>     [<0000000055f15b82>] virtio_gpu_fence_alloc+0x47/0xc0 [virtio_gpu]
>     [<00000000fa6d96f9>] virtio_gpu_execbuffer_ioctl+0x1a8/0x800 [virtio_gpu]
>     [<00000000e6cb5105>] drm_ioctl_kernel+0x169/0x240 [drm]
>     [<000000005ad33e27>] drm_ioctl+0x399/0x6b0 [drm]
>     [<00000000a19dbf65>] __x64_sys_ioctl+0xc5/0x100
>     [<0000000011fa801e>] do_syscall_64+0x5b/0xc0
>     [<0000000065c76d8a>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> unreferenced object 0xffff888121930500 (size 128):
>   comm "kwin_wayland", pid 981, jiffies 4295380313 (age 390.096s)
>   hex dump (first 32 bytes):
>     c8 a1 c2 27 81 88 ff ff e0 14 a9 c0 ff ff ff ff  ...'............
>     f9 ec d7 2f a6 00 00 00 28 fc 5b 17 81 88 ff ff  .../....(.[.....
>   backtrace:
>     [<0000000011655661>] kmalloc_trace+0x26/0xa0
>     [<0000000055f15b82>] virtio_gpu_fence_alloc+0x47/0xc0 [virtio_gpu]
>     [<00000000fa6d96f9>] virtio_gpu_execbuffer_ioctl+0x1a8/0x800 [virtio_gpu]
>     [<00000000e6cb5105>] drm_ioctl_kernel+0x169/0x240 [drm]
>     [<000000005ad33e27>] drm_ioctl+0x399/0x6b0 [drm]
>     [<00000000a19dbf65>] __x64_sys_ioctl+0xc5/0x100
>     [<0000000011fa801e>] do_syscall_64+0x5b/0xc0
>     [<0000000065c76d8a>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> [...]
> 
> This memleak will grow quickly, being possible to see the
> following line in dmesg after few minutes of life in the
> virtual machine:
> 
> [  706.217388] kmemleak: 10731 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
> 
> The patch will remove the line to allow the cleanup
> function do its job.
> 
> Signed-off-by: José Pekkarinen <jose.pekkarinen@foxhound.fi>
> ---
>  drivers/gpu/drm/virtio/virtgpu_submit.c | 1 -
>  1 file changed, 1 deletion(-)

Added fixes tag and pushed to misc-fixes

-- 
Best regards,
Dmitry


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

end of thread, other threads:[~2023-09-20 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12  6:08 [PATCH] drm/virtio: clean out_fence on complete_submit José Pekkarinen
2023-09-19 11:12 ` José Pekkarinen
2023-09-20 21:13 ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox