MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_phys_enq_range

Function vm_phys_enq_range

freebsd/vm/vm_phys.c:689–712  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

687 * The physical page m's buddy must not be free.
688 */
689static void
690vm_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

Callers 2

vm_phys_alloc_npagesFunction · 0.85
vm_phys_alloc_seg_contigFunction · 0.85

Calls 3

vm_freelist_addFunction · 0.85
flsFunction · 0.50
ffsFunction · 0.50

Tested by

no test coverage detected