Print this page
9525 kmem_dump_size is a corrupting influence
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Dan McDonald <danmcd@joyent.com>
        
*** 19,29 ****
   * CDDL HEADER END
   */
  
  /*
   * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
!  * Copyright 2016 Joyent, Inc.
   */
  
  #include <sys/types.h>
  #include <sys/param.h>
  #include <sys/systm.h>
--- 19,29 ----
   * CDDL HEADER END
   */
  
  /*
   * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
!  * Copyright 2018 Joyent, Inc.
   */
  
  #include <sys/types.h>
  #include <sys/param.h>
  #include <sys/systm.h>
*** 72,81 ****
--- 72,83 ----
  #include <sys/clock_impl.h>
  #include <sys/hold_page.h>
  
  #include <bzip2/bzlib.h>
  
+ #define ONE_GIG (1024 * 1024 * 1024UL)
+ 
  /*
   * Crash dump time is dominated by disk write time.  To reduce this,
   * the stronger compression method bzip2 is applied to reduce the dump
   * size and hence reduce I/O time.  However, bzip2 is much more
   * computationally expensive than the existing lzjb algorithm, so to
*** 136,146 ****
  #define MINCPU_NOT_SET  ((uint_t)-1)
  uint_t dump_plat_mincpu = MINCPU_NOT_SET;
  
  /* tunables for pre-reserved heap */
  uint_t dump_kmem_permap = 1024;
! uint_t dump_kmem_pages = 8;
  
  /* Define multiple buffers per helper to avoid stalling */
  #define NCBUF_PER_HELPER        2
  #define NCMAP_PER_HELPER        4
  
--- 138,148 ----
  #define MINCPU_NOT_SET  ((uint_t)-1)
  uint_t dump_plat_mincpu = MINCPU_NOT_SET;
  
  /* tunables for pre-reserved heap */
  uint_t dump_kmem_permap = 1024;
! uint_t dump_kmem_pages = 0;
  
  /* Define multiple buffers per helper to avoid stalling */
  #define NCBUF_PER_HELPER        2
  #define NCMAP_PER_HELPER        4
  
*** 677,691 ****
                  new->maxvm = vmem_xalloc(heap_arena, new->maxvmsize,
                      CBUF_MAPSIZE, 0, 0, NULL, NULL, VM_SLEEP);
          }
  
          /*
!          * Reserve memory for kmem allocation calls made during crash
!          * dump.  The hat layer allocates memory for each mapping
!          * created, and the I/O path allocates buffers and data structs.
!          * Add a few pages for safety.
           */
          kmem_dump_init((new->ncmap * dump_kmem_permap) +
              (dump_kmem_pages * PAGESIZE));
  
          /* set new config pointers */
          *old = *new;
--- 679,705 ----
                  new->maxvm = vmem_xalloc(heap_arena, new->maxvmsize,
                      CBUF_MAPSIZE, 0, 0, NULL, NULL, VM_SLEEP);
          }
  
          /*
!          * Reserve memory for kmem allocation calls made during crash dump.  The
!          * hat layer allocates memory for each mapping created, and the I/O path
!          * allocates buffers and data structs.
!          *
!          * On larger systems, we easily exceed the lower amount, so we need some
!          * more space; the cut-over point is relatively arbitrary.  If we run
!          * out, the only impact is that kmem state in the dump becomes
!          * inconsistent.
           */
+ 
+         if (dump_kmem_pages == 0) {
+                 if (physmem > (16 * ONE_GIG) / PAGESIZE)
+                         dump_kmem_pages = 20;
+                 else
+                         dump_kmem_pages = 8;
+         }
+ 
          kmem_dump_init((new->ncmap * dump_kmem_permap) +
              (dump_kmem_pages * PAGESIZE));
  
          /* set new config pointers */
          *old = *new;