Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Nov 2018 19:54:02 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341163 - head/sys/vm
Message-ID:  <201811281954.wASJs2QB091761@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811281954.wASJs2QB091761>