* vm_page_advise * * Apply the specified advice to the given page. */
| 4303 | * Apply the specified advice to the given page. |
| 4304 | */ |
| 4305 | void |
| 4306 | vm_page_advise(vm_page_t m, int advice) |
| 4307 | { |
| 4308 | |
| 4309 | VM_OBJECT_ASSERT_WLOCKED(m->object); |
| 4310 | vm_page_assert_xbusied(m); |
| 4311 | |
| 4312 | if (advice == MADV_FREE) |
| 4313 | /* |
| 4314 | * Mark the page clean. This will allow the page to be freed |
| 4315 | * without first paging it out. MADV_FREE pages are often |
| 4316 | * quickly reused by malloc(3), so we do not do anything that |
| 4317 | * would result in a page fault on a later access. |
| 4318 | */ |
| 4319 | vm_page_undirty(m); |
| 4320 | else if (advice != MADV_DONTNEED) { |
| 4321 | if (advice == MADV_WILLNEED) |
| 4322 | vm_page_activate(m); |
| 4323 | return; |
| 4324 | } |
| 4325 | |
| 4326 | if (advice != MADV_FREE && m->dirty == 0 && pmap_is_modified(m)) |
| 4327 | vm_page_dirty(m); |
| 4328 | |
| 4329 | /* |
| 4330 | * Clear any references to the page. Otherwise, the page daemon will |
| 4331 | * immediately reactivate the page. |
| 4332 | */ |
| 4333 | vm_page_aflag_clear(m, PGA_REFERENCED); |
| 4334 | |
| 4335 | /* |
| 4336 | * Place clean pages near the head of the inactive queue rather than |
| 4337 | * the tail, thus defeating the queue's LRU operation and ensuring that |
| 4338 | * the page will be reused quickly. Dirty pages not already in the |
| 4339 | * laundry are moved there. |
| 4340 | */ |
| 4341 | if (m->dirty == 0) |
| 4342 | vm_page_deactivate_noreuse(m); |
| 4343 | else if (!vm_page_in_laundry(m)) |
| 4344 | vm_page_launder(m); |
| 4345 | } |
| 4346 | |
| 4347 | /* |
| 4348 | * vm_page_grab_release |
no test coverage detected