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)
This commit is contained in:
Anees Iqbal committed 2026-11-09 06:01:13 -08:00
1 parent 15923d88c0
commit 0fa576badc
1 file changed
+6 -1
+6 -1
View File
@@ -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<Self>, 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(())
}
}