svn commit: r344550 - in head/sys: kern vm

Mark Johnston markj at
Mon Feb 25 19:22:15 UTC 2019

Author: markj
Date: Mon Feb 25 19:22:13 2019
New Revision: 344550

  Improve vmem tuning for platforms without a direct map.
  On platforms without a direct map (i.e., platforms without
  UMA_MD_SMALL_ALLOC defined), the boundary tag allocator reserves a
  number of tags for use when allocating a new slab of boundary tags,
  as such platforms require free boundary tags in order to allocate
  boundary tags.  r327899 increased the number of boundary tags required
  for a KVA allocation in the worst case, and the aforementioned
  reservation was not updated accordingly.  In some cases, this could
  lead to a system hang.  Fix the problem by increasing this reservation.
  Also reduce KVA_QUANTUM on systems lacking superpage support.
  The previous import quantum (4MB with a 4KB page size) was quite large
  for systems with limited KVA, and fragmentation in kernel_arena could
  cause kernel memory allocation failures even with a substantial amount
  of free KVA.
  Reported and tested by:	jhibbits
  Reviewed by:	alc, kib
  No objections:	jeff
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:


Modified: head/sys/kern/subr_vmem.c
--- head/sys/kern/subr_vmem.c	Mon Feb 25 19:18:32 2019	(r344549)
+++ head/sys/kern/subr_vmem.c	Mon Feb 25 19:22:13 2019	(r344550)
@@ -689,9 +689,11 @@ vmem_startup(void)
 	 * Reserve enough tags to allocate new tags.  We allow multiple
 	 * CPUs to attempt to allocate new tags concurrently to limit
-	 * false restarts in UMA.
+	 * false restarts in UMA.  vmem_bt_alloc() allocates from a per-domain
+	 * arena, which may involve importing a range from the kernel arena,
+	 * so we need to keep at least 2 * BT_MAXALLOC tags reserved.
-	uma_zone_reserve(vmem_bt_zone, BT_MAXALLOC * (mp_ncpus + 1) / 2);
+	uma_zone_reserve(vmem_bt_zone, 2 * BT_MAXALLOC * mp_ncpus);
 	uma_zone_set_allocf(vmem_bt_zone, vmem_bt_alloc);

Modified: head/sys/vm/vm_kern.c
--- head/sys/vm/vm_kern.c	Mon Feb 25 19:18:32 2019	(r344549)
+++ head/sys/vm/vm_kern.c	Mon Feb 25 19:22:13 2019	(r344550)
@@ -124,8 +124,8 @@ SYSCTL_ULONG(_vm, OID_AUTO, max_kernel_address, CTLFLA
-/* On non-superpage architectures want large import sizes. */
+/* On non-superpage architectures we want large import sizes. */

More information about the svn-src-all mailing list