Change the usage of the pool field in vm_page structs.
Currently, every page belongs to a pool, and the pool field identifies
that pool.
With this change:
1. Free memory blocks are only have valid pool fields when they are
the first page in a block in a buddy queue. Otherwise, the value of
pool is VM_NFREEPOOL.
2. Memory allocated in power-of-two sized blocks, by
vm_phys_alloc_freelist_pages or vm_phys_alloc_pages, have only the
first page of the block with a valid pool field; the others have
VM_NFREEPOOL as their pool field. The function vm_phys_free_pages
frees such blocks and restores the first page field to VM_NFREEPOOL.
3. Memory allocated as a number of pages, by vm_phys_alloc_npages orhas
vm_phys_alloc_contig, has everyno page marked with the pool value. SuchThe memory is freed by
memory can be freed all at once with vm_phys_free_contignpages, or one pageand that caller provides the pool value as a parameter.
Where the pool value is needed, in vm_page_free_toq, it has been supplied by
the function that called uma_zalloc to allocate it from the pgcache.
4. Memory allocated as a number of pages, by vm_phys_alloc_contig, has
every page marked with the pool value. Such memory can be freed all at once
with vm_phys_free_contig, or one page at a time with vm_phys_free_pages(m, 0).
4. A range of pages with all pool fields set to VM_NFREEPOOL can be
freed with vm_phys_enqueue_contig, which passes the pool value as a
parameter. The function vm_page_startup uses it to initialize the
buddy queues, and vm_reserv_break uses it to return to the buddy
queues unused pages from a broken reservation.