Skip to contentSkip to conversation

drm/i915: Fix memleak in runtime wakeref tracking

PATCH In review Mika Kuoppala 4 participants 6 messages Jun 27, 2019 – Jun 28, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Fix memleak in runtime wakeref tracking

If we untrack wakerefs, the actual count may reach zero. However the krealloced owners array is still there and needs to be taken care of. Free the owners unconditionally to fix the leak.

Fixes dbf99c1f8c7e ("drm/i915: Force printing wakeref tacking during pm_cleanup")
Cc Juha-Pekka Heikkila <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Imre Deak <[email protected]>
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +4 -6
index 502c54428570..8d1aebc3e857 100644
@@ -221,13 +221,11 @@ __untrack_all_wakerefs(struct intel_runtime_pm_debug *debug,
 static void
 dump_and_free_wakeref_tracking(struct intel_runtime_pm_debug *debug)
 {
-	struct drm_printer p;
+	if (debug->count) {
+		struct drm_printer p = drm_debug_printer("i915");
 
-	if (!debug->count)
-		return;
-
-	p = drm_debug_printer("i915");
-	__print_intel_runtime_pm_wakeref(&p, debug);
+		__print_intel_runtime_pm_wakeref(&p, debug);
+	}
 
 	kfree(debug->owners);
 }
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw

Quoting Mika Kuoppala (2019-06-27 15:44:38)

Quoted 4 lines

If we untrack wakerefs, the actual count may reach zero. However the krealloced owners array is still there and needs to be taken care of. Free the owners unconditionally to fix the leak.

That is true.

Quoted 1 line
Fixes dbf99c1f8c7e ("drm/i915: Force printing wakeref tacking during pm_cleanup")

However, the bug is mine

Fixes bd780f37a361 ("drm/i915: Track all held rpm wakerefs")
Quoted 5 lines

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
Quoted 6 lines · Chris Wilson

Quoting Mika Kuoppala (2019-06-27 15:44:38)

Quoted 4 lines

If we untrack wakerefs, the actual count may reach zero. However the krealloced owners array is still there and needs to be taken care of. Free the owners unconditionally to fix the leak.

Quoted 6 lines

That is true.

Quoted 1 line
Fixes dbf99c1f8c7e ("drm/i915: Force printing wakeref tacking during pm_cleanup")

However, the bug is mine

Fixes bd780f37a361 ("drm/i915: Track all held rpm wakerefs")

Indeed. Apologies Imre!

I personally know the reviewer of the original patch and will have a discussion.
-Mika

Quoted 8 lines
Quoted 6 lines

-Chris

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 12 lines · Mika Kuoppala
Quoted 10 lines · Chris Wilson

Quoting Mika Kuoppala (2019-06-27 15:44:38)

Quoted 4 lines

If we untrack wakerefs, the actual count may reach zero. However the krealloced owners array is still there and needs to be taken care of. Free the owners unconditionally to fix the leak.

That is true.

Quoted 1 line
Fixes dbf99c1f8c7e ("drm/i915: Force printing wakeref tacking during pm_cleanup")
Quoted 7 lines
Quoted 2 lines

However, the bug is mine

Fixes bd780f37a361 ("drm/i915: Track all held rpm wakerefs")

Indeed. Apologies Imre!

I personally know the reviewer of the original patch and will have a discussion.

Good catch, I've been staring at the kmemleak logs J-P provided, but couldn't see how it can happen.

Quoted 10 lines

-Mika

Quoted 8 lines
Quoted 6 lines

-Chris

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH 1/1 drm/i915: Fix memleak in runtime wakeref tracking

In reply to Chris Wilson

If we untrack wakerefs, the actual count may reach zero. However the krealloced owners array is still there and needs to be taken care of. Free the owners unconditionally to fix the leak.

Fixes bd780f37a361 ("drm/i915: Track all held rpm wakerefs")
Cc Juha-Pekka Heikkila <[email protected]>
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +4 -6
index 502c54428570..8d1aebc3e857 100644
@@ -221,13 +221,11 @@ __untrack_all_wakerefs(struct intel_runtime_pm_debug *debug,
 static void
 dump_and_free_wakeref_tracking(struct intel_runtime_pm_debug *debug)
 {
-	struct drm_printer p;
+	if (debug->count) {
+		struct drm_printer p = drm_debug_printer("i915");
 
-	if (!debug->count)
-		return;
-
-	p = drm_debug_printer("i915");
-	__print_intel_runtime_pm_wakeref(&p, debug);
+		__print_intel_runtime_pm_wakeref(&p, debug);
+	}
 
 	kfree(debug->owners);
 }
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

✗ Fi.CI.BAT: failure for series starting with drm/i915: Fix memleak in runtime wakeref tracking (rev2)

In reply to Mika Kuoppala
== Series Details ==

== Series Details ==

Series: series starting with drm/i915: Fix memleak in runtime wakeref tracking (rev2)
URL : https://patchwork.freedesktop.org/series/62871/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6375 -> Patchwork_13457
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_13457 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_13457, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_13457:

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@basic-rte:
- fi-skl-6600u: NOTRUN -> [DMESG-WARN][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-skl-6600u/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-cml-u: [PASS][2] -> [DMESG-WARN][3]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-cml-u/igt@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-cml-u/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_13457 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_blt:
- fi-icl-dsi: [PASS][4] -> [INCOMPLETE][5] ([fdo#107713])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-icl-dsi/igt@i915_selftest@live_blt.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-icl-dsi/igt@i915_selftest@live_blt.html
- fi-skl-iommu: [PASS][6] -> [INCOMPLETE][7] ([fdo#108602])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-skl-iommu/igt@i915_selftest@live_blt.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-skl-iommu/igt@i915_selftest@live_blt.html

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [PASS][8] -> [FAIL][9] ([fdo#109485])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-kbl-7500u/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-kbl-7500u/igt@[email protected]

#### Possible fixes ####

* igt@kms_frontbuffer_tracking@basic:
- fi-icl-u2: [FAIL][10] ([fdo#103167]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-icl-u2/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-icl-u2/igt@[email protected]

* igt@prime_self_import@basic-with_two_bos:
- fi-icl-u3: [DMESG-WARN][12] ([fdo#107724]) -> [PASS][13] +1 similar issue
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6375/fi-icl-u3/igt@prime_self_import@basic-with_two_bos.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/fi-icl-u3/igt@prime_self_import@basic-with_two_bos.html

[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485

Participating hosts (53 -> 45)
------------------------------

Additional (1): fi-skl-6600u
Missing (9): fi-kbl-soraka fi-kbl-7567u fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

Build changes
-------------

* Linux: CI_DRM_6375 -> Patchwork_13457

CI_DRM_6375: 44b3a556c682d3ae6d1cf94f6ec7c155ebeeff50 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5070: 250475af7bc52ba64956e6b35591fdd7176954d7 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13457: 6095e391e0434e88cc9187a20148b92e32e7cf6e @ git://anongit.freedesktop.org/gfx-ci/linux

== Kernel 32bit build ==

Warning: Kernel 32bit buildtest failed:
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/build_32bit.log

  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h

Kernel: arch/x86/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST 112 modules
ERROR: "__udivdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: "__divdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! scripts/Makefile.modpost:91: recipe for target '__modpost' failed make[1]: *** [__modpost] Error 1
Makefile:1287: recipe for target 'modules' failed
make: *** [modules] Error 2

== Linux commits ==

6095e391e043 drm/i915: Fix memleak in runtime wakeref tracking

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13457/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx