swap-like pagers: assert that writemapping decrease does not pass zero

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45119
This commit is contained in:
Konstantin Belousov 2024-05-08 16:58:52 +03:00
parent 58d7ac11e7
commit 6ada4e8a0a
2 changed files with 7 additions and 0 deletions

View File

@ -183,6 +183,9 @@ tmpfs_pager_release_writecount(vm_object_t object, vm_offset_t start,
KASSERT((object->flags & OBJ_ANON) == 0, KASSERT((object->flags & OBJ_ANON) == 0,
("%s: object %p with OBJ_ANON", __func__, object)); ("%s: object %p with OBJ_ANON", __func__, object));
old = object->un_pager.swp.writemappings; old = object->un_pager.swp.writemappings;
KASSERT(old >= (vm_ooffset_t)end - start,
("tmpfs obj %p writecount %jx dec %jx", object, (uintmax_t)old,
(uintmax_t)((vm_ooffset_t)end - start)));
object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start; object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start;
new = object->un_pager.swp.writemappings; new = object->un_pager.swp.writemappings;
tmpfs_pager_writecount_recalc(object, old, new); tmpfs_pager_writecount_recalc(object, old, new);

View File

@ -3158,6 +3158,10 @@ swap_pager_release_writecount(vm_object_t object, vm_offset_t start,
VM_OBJECT_WLOCK(object); VM_OBJECT_WLOCK(object);
KASSERT((object->flags & OBJ_ANON) == 0, KASSERT((object->flags & OBJ_ANON) == 0,
("Splittable object with writecount")); ("Splittable object with writecount"));
KASSERT(object->un_pager.swp.writemappings >= (vm_ooffset_t)end - start,
("swap obj %p writecount %jx dec %jx", object,
(uintmax_t)object->un_pager.swp.writemappings,
(uintmax_t)((vm_ooffset_t)end - start)));
object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start; object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start;
VM_OBJECT_WUNLOCK(object); VM_OBJECT_WUNLOCK(object);
} }