Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_page.c
Show First 20 Lines • Show All 2,532 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
vm_domain_free_unlock(vmd); | vm_domain_free_unlock(vmd); | ||||
if (order == VM_NFREEORDER) | if (order == VM_NFREEORDER) | ||||
error = EINVAL; | error = EINVAL; | ||||
} | } | ||||
} | } | ||||
if (m_mtx != NULL) | if (m_mtx != NULL) | ||||
mtx_unlock(m_mtx); | mtx_unlock(m_mtx); | ||||
if ((m = SLIST_FIRST(&free)) != NULL) { | vm_page_free_pages_toq(&free, false); | ||||
vmd = VM_DOMAIN(domain); | |||||
vm_domain_free_lock(vmd); | |||||
do { | |||||
MPASS(vm_phys_domain(m) == domain); | |||||
SLIST_REMOVE_HEAD(&free, plinks.s.ss); | |||||
vm_page_free_phys(vmd, m); | |||||
} while ((m = SLIST_FIRST(&free)) != NULL); | |||||
vm_domain_free_wakeup(vmd); | |||||
vm_domain_free_unlock(vmd); | |||||
} | |||||
return (error); | return (error); | ||||
} | } | ||||
#define NRUNS 16 | #define NRUNS 16 | ||||
CTASSERT(powerof2(NRUNS)); | CTASSERT(powerof2(NRUNS)); | ||||
#define RUN_INDEX(count) ((count) & (NRUNS - 1)) | #define RUN_INDEX(count) ((count) & (NRUNS - 1)) | ||||
▲ Show 20 Lines • Show All 680 Lines • ▼ Show 20 Lines | vm_page_free_toq(vm_page_t m) | ||||
if (!vm_page_free_prep(m, false)) | if (!vm_page_free_prep(m, false)) | ||||
return; | return; | ||||
vmd = vm_pagequeue_domain(m); | vmd = vm_pagequeue_domain(m); | ||||
vm_domain_free_lock(vmd); | vm_domain_free_lock(vmd); | ||||
vm_page_free_phys(vmd, m); | vm_page_free_phys(vmd, m); | ||||
vm_domain_free_wakeup(vmd); | vm_domain_free_wakeup(vmd); | ||||
vm_domain_free_unlock(vmd); | vm_domain_free_unlock(vmd); | ||||
} | |||||
/* | |||||
* vm_page_free_pages_toq: | |||||
* | |||||
* Returns a list of pages to the free list, disassociating it | |||||
* from any VM object. In other words, this is equivalent to | |||||
* calling vm_page_free_toq() for each page of a list of VM objects. | |||||
* | |||||
* The objects must be locked. The pages must be locked if it is | |||||
* managed. | |||||
*/ | |||||
void | |||||
vm_page_free_pages_toq(struct spglist *free, bool update_wire_count) | |||||
{ | |||||
vm_page_t m; | |||||
struct pglist pgl; | |||||
int count; | |||||
if (SLIST_EMPTY(free)) | |||||
return; | |||||
count = 0; | |||||
TAILQ_INIT(&pgl); | |||||
while ((m = SLIST_FIRST(free)) != NULL) { | |||||
count++; | |||||
SLIST_REMOVE_HEAD(free, plinks.s.ss); | |||||
if (vm_page_free_prep(m, false)) | |||||
TAILQ_INSERT_TAIL(&pgl, m, listq); | |||||
} | |||||
vm_page_free_phys_pglist(&pgl); | |||||
if (update_wire_count && count > 0) | |||||
vm_wire_sub(count); | |||||
} | } | ||||
/* | /* | ||||
* vm_page_wire: | * vm_page_wire: | ||||
* | * | ||||
* Mark this page as wired down. If the page is fictitious, then | * Mark this page as wired down. If the page is fictitious, then | ||||
* its wire count must remain one. | * its wire count must remain one. | ||||
* | * | ||||
* The page must be locked. | * The page must be locked. | ||||
*/ | */ | ||||
void | void | ||||
vm_page_wire(vm_page_t m) | vm_page_wire(vm_page_t m) | ||||
▲ Show 20 Lines • Show All 959 Lines • Show Last 20 Lines |