All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails
@ 2026-11-16  3:38 Mirian Shilakadze
  2026-11-16  3:45 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mirian Shilakadze @ 2026-11-16  3:38 UTC (permalink / raw)
  To: khorenko; +Cc: devel

Since commit ffbc4c6f4d0b ("ms/drm/amdgpu: Fix init ordering in
amdgpu_vram_mgr_init()") the dmem cgroup region is registered after
drm_buddy_init(). When drmm_cgroup_register_region() fails,
amdgpu_vram_mgr_init() returns without drm_buddy_fini(), so a probe
failing there leaks the buddy allocator.

Free it on that error path. Upstream does the same in commit
bd4f284df04d ("drm/amdgpu: Wire up dmem cgroup reclaim for VRAM
manager"), which also wires up dmem reclaim and is not taken here.

Fixes: ffbc4c6f4d0b ("ms/drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init()")
https://virtuozzo.atlassian.net/browse/VSTOR-154845
Feature: fix ms/drm
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
Item 1 from the review of VSTOR-153702.

Not run: we have no node with an AMD GPU. Build-tested only,
amdgpu_vram_mgr.o compiles with the 211.52.1.22.22 config.

 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 2e457a0388a3..11679506de47 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -932,8 +932,10 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 		return err;
 
 	man->cg = drmm_cgroup_register_region(adev_to_drm(adev), "vram", adev->gmc.real_vram_size);
-	if (IS_ERR(man->cg))
+	if (IS_ERR(man->cg)) {
+		drm_buddy_fini(&mgr->mm);
 		return PTR_ERR(man->cg);
+	}
 
 	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
 	ttm_resource_manager_set_used(man, true);
-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails
  2026-11-16  3:38 [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails Mirian Shilakadze
@ 2026-11-16  3:45 ` no-reply
  2026-11-16 16:03 ` Konstantin Khorenko
  2026-11-16 16:03 ` Konstantin Khorenko
  2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2026-11-16  3:45 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko; +Cc: devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/amdgpu: Fixes tag cites ffbc4c6f4d0b, not in baseline
  history
--

commit 6e9e31d0a13bdda4472b468f1406f2c15cf25c56
Author: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

drm/amdgpu: free the buddy allocator when dmem region registration fails

When drmm_cgroup_register_region() fails in amdgpu_vram_mgr_init(), the function now calls drm_buddy_fini() before returning the error. Previously the buddy allocator initialised just before was leaked.

> drm/amdgpu: free the buddy allocator when dmem region registration fails
>
> Since commit ffbc4c6f4d0b ("ms/drm/amdgpu: Fix init ordering in
> amdgpu_vram_mgr_init()") the dmem cgroup region is registered after
> drm_buddy_init(). When drmm_cgroup_register_region() fails,
> amdgpu_vram_mgr_init() returns without drm_buddy_fini(), so a probe
> failing there leaks the buddy allocator.
>
> Free it on that error path. Upstream does the same in commit
> bd4f284df04d ("drm/amdgpu: Wire up dmem cgroup reclaim for VRAM
> manager"), which also wires up dmem reclaim and is not taken here.
>
> Fixes: ffbc4c6f4d0b ("ms/drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init()")
> https://virtuozzo.atlassian.net/browse/VSTOR-154845
> Feature: fix ms/drm
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

[Severity: Low]
Does the Fixes: tag name the right commit? ffbc4c6f4d0b is not in the baseline history, so the tag and the "Since commit" sentence do not resolve on this branch. The commit already on the branch that moved drmm_cgroup_register_region() after drm_buddy_init(), and so opened this leak, is 6221d6dc707e ("ms/drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init()"). Should both references be changed to it?

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261116033832.26787-1-mirian.shilakadze@virtuozzo.com?part=1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails
  2026-11-16  3:38 [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails Mirian Shilakadze
  2026-11-16  3:45 ` no-reply
@ 2026-11-16 16:03 ` Konstantin Khorenko
  2026-11-16 16:03 ` Konstantin Khorenko
  2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 16:03 UTC (permalink / raw)
  To: Mirian Shilakadze; +Cc: devel

Applying with these fixes on my side:
- "Since commit" and Fixes: ffbc4c6f4d0b -> 6221d6dc707e

On Mon, 16 Nov 2026 07:38:01 +0400, Mirian Shilakadze <mirian.shilakadze@virtuozzo.com> wrote:
> Fixes: ffbc4c6f4d0b ("ms/drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init()")

Sashiko is right: ffbc4c6f4d0b is the copy on the 211.52.1.22.x
branch. On this branch the same backport is 6221d6dc707e.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails
  2026-11-16  3:38 [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails Mirian Shilakadze
  2026-11-16  3:45 ` no-reply
  2026-11-16 16:03 ` Konstantin Khorenko
@ 2026-11-16 16:03 ` Konstantin Khorenko
  2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 16:03 UTC (permalink / raw)
  To: Mirian Shilakadze; +Cc: devel

On Mon, 16 Nov 2026 07:38:01 +0400, Mirian Shilakadze wrote:
> drm/amdgpu: free the buddy allocator when dmem region registration fails

Applied to branch-rh10-6.12.0-211.75.1.24.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.2.vz10, thanks!

[1/1] drm/amdgpu: free the buddy allocator when dmem region registration fails
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/c8d9b03a0cdd

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

end of thread, other threads:[~2026-11-16 16:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16  3:38 [Devel] [PATCH hci-8.1] drm/amdgpu: free the buddy allocator when dmem region registration fails Mirian Shilakadze
2026-11-16  3:45 ` no-reply
2026-11-16 16:03 ` Konstantin Khorenko
2026-11-16 16:03 ` Konstantin Khorenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.