From 0fa576badc201fe7ee38f873d85dd0bd59fe0137 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 9 Nov 2026 05:18:10 -0800 Subject: [PATCH] A carried use of guest RAM is kept for the next generation's recovery in turn RamUseCell::carry registers the cell with the new generation's carry registry, so a later recovery carries it again. Where that registry was taken already (a late carry after a further loss), the use is carried on at once, as a late maker carries what it makes. Verification: the lavapipe runs of the carry tests. (cherry picked from commit 3868551689cc78de74431a7b5e86da65c4a2441f) --- crates/metal2vulkan-runtime/src/host_ram.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-runtime/src/host_ram.rs b/crates/metal2vulkan-runtime/src/host_ram.rs index 8db0673e0..b21caa788 100644 --- a/crates/metal2vulkan-runtime/src/host_ram.rs +++ b/crates/metal2vulkan-runtime/src/host_ram.rs @@ -423,7 +423,7 @@ impl RamUseCell { /// generation it leaves is let go of, as a drop lets it go (its thread ended, each chunk /// freed once nothing there holds it). Refused as [`Device::use_host_ram`] refuses it there, /// the use left the lost generation's. - pub(crate) fn carry(&self, to: &Device) -> Result<(), Error> { + pub(crate) fn carry(self: &Arc, to: &Device) -> Result<(), Error> { let ram = { let on = lock(&self.on); if on.device.same(to) { @@ -436,6 +436,11 @@ impl RamUseCell { let left = std::mem::replace(&mut *lock(&self.on), used); // Let go of with no lock held: its drop waits for the lost generation's thread to end. drop(left); + // Kept for `to`'s recovery in turn, or carried on where that took `to`'s uses already + // (a late carry, `Device::carry_late`). + if to.shared().carry.ram_use(self) { + to.carry_late(|serving| self.carry(serving)); + } Ok(()) } }