* Release a page back to the page queues in preparation for unwiring. */
| 4144 | * Release a page back to the page queues in preparation for unwiring. |
| 4145 | */ |
| 4146 | static void |
| 4147 | vm_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. |
no test coverage detected