On Mon, Jun 26, 2023 at 2:27 PM Sergey Bugaev <buga...@gmail.com> wrote: > + /* > + * Get rid of the entry without changing any wirings or the pmap, > + * and without altering map->size. > + */ > + prev->vme_end = entry->vme_end; > + vm_map_entry_unlink(map, entry); > + vm_object_deallocate(entry->object.vm_object); > + vm_map_entry_dispose(map, entry);
Here's a little issue: I'm always deallocating entry->object.vm_object, but what if prev->object.vm_object was VM_OBJECT_NULL, and it got coalesced the other way around? In that case this needs to assign prev->object.vm_object to entry->object.vm_object and deallocate nothing. And this will get more complicated if vm_object_coalesce ever learns to coalesce actually different objects into one. So vm_object_coalesce needs to return, as an out parameter, the resulting object, and the callers need to make use of it. I will do that in v2 then. Sergey