git: 0cb2610ee2dc - main - vm: Remove handling for OBJT_DEFAULT objects
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 17 Jul 2022 11:24:18 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=0cb2610ee2dccfde2e385f8e8a10d0b8d6bc0687
commit 0cb2610ee2dccfde2e385f8e8a10d0b8d6bc0687
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-07-16 15:29:19 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-07-17 11:09:48 +0000
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
---
sys/vm/vm_fault.c | 3 +--
sys/vm/vm_map.c | 12 ++----------
sys/vm/vm_mmap.c | 6 ++----
sys/vm/vm_object.c | 16 +++-------------
sys/vm/vm_page.c | 6 ++----
sys/vm/vm_pageout.c | 10 +++-------
6 files changed, 13 insertions(+), 40 deletions(-)
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index d398be941e84..0433b6dd3d7e 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -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));
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 7e528fae7453..04310e42218f 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -2825,8 +2825,7 @@ again:
}
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. */
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 1c02ba35fcfe..56345fcaf560 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -940,8 +940,7 @@ retry:
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) {
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index bb29568ab5e4..7fd82239c13b 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -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));
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 127406c0d582..cb7ce428db28 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2693,8 +2693,7 @@ retry:
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)
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 74439d5884ef..bb12a7e335d5 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -896,11 +896,8 @@ free_page:
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;
}