[PATCH] rust: drm: mm: Add DRM MM Range Allocator abstraction
Daniel Almeida
daniel.almeida at collabora.com
Wed Jun 25 19:16:36 UTC 2025
Hmm, this has an issue
[..]
>
> +impl<A: AllocInner<T>, T> Drop for MmInner<A, T> {
> + fn drop(&mut self) {
> + // SAFETY: If the MmInner is dropped then all nodes are gone (since they hold references),
> + // so it is safe to tear down the allocator.
> + unsafe {
> + bindings::drm_mm_takedown(self.0.get());
> + }
> + }
> +}
> +
>
Where the docs for drm_mm_takedown states:
/**
* drm_mm_takedown - clean up a drm_mm allocator
* @mm: drm_mm allocator to clean up
*
* Note that it is a bug to call this function on an allocator which is not
* clean.
*/
void drm_mm_takedown(struct drm_mm *mm)
{
if (WARN(!drm_mm_clean(mm),
"Memory manager not clean during takedown.\n"))
show_leaks(mm);
}
EXPORT_SYMBOL(drm_mm_takedown);
So perhaps we should remove all nodes before takedown?
This covers the error path, i.e.: something failed somewhere else and the allocator is dirty.
— Daniel
More information about the dri-devel
mailing list