vm: Remove handling for OBJT_DEFAULT objects

Now that OBJT_DEFAULT objects can't be instantiated, we can simplify
checks of the form object->type == OBJT_DEFAULT || (object->flags &
OBJ_SWAP) != 0.  No functional change intended.

Reviewed by:	alc, kib
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35788
This commit is contained in:
Mark Johnston 2022-07-16 11:29:19 -04:00
parent fffc1c594a
commit 0cb2610ee2
6 changed files with 13 additions and 40 deletions

View File

@ -2040,8 +2040,7 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map __unused,
dst_object->cred = curthread->td_ucred;
crhold(dst_object->cred);
*fork_charge += dst_object->charge;
} else if ((dst_object->type == OBJT_DEFAULT ||
(dst_object->flags & OBJ_SWAP) != 0) &&
} else if ((dst_object->flags & OBJ_SWAP) != 0 &&
dst_object->cred == NULL) {
KASSERT(dst_entry->cred != NULL, ("no cred for entry %p",
dst_entry));

View File

@ -2825,8 +2825,7 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
}
VM_OBJECT_WLOCK(obj);
if (obj->type != OBJT_DEFAULT &&
(obj->flags & OBJ_SWAP) == 0) {
if ((obj->flags & OBJ_SWAP) == 0) {
VM_OBJECT_WUNLOCK(obj);
continue;
}
@ -4136,14 +4135,7 @@ vm_map_copy_entry(
*/
size = src_entry->end - src_entry->start;
if ((src_object = src_entry->object.vm_object) != NULL) {
/*
* Swap-backed objects need special handling. Note that
* this is an unlocked check, so it is possible to race
* with an OBJT_DEFAULT -> OBJT_SWAP conversion.
*/
if (src_object->type == OBJT_DEFAULT ||
src_object->type == OBJT_SWAP ||
(src_object->flags & OBJ_SWAP) != 0) {
if ((src_object->flags & OBJ_SWAP) != 0) {
vm_map_copy_swap_object(src_entry, dst_entry,
size, fork_charge);
/* May have split/collapsed, reload obj. */

View File

@ -940,8 +940,7 @@ kern_mincore(struct thread *td, uintptr_t addr0, size_t len, char *vec)
object = current->object.vm_object;
VM_OBJECT_WLOCK(object);
}
if (object->type == OBJT_DEFAULT ||
(object->flags & OBJ_SWAP) != 0 ||
if ((object->flags & OBJ_SWAP) != 0 ||
object->type == OBJT_VNODE) {
pindex = OFF_TO_IDX(current->offset +
(addr - current->start));
@ -1368,8 +1367,7 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
goto done;
}
} else {
KASSERT(obj->type == OBJT_DEFAULT || obj->type == OBJT_SWAP ||
(obj->flags & OBJ_SWAP) != 0, ("wrong object type"));
KASSERT((obj->flags & OBJ_SWAP) != 0, ("wrong object type"));
vm_object_reference(obj);
#if VM_NRESERVLEVEL > 0
if ((obj->flags & OBJ_COLORED) == 0) {

View File

@ -414,9 +414,6 @@ vm_object_allocate(objtype_t type, vm_pindex_t size)
switch (type) {
case OBJT_DEAD:
panic("vm_object_allocate: can't create OBJT_DEAD");
case OBJT_DEFAULT:
flags = OBJ_COLORED;
break;
case OBJT_SWAP:
flags = OBJ_COLORED | OBJ_SWAP;
break;
@ -688,8 +685,7 @@ vm_object_deallocate(vm_object_t object)
umtx_shm_object_terminated(object);
temp = object->backing_object;
if (temp != NULL) {
KASSERT(object->type == OBJT_DEFAULT ||
object->type == OBJT_SWAP,
KASSERT(object->type == OBJT_SWAP,
("shadowed tmpfs v_object 2 %p", object));
vm_object_backing_remove(object);
}
@ -969,8 +965,7 @@ vm_object_terminate(vm_object_t object)
vm_reserv_break_all(object);
#endif
KASSERT(object->cred == NULL || object->type == OBJT_DEFAULT ||
(object->flags & OBJ_SWAP) != 0,
KASSERT(object->cred == NULL || (object->flags & OBJ_SWAP) != 0,
("%s: non-swap obj %p has cred", __func__, object));
/*
@ -1306,8 +1301,7 @@ vm_object_madvise_freespace(vm_object_t object, int advice, vm_pindex_t pindex,
*
* Deactivate the specified pages if they are resident.
*
* MADV_FREE (OBJT_DEFAULT/OBJT_SWAP objects,
* OBJ_ONEMAPPING only)
* MADV_FREE (OBJT_SWAP objects, OBJ_ONEMAPPING only)
*
* Deactivate and clean the specified pages if they are
* resident. This permits the process to reuse the pages
@ -1529,10 +1523,6 @@ vm_object_split(vm_map_entry_t entry)
offidxstart = OFF_TO_IDX(entry->offset);
size = atop(entry->end - entry->start);
/*
* If swap_pager_copy() is later called, it will convert new_object
* into a swap object.
*/
new_object = vm_object_allocate_anon(size, orig_object,
orig_object->cred, ptoa(size));

View File

@ -2693,8 +2693,7 @@ vm_page_scan_contig(u_long npages, vm_page_t m_start, vm_page_t m_end,
goto retry;
}
/* Don't care: PG_NODUMP, PG_ZERO. */
if (object->type != OBJT_DEFAULT &&
(object->flags & OBJ_SWAP) == 0 &&
if ((object->flags & OBJ_SWAP) == 0 &&
object->type != OBJT_VNODE) {
run_ext = 0;
#if VM_NRESERVLEVEL > 0
@ -2831,8 +2830,7 @@ vm_page_reclaim_run(int req_class, int domain, u_long npages, vm_page_t m_run,
VM_OBJECT_WLOCK(object);
/* Don't care: PG_NODUMP, PG_ZERO. */
if (m->object != object ||
(object->type != OBJT_DEFAULT &&
(object->flags & OBJ_SWAP) == 0 &&
((object->flags & OBJ_SWAP) == 0 &&
object->type != OBJT_VNODE))
error = EINVAL;
else if (object->memattr != VM_MEMATTR_DEFAULT)

View File

@ -896,11 +896,8 @@ vm_pageout_launder(struct vm_domain *vmd, int launder, bool in_shortfall)
vm_page_free(m);
VM_CNT_INC(v_dfree);
} else if ((object->flags & OBJ_DEAD) == 0) {
if ((object->flags & OBJ_SWAP) == 0 &&
object->type != OBJT_DEFAULT)
pageout_ok = true;
else if (disable_swap_pageouts)
pageout_ok = false;
if ((object->flags & OBJ_SWAP) != 0)
pageout_ok = disable_swap_pageouts == 0;
else
pageout_ok = true;
if (!pageout_ok) {
@ -1886,8 +1883,7 @@ vm_pageout_oom_pagecount(struct vmspace *vmspace)
if ((entry->eflags & MAP_ENTRY_NEEDS_COPY) != 0 &&
obj->ref_count != 1)
continue;
if (obj->type == OBJT_DEFAULT || obj->type == OBJT_SWAP ||
obj->type == OBJT_PHYS || obj->type == OBJT_VNODE ||
if (obj->type == OBJT_PHYS || obj->type == OBJT_VNODE ||
(obj->flags & OBJ_SWAP) != 0)
res += obj->resident_page_count;
}