diff options
Diffstat (limited to 'sys/vm/vm_reserv.c')
-rw-r--r-- | sys/vm/vm_reserv.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 8f34b31..8bb1788 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -866,6 +866,35 @@ vm_reserv_init(void) } /* + * Returns true if the given page belongs to a reservation and that page is + * free. Otherwise, returns false. + */ +bool +vm_reserv_is_page_free(vm_page_t m) +{ + vm_reserv_t rv; + + mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); + rv = vm_reserv_from_page(m); + if (rv->object == NULL) + return (false); + return (popmap_is_clear(rv->popmap, m - rv->pages)); +} + +/* + * If the given page belongs to a reservation, returns the level of that + * reservation. Otherwise, returns -1. + */ +int +vm_reserv_level(vm_page_t m) +{ + vm_reserv_t rv; + + rv = vm_reserv_from_page(m); + return (rv->object != NULL ? 0 : -1); +} + +/* * Returns a reservation level if the given page belongs to a fully-populated * reservation and -1 otherwise. */ @@ -1076,6 +1105,23 @@ vm_reserv_rename(vm_page_t m, vm_object_t new_object, vm_object_t old_object, } /* + * Returns the size (in bytes) of a reservation of the specified level. + */ +int +vm_reserv_size(int level) +{ + + switch (level) { + case 0: + return (VM_LEVEL_0_SIZE); + case -1: + return (PAGE_SIZE); + default: + return (0); + } +} + +/* * Allocates the virtual and physical memory required by the reservation * management system's data structures, in particular, the reservation array. */ |