diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -293,7 +293,7 @@ * Use a fairly large batch size since we expect amd64 systems to have lots of * memory. */ -#define VM_BATCHQUEUE_SIZE 31 +#define VM_BATCHQUEUE_SIZE 63 /* * The pmap can create non-transparent large page mappings. diff --git a/sys/powerpc/include/vmparam.h b/sys/powerpc/include/vmparam.h --- a/sys/powerpc/include/vmparam.h +++ b/sys/powerpc/include/vmparam.h @@ -263,7 +263,7 @@ * memory. */ #ifdef __powerpc64__ -#define VM_BATCHQUEUE_SIZE 31 +#define VM_BATCHQUEUE_SIZE 63 #endif /* 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 @@ -3656,19 +3656,32 @@ { struct vm_batchqueue *bq; struct vm_pagequeue *pq; - int domain; + int domain, slots_remaining; KASSERT(queue < PQ_COUNT, ("invalid queue %d", queue)); domain = vm_page_domain(m); critical_enter(); bq = DPCPU_PTR(pqbatch[domain][queue]); - if (vm_batchqueue_insert(bq, m)) { + slots_remaining = vm_batchqueue_insert(bq, m); + if (slots_remaining > (VM_BATCHQUEUE_SIZE >> 1)) { + /* keep building the bq */ + critical_exit(); + return; + } else if (slots_remaining > 0 ) { + /* Try to process the bq if we can get the lock */ + pq = &VM_DOMAIN(domain)->vmd_pagequeues[queue]; + if (vm_pagequeue_trylock(pq)) { + vm_pqbatch_process(pq, bq, queue); + vm_pagequeue_unlock(pq); + } critical_exit(); return; } critical_exit(); + /* if we make it here, the bq is full so wait for the lock */ + pq = &VM_DOMAIN(domain)->vmd_pagequeues[queue]; vm_pagequeue_lock(pq); critical_enter(); diff --git a/sys/vm/vm_pagequeue.h b/sys/vm/vm_pagequeue.h --- a/sys/vm/vm_pagequeue.h +++ b/sys/vm/vm_pagequeue.h @@ -75,7 +75,7 @@ } __aligned(CACHE_LINE_SIZE); #ifndef VM_BATCHQUEUE_SIZE -#define VM_BATCHQUEUE_SIZE 7 +#define VM_BATCHQUEUE_SIZE 15 #endif struct vm_batchqueue { @@ -356,15 +356,17 @@ bq->bq_cnt = 0; } -static inline bool +static inline int vm_batchqueue_insert(struct vm_batchqueue *bq, vm_page_t m) { + int slots_free; - if (bq->bq_cnt < nitems(bq->bq_pa)) { + slots_free = nitems(bq->bq_pa) - bq->bq_cnt; + if (slots_free > 0) { bq->bq_pa[bq->bq_cnt++] = m; - return (true); + return (slots_free); } - return (false); + return (slots_free); } static inline vm_page_t