| 437 | } |
| 438 | |
| 439 | static void |
| 440 | vm_page_domain_init(int domain) |
| 441 | { |
| 442 | struct vm_domain *vmd; |
| 443 | struct vm_pagequeue *pq; |
| 444 | int i; |
| 445 | |
| 446 | vmd = VM_DOMAIN(domain); |
| 447 | bzero(vmd, sizeof(*vmd)); |
| 448 | *__DECONST(const char **, &vmd->vmd_pagequeues[PQ_INACTIVE].pq_name) = |
| 449 | "vm inactive pagequeue"; |
| 450 | *__DECONST(const char **, &vmd->vmd_pagequeues[PQ_ACTIVE].pq_name) = |
| 451 | "vm active pagequeue"; |
| 452 | *__DECONST(const char **, &vmd->vmd_pagequeues[PQ_LAUNDRY].pq_name) = |
| 453 | "vm laundry pagequeue"; |
| 454 | *__DECONST(const char **, |
| 455 | &vmd->vmd_pagequeues[PQ_UNSWAPPABLE].pq_name) = |
| 456 | "vm unswappable pagequeue"; |
| 457 | vmd->vmd_domain = domain; |
| 458 | vmd->vmd_page_count = 0; |
| 459 | vmd->vmd_free_count = 0; |
| 460 | vmd->vmd_segs = 0; |
| 461 | vmd->vmd_oom = FALSE; |
| 462 | for (i = 0; i < PQ_COUNT; i++) { |
| 463 | pq = &vmd->vmd_pagequeues[i]; |
| 464 | TAILQ_INIT(&pq->pq_pl); |
| 465 | mtx_init(&pq->pq_mutex, pq->pq_name, "vm pagequeue", |
| 466 | MTX_DEF | MTX_DUPOK); |
| 467 | pq->pq_pdpages = 0; |
| 468 | vm_page_init_marker(&vmd->vmd_markers[i], i, 0); |
| 469 | } |
| 470 | mtx_init(&vmd->vmd_free_mtx, "vm page free queue", NULL, MTX_DEF); |
| 471 | mtx_init(&vmd->vmd_pageout_mtx, "vm pageout lock", NULL, MTX_DEF); |
| 472 | snprintf(vmd->vmd_name, sizeof(vmd->vmd_name), "%d", domain); |
| 473 | |
| 474 | /* |
| 475 | * inacthead is used to provide FIFO ordering for LRU-bypassing |
| 476 | * insertions. |
| 477 | */ |
| 478 | vm_page_init_marker(&vmd->vmd_inacthead, PQ_INACTIVE, PGA_ENQUEUED); |
| 479 | TAILQ_INSERT_HEAD(&vmd->vmd_pagequeues[PQ_INACTIVE].pq_pl, |
| 480 | &vmd->vmd_inacthead, plinks.q); |
| 481 | |
| 482 | /* |
| 483 | * The clock pages are used to implement active queue scanning without |
| 484 | * requeues. Scans start at clock[0], which is advanced after the scan |
| 485 | * ends. When the two clock hands meet, they are reset and scanning |
| 486 | * resumes from the head of the queue. |
| 487 | */ |
| 488 | vm_page_init_marker(&vmd->vmd_clock[0], PQ_ACTIVE, PGA_ENQUEUED); |
| 489 | vm_page_init_marker(&vmd->vmd_clock[1], PQ_ACTIVE, PGA_ENQUEUED); |
| 490 | TAILQ_INSERT_HEAD(&vmd->vmd_pagequeues[PQ_ACTIVE].pq_pl, |
| 491 | &vmd->vmd_clock[0], plinks.q); |
| 492 | TAILQ_INSERT_TAIL(&vmd->vmd_pagequeues[PQ_ACTIVE].pq_pl, |
| 493 | &vmd->vmd_clock[1], plinks.q); |
| 494 | } |
| 495 | |
| 496 | /* |
no test coverage detected