Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Michał Grzelak" <michal.grzelak@intel.com>,
	intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: lucas.demarchi@intel.com, rodrigo.vivi@intel.com,
	jani.nikula@linux.intel.com, Arunpravin.PaneerSelvam@amd.com,
	thomas.hellstrom@linux.intel.com
Subject: Re: [PATCH] drm/buddy: release free_trees array on buddy mm teardown
Date: Thu, 20 Nov 2025 09:46:45 +0000	[thread overview]
Message-ID: <370852a0-508b-4635-b46c-344e1b488363@intel.com> (raw)
In-Reply-To: <20251120093022.276551-1-michal.grzelak@intel.com>

On 20/11/2025 09:30, Michał Grzelak wrote:
> During initialization of DRM buddy memory manager at drm_buddy_init,
> mm->free_trees array is allocated for both clear and dirty RB trees.
> During cleanup happening at drm_buddy_fini it is never freed, leading to
> following memory leaks observed on xe module load & unload cycles:
> 
>      kmemleak_alloc+0x4a/0x90
>      __kmalloc_cache_noprof+0x488/0x800
>      drm_buddy_init+0xc2/0x330 [drm_buddy]
>      __xe_ttm_vram_mgr_init+0xc3/0x190 [xe]
>      xe_ttm_stolen_mgr_init+0xf5/0x9d0 [xe]
>      xe_device_probe+0x326/0x9e0 [xe]
>      xe_pci_probe+0x39a/0x610 [xe]
>      local_pci_probe+0x47/0xb0
>      pci_device_probe+0xf3/0x260
>      really_probe+0xf1/0x3c0
>      __driver_probe_device+0x8c/0x180
>      driver_probe_device+0x24/0xd0
>      __driver_attach+0x10f/0x220
>      bus_for_each_dev+0x7f/0xe0
>      driver_attach+0x1e/0x30
>      bus_add_driver+0x151/0x290
> 
> Deallocate array for free trees when cleaning up buddy memory manager
> in the same way as if going through out_free_tree label.
> 
> Fixes: d4cd665c ("drm/buddy: Separate clear and dirty free block trees")
> Signed-off-by: Michał Grzelak <michal.grzelak@intel.com>
> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matthew Auld <matthew.auld@intel.com>

> ---
>   drivers/gpu/drm/drm_buddy.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
> index 2f279b46bd2c..8308116058cc 100644
> --- a/drivers/gpu/drm/drm_buddy.c
> +++ b/drivers/gpu/drm/drm_buddy.c
> @@ -420,6 +420,7 @@ void drm_buddy_fini(struct drm_buddy *mm)
>   
>   	for_each_free_tree(i)
>   		kfree(mm->free_trees[i]);
> +	kfree(mm->free_trees);
>   	kfree(mm->roots);
>   }
>   EXPORT_SYMBOL(drm_buddy_fini);


  parent reply	other threads:[~2025-11-20  9:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20  9:30 [PATCH] drm/buddy: release free_trees array on buddy mm teardown Michał Grzelak
2025-11-20  9:39 ` ✗ CI.checkpatch: warning for " Patchwork
2025-11-20  9:40 ` ✓ CI.KUnit: success " Patchwork
2025-11-20  9:46 ` Matthew Auld [this message]
2025-11-29 20:28   ` [PATCH] " Michał Grzelak
2025-11-20 10:39 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-11-20 12:44 ` ✓ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=370852a0-508b-4635-b46c-344e1b488363@intel.com \
    --to=matthew.auld@intel.com \
    --cc=Arunpravin.PaneerSelvam@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.grzelak@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox