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, vm_pindex_t pindex, int npages) +{ + int ninserted; + + VM_OBJECT_ASSERT_WLOCKED(object); + + ninserted = vm_radix_insert_batch(it, ma, pindex, 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 @@ -79,6 +79,18 @@ 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, + vm_pindex_t pindex, int npages) +{ + return (VM_RADIX_PCTRIE_INSERT_BATCH(it, ma, pindex, 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