diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1610,6 +1610,29 @@ vm_object_set_writeable_dirty(object); } +/* + * vm_page_insert_batch: + * + * Inserts page array "ma" into the specified object + * starting at offset "pindex". + * + * The object must be locked. + */ +static __always_inline int +vm_page_insert_batch(vm_object_t object, struct pctrie_iter *it, + vm_page_t *ma, int npages) +{ + int ninserted; + + VM_OBJECT_ASSERT_WLOCKED(object); + + ninserted = vm_radix_insert_batch(it, ma, npages); + if (ninserted > 0) + vm_page_insert_radixdone_batch(object, ma, ninserted); + + return (ninserted); +} + /* * Do the work to remove a page from its object. The caller is responsible for * updating the page's fields to reflect this removal. diff --git a/sys/vm/vm_radix.h b/sys/vm/vm_radix.h --- a/sys/vm/vm_radix.h +++ b/sys/vm/vm_radix.h @@ -39,6 +39,15 @@ #include void vm_radix_wait(void); +======= + * Inserts an array of pages into the trie. + * Panics if any of the keys already exist. + * Returns the number of inserted pages. + */ +static __inline int +vm_radix_insert_batch(struct pctrie_iter *it, vm_page_t *ma, int npages) +{ + return (VM_RADIX_PCTRIE_INSERT_BATCH(it, ma, npages)); void vm_radix_zinit(void); void *vm_radix_node_alloc(struct pctrie *ptree); void vm_radix_node_free(struct pctrie *ptree, void *node); @@ -79,6 +88,17 @@ return (VM_RADIX_PCTRIE_ITER_INSERT(pages, page)); } +/* + * Inserts an array of pages into the trie. + * Panics if any of the keys already exist. + * Returns the number of inserted pages. + */ +static __inline int +vm_radix_insert_batch(struct pctrie_iter *it, vm_page_t *ma, int npages) +{ + return (VM_RADIX_PCTRIE_INSERT_BATCH(it, ma, npages)); +} + /* * Insert the page into the vm_radix tree with its pindex as the key. Panic if * the pindex already exists. Return zero on success or a non-zero error on