diff options
Diffstat (limited to 'sys/uvm/uvm_addr.c')
-rw-r--r-- | sys/uvm/uvm_addr.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/sys/uvm/uvm_addr.c b/sys/uvm/uvm_addr.c index ca72453cfbb..317a427da49 100644 --- a/sys/uvm/uvm_addr.c +++ b/sys/uvm/uvm_addr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_addr.c,v 1.29 2020/09/22 14:31:08 mpi Exp $ */ +/* $OpenBSD: uvm_addr.c,v 1.30 2021/03/20 10:24:21 mpi Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -65,7 +65,9 @@ struct uaddr_rnd_state { #endif }; -/* Definition of a pivot in pivot selector. */ +/* + * Definition of a pivot in pivot selector. + */ struct uaddr_pivot { vaddr_t addr; /* End of prev. allocation. */ int expire;/* Best before date. */ @@ -87,7 +89,11 @@ struct uaddr_pivot_state { extern const struct uvm_addr_functions uaddr_kernel_functions; struct uvm_addr_state uaddr_kbootstrap; -/* Support functions. */ + +/* + * Support functions. + */ + #ifndef SMALL_KERNEL struct vm_map_entry *uvm_addr_entrybyspace(struct uaddr_free_rbtree*, vsize_t); @@ -236,7 +242,9 @@ uvm_addr_fitspace(vaddr_t *min_result, vaddr_t *max_result, if (fspace - before_gap - after_gap < sz) return ENOMEM; - /* Calculate lowest address. */ + /* + * Calculate lowest address. + */ low_addr += before_gap; low_addr = uvm_addr_align_forward(tmp = low_addr, align, offset); if (low_addr < tmp) /* Overflow during alignment. */ @@ -244,7 +252,9 @@ uvm_addr_fitspace(vaddr_t *min_result, vaddr_t *max_result, if (high_addr - after_gap - sz < low_addr) return ENOMEM; - /* Calculate highest address. */ + /* + * Calculate highest address. + */ high_addr -= after_gap + sz; high_addr = uvm_addr_align_backward(tmp = high_addr, align, offset); if (high_addr > tmp) /* Overflow during alignment. */ @@ -341,7 +351,9 @@ uvm_addr_linsearch(struct vm_map *map, struct uvm_addr_state *uaddr, (before_gap & PAGE_MASK) == 0 && (after_gap & PAGE_MASK) == 0); KASSERT(high + sz > high); /* Check for overflow. */ - /* Hint magic. */ + /* + * Hint magic. + */ if (hint == 0) hint = (direction == 1 ? low : high); else if (hint > high) { @@ -463,6 +475,7 @@ uaddr_destroy(struct uvm_addr_state *uaddr) * If hint is set, search will start at the hint position. * Only searches forward. */ + const struct uvm_addr_functions uaddr_lin_functions = { .uaddr_select = &uaddr_lin_select, .uaddr_destroy = &uaddr_destroy, @@ -489,7 +502,9 @@ uaddr_lin_select(struct vm_map *map, struct uvm_addr_state *uaddr, { vaddr_t guard_sz; - /* Deal with guardpages: search for space with one extra page. */ + /* + * Deal with guardpages: search for space with one extra page. + */ guard_sz = ((map->flags & VM_MAP_GUARDPAGES) == 0 ? 0 : PAGE_SIZE); if (uaddr->uaddr_maxaddr - uaddr->uaddr_minaddr - guard_sz < sz) @@ -716,6 +731,7 @@ uaddr_rnd_print(struct uvm_addr_state *uaddr_p, boolean_t full, /* * Kernel allocation bootstrap logic. */ + const struct uvm_addr_functions uaddr_kernel_functions = { .uaddr_select = &uaddr_kbootstrap_select, .uaddr_destroy = &uaddr_kbootstrap_destroy, @@ -839,7 +855,9 @@ uaddr_bestfit_select(struct vm_map *map, struct uvm_addr_state *uaddr_p, if (entry == NULL) return ENOMEM; - /* Walk the tree until we find an entry that fits. */ + /* + * Walk the tree until we find an entry that fits. + */ while (uvm_addr_fitspace(&min, &max, VMMAP_FREE_START(entry), VMMAP_FREE_END(entry), sz, align, offset, 0, guardsz) != 0) { @@ -848,7 +866,9 @@ uaddr_bestfit_select(struct vm_map *map, struct uvm_addr_state *uaddr_p, return ENOMEM; } - /* Return the address that generates the least fragmentation. */ + /* + * Return the address that generates the least fragmentation. + */ *entry_out = entry; *addr_out = (min - VMMAP_FREE_START(entry) <= VMMAP_FREE_END(entry) - guardsz - sz - max ? @@ -1128,7 +1148,9 @@ uaddr_pivot_select(struct vm_map *map, struct uvm_addr_state *uaddr_p, if (pivot->addr == 0 || pivot->entry == NULL || pivot->expire == 0) goto expired; /* Pivot is invalid (null or expired). */ - /* Attempt to use the pivot to map the entry. */ + /* + * Attempt to use the pivot to map the entry. + */ entry = pivot->entry; if (pivot->dir > 0) { if (uvm_addr_fitspace(&min, &max, |