svn commit: r341163 - head/sys/vm
Gleb Smirnoff
glebius at FreeBSD.org
Wed Nov 28 19:54:03 UTC 2018
Author: glebius
Date: Wed Nov 28 19:54:02 2018
New Revision: 341163
URL: https://svnweb.freebsd.org/changeset/base/341163
Log:
Fix yet another edge case in uma_startup_count(). If zone size fits into
several pages, but leaves no space for struct uma_slab at the end we
miscalculate number of pages by one. Totally mimic keg_large_init() math
here to cover that problem.
Reported by: gallatin
Modified:
head/sys/vm/uma_core.c
Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c Wed Nov 28 19:17:27 2018 (r341162)
+++ head/sys/vm/uma_core.c Wed Nov 28 19:54:02 2018 (r341163)
@@ -1991,10 +1991,17 @@ uma_startup_count(int vm_zones)
#endif
/* Memory for the rest of startup zones, UMA and VM, ... */
- if (zsize > UMA_SLAB_SPACE)
- pages += (zones + vm_zones) *
- howmany(roundup2(zsize, UMA_BOOT_ALIGN), UMA_SLAB_SIZE);
- else if (roundup2(zsize, UMA_BOOT_ALIGN) > UMA_SLAB_SPACE)
+ if (zsize > UMA_SLAB_SPACE) {
+ /* See keg_large_init(). */
+ u_int ppera;
+
+ ppera = howmany(roundup2(zsize, UMA_BOOT_ALIGN), PAGE_SIZE);
+ if (PAGE_SIZE * ppera - roundup2(zsize, UMA_BOOT_ALIGN) <
+ SIZEOF_UMA_SLAB)
+ ppera++;
+ pages += (zones + vm_zones) * ppera;
+ } else if (roundup2(zsize, UMA_BOOT_ALIGN) > UMA_SLAB_SPACE)
+ /* See keg_small_init() special case for uk_ppera = 1. */
pages += zones;
else
pages += howmany(zones,
More information about the svn-src-head
mailing list