| 1423 | } |
| 1424 | |
| 1425 | static void |
| 1426 | vm_pageout_scan_inactive(struct vm_domain *vmd, int page_shortage) |
| 1427 | { |
| 1428 | struct timeval start, end; |
| 1429 | struct scan_state ss; |
| 1430 | struct vm_batchqueue rq; |
| 1431 | struct vm_page marker_page; |
| 1432 | vm_page_t m, marker; |
| 1433 | struct vm_pagequeue *pq; |
| 1434 | vm_object_t object; |
| 1435 | vm_page_astate_t old, new; |
| 1436 | int act_delta, addl_page_shortage, starting_page_shortage, refs; |
| 1437 | |
| 1438 | object = NULL; |
| 1439 | vm_batchqueue_init(&rq); |
| 1440 | getmicrouptime(&start); |
| 1441 | |
| 1442 | /* |
| 1443 | * The addl_page_shortage is an estimate of the number of temporarily |
| 1444 | * stuck pages in the inactive queue. In other words, the |
| 1445 | * number of pages from the inactive count that should be |
| 1446 | * discounted in setting the target for the active queue scan. |
| 1447 | */ |
| 1448 | addl_page_shortage = 0; |
| 1449 | |
| 1450 | /* |
| 1451 | * Start scanning the inactive queue for pages that we can free. The |
| 1452 | * scan will stop when we reach the target or we have scanned the |
| 1453 | * entire queue. (Note that m->a.act_count is not used to make |
| 1454 | * decisions for the inactive queue, only for the active queue.) |
| 1455 | */ |
| 1456 | starting_page_shortage = page_shortage; |
| 1457 | marker = &marker_page; |
| 1458 | vm_page_init_marker(marker, PQ_INACTIVE, 0); |
| 1459 | pq = &vmd->vmd_pagequeues[PQ_INACTIVE]; |
| 1460 | vm_pagequeue_lock(pq); |
| 1461 | vm_pageout_init_scan(&ss, pq, marker, NULL, pq->pq_cnt); |
| 1462 | while (page_shortage > 0 && (m = vm_pageout_next(&ss, true)) != NULL) { |
| 1463 | KASSERT((m->flags & PG_MARKER) == 0, |
| 1464 | ("marker page %p was dequeued", m)); |
| 1465 | |
| 1466 | /* |
| 1467 | * Don't touch a page that was removed from the queue after the |
| 1468 | * page queue lock was released. Otherwise, ensure that any |
| 1469 | * pending queue operations, such as dequeues for wired pages, |
| 1470 | * are handled. |
| 1471 | */ |
| 1472 | if (vm_pageout_defer(m, PQ_INACTIVE, false)) |
| 1473 | continue; |
| 1474 | |
| 1475 | /* |
| 1476 | * Lock the page's object. |
| 1477 | */ |
| 1478 | if (object == NULL || object != m->object) { |
| 1479 | if (object != NULL) |
| 1480 | VM_OBJECT_WUNLOCK(object); |
| 1481 | object = atomic_load_ptr(&m->object); |
| 1482 | if (__predict_false(object == NULL)) |
no test coverage detected