On 2026-09-09 at 13:59 +1000, Eliot Courtney <[email protected]> wrote...
> From: Joel Fernandes <[email protected]>

[...]

> +        // TODO: Internal page table pages (PDE, PTE pages) are still kept 
> around.
> +        // This is by design as repeated maps/unmaps will be fast. As a 
> future TODO,
> +        // we can add a reclaimer here to reclaim if VRAM is short. For now, 
> the PT
> +        // pages are dropped once the `Vmm` is dropped.
> +
> +        // Free the VA range regardless of PTE invalidation success, so that 
> the VA
> +        // range is recovered even on failure (PTEs may be stale, but that 
> is better
> +        // than leaking both PTEs and VA range).

I don't think this is the correct approach. I'm not sure what exactly can cause
PTE invalidation to fail, but I don't think we can just recover the VA range
if something might still be using it via stale PTEs. That would cause problems
if the VA was ever reused for example. TLB invalidation is also part of PTE
invalidation as written, so we could also end up with stale TLB entries.

So leaking the range might be bad, but it's the least bad option IMHO.

 - Alistair

> +        self.free_vfn(range.vfn_start);
> +
> +        // Unmap complete, safe to drop `MappedRange`.
> +        range._drop_guard.disarm();
> +        result
> +    }
>  }
> 
> -- 
> 2.55.0
> 

Reply via email to