* Search for the domain with the least cached items and return it if it * is out of balance with the preferred domain. */
| 558 | * is out of balance with the preferred domain. |
| 559 | */ |
| 560 | static __noinline int |
| 561 | zone_domain_lowest(uma_zone_t zone, int pref) |
| 562 | { |
| 563 | long least, nitems, prefitems; |
| 564 | int domain; |
| 565 | int i; |
| 566 | |
| 567 | prefitems = least = LONG_MAX; |
| 568 | domain = 0; |
| 569 | for (i = 0; i < vm_ndomains; i++) { |
| 570 | nitems = ZDOM_GET(zone, i)->uzd_nitems; |
| 571 | if (nitems < least) { |
| 572 | domain = i; |
| 573 | least = nitems; |
| 574 | } |
| 575 | if (domain == pref) |
| 576 | prefitems = nitems; |
| 577 | } |
| 578 | if (prefitems < least * 2) |
| 579 | return (pref); |
| 580 | |
| 581 | return (domain); |
| 582 | } |
| 583 | |
| 584 | /* |
| 585 | * Search for the domain with the most cached items and return it or the |