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

Function vm_page_release_toq

freebsd/vm/vm_page.c:4146–4186  ·  view source on GitHub ↗

* Release a page back to the page queues in preparation for unwiring. */

Source from the content-addressed store, hash-verified

4144 * Release a page back to the page queues in preparation for unwiring.
4145 */
4146static void
4147vm_page_release_toq(vm_page_t m, uint8_t nqueue, const bool noreuse)
4148{
4149 vm_page_astate_t old, new;
4150 uint16_t nflag;
4151
4152 /*
4153 * Use a check of the valid bits to determine whether we should
4154 * accelerate reclamation of the page. The object lock might not be
4155 * held here, in which case the check is racy. At worst we will either
4156 * accelerate reclamation of a valid page and violate LRU, or
4157 * unnecessarily defer reclamation of an invalid page.
4158 *
4159 * If we were asked to not cache the page, place it near the head of the
4160 * inactive queue so that is reclaimed sooner.
4161 */
4162 if (noreuse || m->valid == 0) {
4163 nqueue = PQ_INACTIVE;
4164 nflag = PGA_REQUEUE_HEAD;
4165 } else {
4166 nflag = PGA_REQUEUE;
4167 }
4168
4169 old = vm_page_astate_load(m);
4170 do {
4171 new = old;
4172
4173 /*
4174 * If the page is already in the active queue and we are not
4175 * trying to accelerate reclamation, simply mark it as
4176 * referenced and avoid any queue operations.
4177 */
4178 new.flags &= ~PGA_QUEUE_OP_MASK;
4179 if (nflag != PGA_REQUEUE_HEAD && old.queue == PQ_ACTIVE)
4180 new.flags |= PGA_REFERENCED;
4181 else {
4182 new.flags |= nflag;
4183 new.queue = nqueue;
4184 }
4185 } while (!vm_page_pqstate_commit(m, &old, new));
4186}
4187
4188/*
4189 * Unwire a page and either attempt to free it or re-add it to the page queues.

Callers 2

vm_page_unwire_managedFunction · 0.85
vm_page_release_lockedFunction · 0.85

Calls 2

vm_page_astate_loadFunction · 0.85
vm_page_pqstate_commitFunction · 0.85

Tested by

no test coverage detected