1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-26 23:26:11 +00:00

De-ifdef UVM_AMAP_PPREF it's been enabled long enough to not go back

Fewer knobs and conditional code that nobody tests.

deraadt@: go for it
This commit is contained in:
gnezdo
2025-05-25 01:52:00 +00:00
parent c8fadddc4e
commit cd63ddfc07
2 changed files with 6 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: uvm_amap.c,v 1.96 2024/12/04 09:19:11 mpi Exp $ */
/* $OpenBSD: uvm_amap.c,v 1.97 2025/05/25 01:52:00 gnezdo Exp $ */
/* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */
/*
@@ -72,13 +72,6 @@ static inline void amap_list_remove(struct vm_amap *);
struct vm_amap_chunk *amap_chunk_get(struct vm_amap *, int, int, int);
void amap_chunk_free(struct vm_amap *, struct vm_amap_chunk *);
/*
* if we enable PPREF, then we have a couple of extra functions that
* we need to prototype here...
*/
#ifdef UVM_AMAP_PPREF
#define PPREF_NONE ((int *) -1) /* not using ppref */
void amap_pp_adjref(struct vm_amap *, int, vsize_t, int);
@@ -87,8 +80,6 @@ void amap_wiperange_chunk(struct vm_amap *, struct vm_amap_chunk *, int,
int);
void amap_wiperange(struct vm_amap *, int, int);
#endif /* UVM_AMAP_PPREF */
static inline void
amap_list_insert(struct vm_amap *amap)
{
@@ -179,13 +170,11 @@ amap_chunk_free(struct vm_amap *amap, struct vm_amap_chunk *chunk)
amap->am_ncused--;
}
#ifdef UVM_AMAP_PPREF
/*
* what is ppref? ppref is an _optional_ amap feature which is used
* to keep track of reference counts on a per-page basis. it is enabled
* when UVM_AMAP_PPREF is defined.
* to keep track of reference counts on a per-page basis.
*
* when enabled, an array of ints is allocated for the pprefs. this
* an array of ints is allocated for the pprefs. this
* array is allocated only when a partial reference is added to the
* map (either by unmapping part of the amap, or gaining a reference
* to only a part of an amap). if the allocation of the array fails
@@ -246,7 +235,6 @@ pp_setreflen(int *ppref, int offset, int ref, int len)
ppref[offset+1] = len;
}
}
#endif /* UVM_AMAP_PPREF */
/*
* amap_init: called at boot time to init global amap data structures
@@ -347,9 +335,7 @@ amap_alloc1(int slots, int waitf, int lazyalloc)
amap->am_lock = NULL;
amap->am_ref = 1;
amap->am_flags = 0;
#ifdef UVM_AMAP_PPREF
amap->am_ppref = NULL;
#endif
amap->am_nslot = slots;
amap->am_nused = 0;
@@ -454,10 +440,8 @@ amap_free(struct vm_amap *amap)
rw_obj_free(amap->am_lock);
}
#ifdef UVM_AMAP_PPREF
if (amap->am_ppref && amap->am_ppref != PPREF_NONE)
free(amap->am_ppref, M_UVMAMAP, amap->am_nslot * sizeof(int));
#endif
if (UVM_AMAP_SMALL(amap))
pool_put(&uvm_small_amap_pool[amap->am_nslot - 1], amap);
@@ -688,12 +672,10 @@ amap_copy(struct vm_map *map, struct vm_map_entry *entry, int waitf,
if (srcamap->am_ref == 1 && (srcamap->am_flags & AMAP_SHARED) != 0)
srcamap->am_flags &= ~AMAP_SHARED; /* clear shared flag */
#ifdef UVM_AMAP_PPREF
if (srcamap->am_ppref && srcamap->am_ppref != PPREF_NONE) {
amap_pp_adjref(srcamap, entry->aref.ar_pageoff,
(entry->end - entry->start) >> PAGE_SHIFT, -1);
}
#endif
/*
* If we referenced any anons, then share the source amap's lock.
@@ -854,11 +836,9 @@ amap_splitref(struct vm_aref *origref, struct vm_aref *splitref, vaddr_t offset)
if (amap->am_nslot - origref->ar_pageoff - leftslots <= 0)
panic("amap_splitref: map size check failed");
#ifdef UVM_AMAP_PPREF
/* Establish ppref before we add a duplicate reference to the amap. */
if (amap->am_ppref == NULL)
amap_pp_establish(amap);
#endif
/* Note: not a share reference. */
amap->am_ref++;
@@ -867,8 +847,6 @@ amap_splitref(struct vm_aref *origref, struct vm_aref *splitref, vaddr_t offset)
amap_unlock(amap);
}
#ifdef UVM_AMAP_PPREF
/*
* amap_pp_establish: add a ppref array to an amap, if possible.
*
@@ -1065,8 +1043,6 @@ amap_wiperange(struct vm_amap *amap, int slotoff, int slots)
}
}
#endif
/*
* amap_swap_off: pagein anonymous pages in amaps and drop swap slots.
*
@@ -1303,7 +1279,6 @@ static void
amap_adjref_anons(struct vm_amap *amap, vaddr_t offset, vsize_t len,
int refv, boolean_t all)
{
#ifdef UVM_AMAP_PPREF
KASSERT(rw_write_held(amap->am_lock));
/*
@@ -1313,11 +1288,8 @@ amap_adjref_anons(struct vm_amap *amap, vaddr_t offset, vsize_t len,
if (amap->am_ppref == NULL && !all && len != amap->am_nslot) {
amap_pp_establish(amap);
}
#endif
amap->am_ref += refv;
#ifdef UVM_AMAP_PPREF
if (amap->am_ppref && amap->am_ppref != PPREF_NONE) {
if (all) {
amap_pp_adjref(amap, 0, amap->am_nslot, refv);
@@ -1325,7 +1297,6 @@ amap_adjref_anons(struct vm_amap *amap, vaddr_t offset, vsize_t len,
amap_pp_adjref(amap, offset, len, refv);
}
}
#endif
amap_unlock(amap);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: uvm_amap.h,v 1.35 2024/12/04 09:19:11 mpi Exp $ */
/* $OpenBSD: uvm_amap.h,v 1.36 2025/05/25 01:52:00 gnezdo Exp $ */
/* $NetBSD: uvm_amap.h,v 1.14 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -112,13 +112,10 @@ boolean_t amap_swap_off(int, int);
/*
* we currently provide an array-based amap implementation. in this
* implementation we provide the option of tracking split references
* so that we don't lose track of references during partial unmaps
* ... this is enabled with the "UVM_AMAP_PPREF" define.
* implementation we track split references so that we don't lose track of
* references during partial unmaps.
*/
#define UVM_AMAP_PPREF /* track partial references */
/*
* here is the definition of the vm_amap structure and helper structures for
* this implementation.
@@ -138,9 +135,7 @@ struct vm_amap {
int am_flags; /* flags */
int am_nslot; /* # of slots currently in map */
int am_nused; /* # of slots currently in use */
#ifdef UVM_AMAP_PPREF
int *am_ppref; /* per page reference count (if !NULL) */
#endif
LIST_ENTRY(vm_amap) am_list;
union {