aboutsummaryrefslogtreecommitdiff
path: root/sys/vm
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2018-11-02 16:26:44 +0000
committerMark Johnston <markj@FreeBSD.org>2018-11-02 16:26:44 +0000
commit2203c46d8751ea0f2d669727f539cf19f90edb01 (patch)
tree403149be36d90fdffee58391b37cab261b0fcb38 /sys/vm
parent5c239d80c07ae4955749f51f535f52583688c303 (diff)
downloadsrc-2203c46d8751ea0f2d669727f539cf19f90edb01.tar.gz
src-2203c46d8751ea0f2d669727f539cf19f90edb01.zip
Initialize the eflags field of vm_map headers.
Initializing the eflags field of the map->header entry to a value with a unique new bit set makes a few comparisons to &map->header unnecessary. Submitted by: Doug Moore <dougm@rice.edu> Reviewed by: alc, kib Tested by: pho MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D14005
Notes
Notes: svn path=/head/; revision=340064
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_map.c11
-rw-r--r--sys/vm/vm_map.h19
2 files changed, 14 insertions, 16 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index e961dd9e4a25..c44c9ff7bce9 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -796,6 +796,7 @@ _vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t min, vm_offset_t max)
{
map->header.next = map->header.prev = &map->header;
+ map->header.eflags = MAP_ENTRY_HEADER;
map->needs_wakeup = FALSE;
map->system_map = 0;
map->pmap = pmap;
@@ -1277,8 +1278,8 @@ charged:
if (object->ref_count > 1 || object->shadow_count != 0)
vm_object_clear_flag(object, OBJ_ONEMAPPING);
VM_OBJECT_WUNLOCK(object);
- } else if (prev_entry != &map->header &&
- (prev_entry->eflags & ~MAP_ENTRY_USER_WIRED) == protoeflags &&
+ } else if ((prev_entry->eflags & ~MAP_ENTRY_USER_WIRED) ==
+ protoeflags &&
(cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) == 0 &&
prev_entry->end == start && (prev_entry->cred == cred ||
(prev_entry->object.vm_object != NULL &&
@@ -1708,8 +1709,7 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry)
return;
prev = entry->prev;
- if (prev != &map->header &&
- vm_map_mergeable_neighbors(prev, entry)) {
+ if (vm_map_mergeable_neighbors(prev, entry)) {
vm_map_entry_unlink(map, prev);
entry->start = prev->start;
entry->offset = prev->offset;
@@ -1719,8 +1719,7 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry)
}
next = entry->next;
- if (next != &map->header &&
- vm_map_mergeable_neighbors(entry, next)) {
+ if (vm_map_mergeable_neighbors(entry, next)) {
vm_map_entry_unlink(map, next);
entry->end = next->end;
vm_map_entry_resize_free(map, entry);
diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h
index 23548bf7d9b5..b1cf8dbc44fc 100644
--- a/sys/vm/vm_map.h
+++ b/sys/vm/vm_map.h
@@ -146,6 +146,7 @@ struct vm_map_entry {
#define MAP_ENTRY_GUARD 0x10000
#define MAP_ENTRY_STACK_GAP_DN 0x20000
#define MAP_ENTRY_STACK_GAP_UP 0x40000
+#define MAP_ENTRY_HEADER 0x80000
#ifdef _KERNEL
static __inline u_char
@@ -175,24 +176,22 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry)
* list. Both structures are ordered based upon the start and
* end addresses contained within each map entry.
*
- * Counterintuitively, the map's min offset value is stored in
- * map->header.end, and its max offset value is stored in
- * map->header.start.
- *
- * The list header has max start value and min end value to act
- * as sentinels for sequential search of the doubly-linked list.
* Sleator and Tarjan's top-down splay algorithm is employed to
* control height imbalance in the binary search tree.
*
+ * The map's min offset value is stored in map->header.end, and
+ * its max offset value is stored in map->header.start. These
+ * values act as sentinels for any forward or backward address
+ * scan of the list. The map header has a special value for the
+ * eflags field, MAP_ENTRY_HEADER, that is set initially, is
+ * never changed, and prevents an eflags match of the header
+ * with any other map entry.
+ *
* List of locks
* (c) const until freed
*/
struct vm_map {
struct vm_map_entry header; /* List of entries */
-/*
- map min_offset header.end (c)
- map max_offset header.start (c)
-*/
struct sx lock; /* Lock for map data */
struct mtx system_mtx;
int nentries; /* Number of entries */