drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits
Subsystems (2)
PATCH 1/1 drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits
From: "Leo (Sunpeng) Li" <[email protected]>
During a non-blocking commit, it is possible to return before the commit_tail work is queued (-ERESTARTSYS, for example).
Since a reference on the crtc commit object is obtained for the pending vblank event when preparing the commit, the above situation will leave us with an extra reference.
Therefore, if the commit_tail worker has not consumed the event at the end of a commit, release it's reference.
--- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +9 -0
@@ -3421,6 +3421,15 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);void __drm_atomic_helper_crtc_destroy_state (struct drm_crtc_state *state) {if (state->commit) { +/* +* In the event that a non-blocking commit returns +* -ERESTARTSYS before the commit_tail work is queued, we will +* have an extra reference to the commit object. Release it, if +* the event has not been consumed by the worker. +*/ +if (state->event) +drm_crtc_commit_put (state->commit); +kfree (state->commit->event); state->commit->event =NULL ;drm_crtc_commit_put (state->commit);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · On 2018-01-04 02:47 PM, [email protected] wrote:
From: "Leo (Sunpeng) Li" <[email protected]>
During a non-blocking commit, it is possible to return before the
commit_tailwork is queued (-ERESTARTSYS, for example).
Quoted 8 lines
Since a reference on the crtc commit object is obtained for the pending vblank event when preparing the commit, the above situation will leave us with an extra reference.
Therefore, if the
commit_tailworker has not consumed the event at the end of a commit, release it's reference.Signed-off-by Leo (Sunpeng) Li <[email protected]>
No expert on this but looks sane to me.
Harry
Quoted 15 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +2
-0@@ -3421,6 +3421,15 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);void __drm_atomic_helper_crtc_destroy_state (struct drm_crtc_state *state) {if (state->commit) { +/* +* In the event that a non-blocking commit returns
drivers/gpu/drm/drm_atomic_helper.c EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state); · line 3435
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +7
-0+* -ERESTARTSYS before the commit_tail work is queued, we will +* have an extra reference to the commit object. Release it, if +* the event has not been consumed by the worker. +*/ +if (state->event) +drm_crtc_commit_put (state->commit); +kfree (state->commit->event); state->commit->event =NULL ;drm_crtc_commit_put (state->commit);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Alex Deucher
AppliedQuoted 10 lines · Harry Wentland
Quoted 9 lines · On 2018-01-04 02:47 PM, [email protected] wrote:
From: "Leo (Sunpeng) Li" <[email protected]>
During a non-blocking commit, it is possible to return before the
commit_tailwork is queued (-ERESTARTSYS, for example).Since a reference on the crtc commit object is obtained for the pending vblank event when preparing the commit, the above situation will leave us with an extra reference.
Quoted 8 lines
Quoted 4 lines
Therefore, if the
commit_tailworker has not consumed the event at the end of a commit, release it's reference.Signed-off-by Leo (Sunpeng) Li <[email protected]>No expert on this but looks sane to me.
Acked-by Harry Wentland <[email protected]>
Pushed to drm-misc-next.
Thanks,
Alex
Quoted 24 lines
Harry
Quoted 21 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +9
-0@@ -3421,6 +3421,15 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);void __drm_atomic_helper_crtc_destroy_state (struct drm_crtc_state *state) {if (state->commit) { +/* +* In the event that a non-blocking commit returns +* -ERESTARTSYS before the commit_tail work is queued, we will +* have an extra reference to the commit object. Release it, if +* the event has not been consumed by the worker. +*/ +if (state->event) +drm_crtc_commit_put (state->commit); +
Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state); · line 3435
Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +0
-0kfree (state->commit->event); state->commit->event =NULL ;drm_crtc_commit_put (state->commit);_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 14 lines · Alex Deucher
Quoted 13 lines · Harry Wentland
Quoted 12 lines · On 2018-01-04 02:47 PM, [email protected] wrote:
From: "Leo (Sunpeng) Li" <[email protected]>
During a non-blocking commit, it is possible to return before the
commit_tailwork is queued (-ERESTARTSYS, for example).Since a reference on the crtc commit object is obtained for the pending vblank event when preparing the commit, the above situation will leave us with an extra reference.
Therefore, if the
commit_tailworker has not consumed the event at the end of a commit, release it's reference.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Leo (Sunpeng) Li <[email protected]>No expert on this but looks sane to me.
Acked-by Harry Wentland <[email protected]>Pushed to drm-misc-next.
This blows up all over the place in our CI:
https://bugs.freedesktop.org/show_bug.cgi?id=104566
I think as a leak fix it should also be pushed to -fixes. And we didn't really figure out what's wrong, so we're going with the quick revert until you folks are all awake.
Cheers, Daniel
Quoted 41 lines
Thanks,
Alex
Quoted 24 lines
Harry
Quoted 21 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +9
-0@@ -3421,6 +3421,15 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);void __drm_atomic_helper_crtc_destroy_state (struct drm_crtc_state *state) {if (state->commit) { +/* +* In the event that a non-blocking commit returns +* -ERESTARTSYS before the commit_tail work is queued, we will +* have an extra reference to the commit object. Release it, if +* the event has not been consumed by the worker. +*/ +if (state->event) +drm_crtc_commit_put (state->commit); +Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state); · line 3435
Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +0
-0kfree (state->commit->event); state->commit->event =NULL ;drm_crtc_commit_put (state->commit);_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerOp 08-01-18 om 22:30 schreef Harry Wentland:
Quoted 13 lines · On 2018-01-04 02:47 PM, [email protected] wrote:
Quoted 12 lines
From: "Leo (Sunpeng) Li" <[email protected]>
During a non-blocking commit, it is possible to return before the
commit_tailwork is queued (-ERESTARTSYS, for example).Since a reference on the crtc commit object is obtained for the pending vblank event when preparing the commit, the above situation will leave us with an extra reference.
Therefore, if the
commit_tailworker has not consumed the event at the end of a commit, release it's reference.
Quoted 6 lines
Quoted 1 line
Signed-off-by Leo (Sunpeng) Li <[email protected]>No expert on this but looks sane to me.
Acked-by Harry Wentland <[email protected]>Harry
Hey,
I've reverted the patch for now. I planned to apply it to the drm-misc-fixes branch with the appropriate commits referenced, but it is causing crashes on the kms_flip testcase.
https://bugs.freedesktop.org/show_bug.cgi?id=104566
I'll investigate it some more then send out a fixed patch. :)
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel