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

Function _vm_domain_allocate

freebsd/vm/vm_page.c:2023–2056  ·  view source on GitHub ↗

* Returns true if the number of free pages exceeds the minimum * for the request class and false otherwise. */

Source from the content-addressed store, hash-verified

2021 * for the request class and false otherwise.
2022 */
2023static int
2024_vm_domain_allocate(struct vm_domain *vmd, int req_class, int npages)
2025{
2026 u_int limit, old, new;
2027
2028 if (req_class == VM_ALLOC_INTERRUPT)
2029 limit = 0;
2030 else if (req_class == VM_ALLOC_SYSTEM)
2031 limit = vmd->vmd_interrupt_free_min;
2032 else
2033 limit = vmd->vmd_free_reserved;
2034
2035 /*
2036 * Attempt to reserve the pages. Fail if we're below the limit.
2037 */
2038 limit += npages;
2039 old = vmd->vmd_free_count;
2040 do {
2041 if (old < limit)
2042 return (0);
2043 new = old - npages;
2044 } while (atomic_fcmpset_int(&vmd->vmd_free_count, &old, new) == 0);
2045
2046 /* Wake the page daemon if we've crossed the threshold. */
2047 if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
2048 pagedaemon_wakeup(vmd->vmd_domain);
2049
2050 /* Only update bitsets on transitions. */
2051 if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
2052 (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
2053 vm_domain_set(vmd);
2054
2055 return (1);
2056}
2057
2058int
2059vm_domain_allocate(struct vm_domain *vmd, int req, int npages)

Callers 2

vm_domain_allocateFunction · 0.85
vm_page_zone_importFunction · 0.85

Calls 3

vm_paging_neededFunction · 0.85
pagedaemon_wakeupFunction · 0.85
vm_domain_setFunction · 0.85

Tested by

no test coverage detected