Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VC4 kernel framework driver - memory leak #122

Closed
nkichukov opened this issue Nov 29, 2017 · 6 comments
Closed

VC4 kernel framework driver - memory leak #122

nkichukov opened this issue Nov 29, 2017 · 6 comments

Comments

@nkichukov
Copy link

Hi all,
(redirected here via: raspberrypi#2293)

I have identified a memory leak in the VC4 kernel framework driver implementation on raspberry pi 3b. Details follow below:

kernel: 4.14.0-v7+
compiler: gcc-6.4
raspberry pi running in 32bit mode
OS: Gentoo Linux
Kernel configuration is attached, see below.

Whenever kodi(v17.6) is playing video, I can see that /proc/slabinfo reports number of kmalloc-128 constantly increasing and never releasing:
kmalloc-128 84916 84924 384 21 2 : tunables 0 0 0 : slabdata 4044 4044 0

In about 24 hours this has taken up about 600MB of the memory and the Pi needs to be restarted to avoid swapping. If I stop kodi playback and leave it idle, the kmalloc-128 remains the same until playback is resumed which starts increasing again. If I stop the X server and kodi altogether, the memory is not released.

The memleak pattern is like the one below

(from /sys/kernel/debug/kmemleak):

unreferenced object 0x95ce16c0 (size 128):
comm "kodi.bin", pid 2075, jiffies 891363 (age 2338.023s)
hex dump (first 32 bytes):
01 00 00 00 5c ed 1e 7f 00 00 00 00 00 00 00 00 ...............
d0 16 ce 95 d0 16 ce 95 00 3a fb b4 00 00 00 00 .........:......
backtrace:
[<802827c8>] kmem_cache_alloc_trace+0x234/0x2f8
[<7f1e461c>] vc4_submit_cl_ioctl+0x730/0xb50 [vc4]
[<7f0d796c>] drm_ioctl_kernel+0x78/0xb8 [drm]
[<7f0d7cd4>] drm_ioctl+0x1b4/0x37c [drm]
[<802ac090>] do_vfs_ioctl+0xb0/0x8b4
[<802ac8d8>] SyS_ioctl+0x44/0x6c
[<80108140>] ret_fast_syscall+0x0/0x28
[] 0xffffffff

Let me know if additional information is required to track this issue down.

rpi-4.14.y-kernel_configuration_file.gz

Saw another issue still open here for memory leak, but what I report happens with pretty high CMA, 256MB, so not related to low CMA setting. Also the trace is different.

Thank you,
-Nikolay

@stschake
Copy link

I think it's leaking the dma_fences, certainly the "01" refcount in the hexdump looks suspiciously like them. Could you try the attached patch?

0001-drm-vc4-Release-fence-after-signalling.txt

(Sorry, filename is off because GitHub, ridiculously so, does not allow attaching .patch files)

@nkichukov
Copy link
Author

Hello Stefan,
thank you for the quick response! It fixed the huge memleak issue! Thank you very much!

However, another memleak appeared(it may already have been there before, I just did not see it), see below:

unreferenced object 0x842aa340 (size 128):
comm "X", pid 2009, jiffies 7034334 (age 301.527s)
hex dump (first 32 bytes):
50 3f eb b6 01 00 00 00 00 00 00 00 00 00 00 00 P?..............
50 a3 2a 84 50 a3 2a 84 00 00 00 00 00 00 00 00 P..P..........
backtrace:
[<802827c8>] kmem_cache_alloc_trace+0x234/0x2f8
[<7f167ae8>] drm_atomic_helper_setup_commit+0x1cc/0x3b0 [drm_kms_helper]
[<7f1e2aa0>] vc4_atomic_commit+0x30/0x130 [vc4]
[<7f0f44a0>] drm_atomic_commit+0x5c/0x68 [drm]
[<7f0f5700>] drm_atomic_connector_commit_dpms+0xf8/0x108 [drm]
[<7f0fae64>] drm_mode_obj_set_property_ioctl+0x1bc/0x2b4 [drm]
[<7f0f9820>] drm_mode_connector_property_set_ioctl+0x48/0x50 [drm]
[<7f0e296c>] drm_ioctl_kernel+0x78/0xb8 [drm]
[<7f0e2cd4>] drm_ioctl+0x1b4/0x37c [drm]
[<802ac090>] do_vfs_ioctl+0xb0/0x8b4
[<802ac8d8>] SyS_ioctl+0x44/0x6c
[<80108140>] ret_fast_syscall+0x0/0x28
[] 0xffffffff
unreferenced object 0x83ee2340 (size 128):
comm "X", pid 2009, jiffies 7044631 (age 291.296s)
hex dump (first 32 bytes):
50 3f eb b6 01 00 00 00 00 00 00 00 00 00 00 00 P?..............
50 23 ee 83 50 23 ee 83 00 00 00 00 00 00 00 00 P#..P#..........
backtrace:
[<802827c8>] kmem_cache_alloc_trace+0x234/0x2f8
[<7f167ae8>] drm_atomic_helper_setup_commit+0x1cc/0x3b0 [drm_kms_helper]
[<7f1e2aa0>] vc4_atomic_commit+0x30/0x130 [vc4]
[<7f0f44a0>] drm_atomic_commit+0x5c/0x68 [drm]
[<7f0f5700>] drm_atomic_connector_commit_dpms+0xf8/0x108 [drm]
[<7f0fae64>] drm_mode_obj_set_property_ioctl+0x1bc/0x2b4 [drm]
[<7f0f9820>] drm_mode_connector_property_set_ioctl+0x48/0x50 [drm]
[<7f0e296c>] drm_ioctl_kernel+0x78/0xb8 [drm]
[<7f0e2cd4>] drm_ioctl+0x1b4/0x37c [drm]
[<802ac090>] do_vfs_ioctl+0xb0/0x8b4
[<802ac8d8>] SyS_ioctl+0x44/0x6c
[<80108140>] ret_fast_syscall+0x0/0x28
[] 0xffffffff
unreferenced object 0x84bbe040 (size 128):
comm "X", pid 2009, jiffies 7049751 (age 286.242s)
hex dump (first 32 bytes):
50 3f eb b6 01 00 00 00 00 00 00 00 00 00 00 00 P?..............
50 e0 bb 84 50 e0 bb 84 00 00 00 00 00 00 00 00 P...P...........
backtrace:
[<802827c8>] kmem_cache_alloc_trace+0x234/0x2f8
[<7f167ae8>] drm_atomic_helper_setup_commit+0x1cc/0x3b0 [drm_kms_helper]
[<7f1e2aa0>] vc4_atomic_commit+0x30/0x130 [vc4]
[<7f0f44a0>] drm_atomic_commit+0x5c/0x68 [drm]
[<7f0f5700>] drm_atomic_connector_commit_dpms+0xf8/0x108 [drm]
[<7f0fae64>] drm_mode_obj_set_property_ioctl+0x1bc/0x2b4 [drm]
[<7f0f9820>] drm_mode_connector_property_set_ioctl+0x48/0x50 [drm]
[<7f0e296c>] drm_ioctl_kernel+0x78/0xb8 [drm]
[<7f0e2cd4>] drm_ioctl+0x1b4/0x37c [drm]
[<802ac090>] do_vfs_ioctl+0xb0/0x8b4
[<802ac8d8>] SyS_ioctl+0x44/0x6c
[<80108140>] ret_fast_syscall+0x0/0x28
[] 0xffffffff

Thank you,
-Nik

@stschake
Copy link

That is an unrelated leak (another refcounting fail, 01 00..)

@nkichukov
Copy link
Author

Hello Stefan,
If this is unrelated to the vc4 kernel driver, do I report this to the raspberrypi kernel developers? Or (if vc4 related) would you like to have a separate issue for this leak here(anholt) and track separately so this can be closed and the patch merged?

Thank you,
-Nik

@lategoodbye
Copy link

Since this is also vc4 related, it should be reported here in this repository and not to the raspberrypi guys.

@nkichukov
Copy link
Author

Thank you Stefan. The originally reported issue was resolved by the provided patch. I am closing the case and will open a new one for the second memory leak.

fengguang pushed a commit to 0day-ci/linux that referenced this issue Dec 4, 2017
We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt/linux#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
pelwell pushed a commit to raspberrypi/linux that referenced this issue Jan 2, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Jan 8, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Jan 10, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Jan 17, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Jan 25, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Jan 31, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
TiejunChina pushed a commit to TiejunChina/linux that referenced this issue Feb 2, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Feb 5, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Feb 5, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
popcornmix pushed a commit to raspberrypi/linux that referenced this issue Feb 9, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
TiejunChina pushed a commit to TiejunChina/linux that referenced this issue Feb 14, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
damentz pushed a commit to zen-kernel/zen-kernel that referenced this issue Feb 24, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt/linux#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
woodsts pushed a commit to woodsts/linux-stable that referenced this issue Feb 25, 2018
[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt/linux#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista-2.4 that referenced this issue Apr 4, 2018
Source: Kernel.org
MR: 93353
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-4.14.y
ChangeID: 4826773306b5275055632a59eda7957ae543eecd
Description:

[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt/linux#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
johalun pushed a commit to FreeBSDDesktop/kms-drm that referenced this issue Apr 15, 2018
We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt/linux#122
Fixes: cdec4d361323 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista-2.4 that referenced this issue Apr 21, 2018
Source: Kernel.org
MR: 93353
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-4.14.y
ChangeID: 4826773306b5275055632a59eda7957ae543eecd
Description:

[ Upstream commit babc811 ]

We were never releasing the initial fence reference that is obtained
through dma_fence_init.

Link: anholt/linux#122
Fixes: cdec4d3 ("drm/vc4: Expose dma-buf fences for V3D rendering.")
Signed-off-by: Stefan Schake <stschake@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1512236444-301-1-git-send-email-stschake@gmail.com
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants