Author: markj
Date: Mon Feb 25 19:22:13 2019
New Revision: 344550
URL: https://svnweb.freebsd.org/changeset/base/344550

Log:
  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:        https://reviews.freebsd.org/D19337

Modified:
  head/sys/kern/subr_vmem.c
  head/sys/vm/vm_kern.c

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);
 #endif
 }

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
 #if VM_NRESERVLEVEL > 0
 #define        KVA_QUANTUM_SHIFT       (VM_LEVEL_0_ORDER + PAGE_SHIFT)
 #else
-/* On non-superpage architectures want large import sizes. */
-#define        KVA_QUANTUM_SHIFT       (10 + PAGE_SHIFT)
+/* On non-superpage architectures we want large import sizes. */
+#define        KVA_QUANTUM_SHIFT       (8 + PAGE_SHIFT)
 #endif
 #define        KVA_QUANTUM             (1 << KVA_QUANTUM_SHIFT)
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to