Index: uvm_page.c =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_page.c,v retrieving revision 1.254 diff -p -u -r1.254 uvm_page.c --- uvm_page.c 23 Sep 2023 18:20:20 -0000 1.254 +++ uvm_page.c 14 Oct 2023 21:37:39 -0000 @@ -868,7 +883,7 @@ uvm_page_recolor(int newncolors) void uvm_page_rebucket(void) { - u_int min_numa, max_numa, npackage, shift; + u_int min_numa, max_numa, npackage, div; struct cpu_info *ci, *ci2, *ci3; CPU_INFO_ITERATOR cii; @@ -906,12 +921,11 @@ uvm_page_rebucket(void) /* * Figure out how to arrange the packages & buckets, and the total - * number of buckets we need. XXX 2 may not be the best factor. + * number of buckets we need. */ - for (shift = 0; npackage > PGFL_MAX_BUCKETS; shift++) { - npackage >>= 1; - } - uvm_page_redim(uvmexp.ncolors, npackage); + + div = howmany(npackage, PGFL_MAX_BUCKETS); + uvm_page_redim(uvmexp.ncolors, howmany(npackage, div)); /* * Now tell each CPU which bucket to use. In the outer loop, scroll @@ -927,7 +941,7 @@ uvm_page_rebucket(void) */ ci3 = ci2; do { - ci3->ci_data.cpu_uvm->pgflbucket = npackage >> shift; + ci3->ci_data.cpu_uvm->pgflbucket = npackage / div; ci3 = ci3->ci_sibling[CPUREL_PACKAGE]; } while (ci3 != ci2); npackage++; @@ -935,7 +949,7 @@ uvm_page_rebucket(void) } while (ci2 != ci->ci_sibling[CPUREL_PACKAGE1ST]); aprint_debug("UVM: using package allocation scheme, " - "%d package(s) per bucket\n", 1 << shift); + "%d package(s) per bucket\n", div); } /*