drm/syncobj: Don't leak fences when WAIT_FOR_SUBMIT is set
Subsystems (3)
PATCH 1/1 drm/syncobj: Don't leak fences when WAIT_FOR_SUBMIT is set
We attempt to get fences earlier in the hopes that everything will already have fences and no callbacks will be needed. If we do succeed in getting a fence, getting one a second time will result in a duplicate ref with no unref. This is causing memory leaks in Vulkan applications that create a lot of fences; playing for a few hours can, apparently, bring down the system.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
--- drivers/gpu/drm/drm_syncobj.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/drm_syncobj.c +5 -0
@@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, {int ret; +WARN_ON (*fence); + *fence =drm_syncobj_fence_get (syncobj);if (*fence)return 1 ;
@@ -743,6 +745,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,if (flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT ) {for (i =0 ; i < count; ++i) { +if (entries[i].fence) +continue ; + drm_syncobj_fence_get_or_add_callback(syncobjs[i], &entries[i].fence, &entries[i].syncobj_cb,
Signature · 1 line
2.17.1
Quoting Jason Ekstrand (2018-09-26 08:17:03)
Quoted 19 lines
We attempt to get fences earlier in the hopes that everything will already have fences and no callbacks will be needed. If we do succeed in getting a fence, getting one a second time will result in a duplicate ref with no unref. This is causing memory leaks in Vulkan applications that create a lot of fences; playing for a few hours can, apparently, bring down the system.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
Signed-off-by Jason Ekstrand <[email protected]>--- drivers/gpu/drm/drm_syncobj.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/drm_syncobj.c +0
-0
drivers/gpu/drm/drm_syncobj.c static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, · line 100
Quoted 4 lines
drivers/gpu/drm/drm_syncobj.c +1
-0@@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, {int ret; +WARN_ON (*fence);
I would have just put if (*fence) return; since the function is tied to the array_wait implementation.
-Chris
Quoted 22 lines · Chris Wilson
Quoting Jason Ekstrand (2018-09-26 08:17:03)
Quoted 7 lines
We attempt to get fences earlier in the hopes that everything will already have fences and no callbacks will be needed. If we do succeed in getting a fence, getting one a second time will result in a duplicate ref with no unref. This is causing memory leaks in Vulkan applications that create a lot of fences; playing for a few hours can, apparently, bring down the system.
Review
Quoted 8 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
Signed-off-by Jason Ekstrand <[email protected]>--- drivers/gpu/drm/drm_syncobj.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/drm_syncobj.cdrivers/gpu/drm/drm_syncobj.c static int
Quoted 4 lines
index
adb3cb27d31e..759278fef35a100644drivers/gpu/drm/drm_syncobj.c +0
-0@@ -97,6 +97,8 @@ static intdrm_syncobj_fence_get_or_add_callback(struct
drm_syncobj*syncobj,
Quoted 8 lines
drivers/gpu/drm/drm_syncobj.c static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, · line 100
Quoted 4 lines
drivers/gpu/drm/drm_syncobj.c +1
-0{int ret; +WARN_ON (*fence);I would have just put if (*fence) return; since the function is tied to the
array_waitimplementation.
I considered doing that but marginally liked this better. If you have a preference, I'm happy to change itl.
--Jason
Quoted 3 lines
Reviewed-by Chris Wilson <[email protected]>-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoting Jason Ekstrand (2018-09-26 10:43:59)
Quoted 33 lines · Chris Wilson
Quoting Jason Ekstrand (2018-09-26 08:17:03)
> We attempt to get fences earlier in the hopes that everything will
> already have fences and no callbacks will be needed. If we do succeed
> in getting a fence, getting one a second time will result in a duplicate
> ref with no unref. This is causing memory leaks in Vulkan applications
> that create a lot of fences; playing for a few hours can, apparently,
> bring down the system.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
> Signed-off-by: Jason Ekstrand <[email protected]>
> Cc: [email protected]
> ---
> drivers/gpu/drm/drm_syncobj.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/
drm_syncobj.c
> index adb3cb27d31e..759278fef35a 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct
drm_syncobj *syncobj,
> {
> int ret;
>
> + WARN_ON(*fence);
I would have just put if (*fence) return; since the function is tied to
the array_wait implementation.Quoted 2 lines
I considered doing that but marginally liked this better. If you have a preference, I'm happy to change itl.
Patch works, the difference is insignificant, land the patch and close the bug.
-Chris
Sean Paul
AppliedQuoted 9 lines · Jason Ekstrand
We attempt to get fences earlier in the hopes that everything will already have fences and no callbacks will be needed. If we do succeed in getting a fence, getting one a second time will result in a duplicate ref with no unref. This is causing memory leaks in Vulkan applications that create a lot of fences; playing for a few hours can, apparently, bring down the system.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
Signed-off-by Jason Ekstrand <[email protected]>
Pushed to drm-misc-fixes, thanks!
Sean
Quoted 35 lines
--- drivers/gpu/drm/drm_syncobj.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/drm_syncobj.c +5
-0@@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, {int ret; +WARN_ON (*fence); + *fence =drm_syncobj_fence_get (syncobj);if (*fence)return 1 ;@@ -743,6 +745,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,if (flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT ) {for (i =0 ; i < count; ++i) { +if (entries[i].fence) +continue ; + drm_syncobj_fence_get_or_add_callback(syncobjs[i], &entries[i].fence, &entries[i].syncobj_cb,Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS