diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -729,8 +729,12 @@ * estimating the number we need based on the number of pages * in the system. */ - n = maxswzone != 0 ? maxswzone / sizeof(struct swblk) : - vm_cnt.v_page_count / 2; + if (maxswzone > 0) { + n = maxswzone / sizeof(struct swblk); + } else { + n = vm_cnt.v_page_count / 2; + maxswzone = n * sizeof(struct swblk); + } swpctrie_zone = uma_zcreate("swpctrie", pctrie_node_size(), NULL, NULL, pctrie_zone_init, NULL, UMA_ALIGN_PTR, 0); swblk_zone = uma_zcreate("swblk", sizeof(struct swblk), NULL, NULL, @@ -2669,21 +2673,22 @@ } /* - * Check that the total amount of swap currently configured does not - * exceed half the theoretical maximum. If it does, print a warning - * message. + * Check that the total amount of swap does not exceed or approach the + * theoretical maximum, and print a warning if it does. */ static void swapon_check_swzone(void) { - - /* recommend using no more than half that amount */ - if (swap_total > swap_maxpages / 2) { + if (swap_total > swap_maxpages) { + printf("warning: total configured swap (%lu pages) " + "exceeds maximum supported amount (%lu pages).\n" + "warning: increase kern.maxswzone " + "or reduce amount of swap.\n", + swap_total, swap_maxpages); + } else if (swap_total > swap_maxpages - swap_maxpages / 4) { printf("warning: total configured swap (%lu pages) " - "exceeds maximum recommended amount (%lu pages).\n", - swap_total, swap_maxpages / 2); - printf("warning: increase kern.maxswzone " - "or reduce amount of swap.\n"); + "exceeds recommended amount (%lu pages).\n", + swap_total, swap_maxpages - swap_maxpages / 4); } }