* Add the physical pages [m, m + npages) at the end of a power-of-two aligned * and sized set to the specified free list. * * When this function is called by a page allocation function, the caller * should request insertion at the head unless the lower-order queues are * known to be empty. The objective being to reduce the likelihood of long- * term fragmentation by promoting contemporaneou
| 687 | * The physical page m's buddy must not be free. |
| 688 | */ |
| 689 | static void |
| 690 | vm_phys_enq_range(vm_page_t m, u_int npages, struct vm_freelist *fl, int tail) |
| 691 | { |
| 692 | u_int n; |
| 693 | int order; |
| 694 | |
| 695 | KASSERT(npages > 0, ("vm_phys_enq_range: npages is 0")); |
| 696 | KASSERT(((VM_PAGE_TO_PHYS(m) + npages * PAGE_SIZE) & |
| 697 | ((PAGE_SIZE << (fls(npages) - 1)) - 1)) == 0, |
| 698 | ("vm_phys_enq_range: page %p and npages %u are misaligned", |
| 699 | m, npages)); |
| 700 | do { |
| 701 | KASSERT(m->order == VM_NFREEORDER, |
| 702 | ("vm_phys_enq_range: page %p has unexpected order %d", |
| 703 | m, m->order)); |
| 704 | order = ffs(npages) - 1; |
| 705 | KASSERT(order < VM_NFREEORDER, |
| 706 | ("vm_phys_enq_range: order %d is out of range", order)); |
| 707 | vm_freelist_add(fl, m, order, tail); |
| 708 | n = 1 << order; |
| 709 | m += n; |
| 710 | npages -= n; |
| 711 | } while (npages > 0); |
| 712 | } |
| 713 | |
| 714 | /* |
| 715 | * Tries to allocate the specified number of pages from the specified pool |
no test coverage detected