Print this page
9525 kmem_dump_size is a corrupting influence

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/dumpsubr.c
          +++ new/usr/src/uts/common/os/dumpsubr.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2016 Joyent, Inc.
       24 + * Copyright 2018 Joyent, Inc.
  25   25   */
  26   26  
  27   27  #include <sys/types.h>
  28   28  #include <sys/param.h>
  29   29  #include <sys/systm.h>
  30   30  #include <sys/vm.h>
  31   31  #include <sys/proc.h>
  32   32  #include <sys/file.h>
  33   33  #include <sys/conf.h>
  34   34  #include <sys/kmem.h>
↓ open down ↓ 32 lines elided ↑ open up ↑
  67   67  #include <vm/as.h>
  68   68  #include <vm/page.h>
  69   69  #include <vm/pvn.h>
  70   70  #include <vm/seg.h>
  71   71  #include <vm/seg_kmem.h>
  72   72  #include <sys/clock_impl.h>
  73   73  #include <sys/hold_page.h>
  74   74  
  75   75  #include <bzip2/bzlib.h>
  76   76  
       77 +#define ONE_GIG (1024 * 1024 * 1024UL)
       78 +
  77   79  /*
  78   80   * Crash dump time is dominated by disk write time.  To reduce this,
  79   81   * the stronger compression method bzip2 is applied to reduce the dump
  80   82   * size and hence reduce I/O time.  However, bzip2 is much more
  81   83   * computationally expensive than the existing lzjb algorithm, so to
  82   84   * avoid increasing compression time, CPUs that are otherwise idle
  83   85   * during panic are employed to parallelize the compression task.
  84   86   * Many helper CPUs are needed to prevent bzip2 from being a
  85   87   * bottleneck, and on systems with too few CPUs, the lzjb algorithm is
  86   88   * parallelized instead. Lastly, I/O and compression are performed by
↓ open down ↓ 44 lines elided ↑ open up ↑
 131  133   */
 132  134  uint_t dump_ncpu_low = 4;       /* minimum config for parallel lzjb */
 133  135  uint_t dump_bzip2_level = 1;    /* bzip2 level (1-9) */
 134  136  
 135  137  /* Use dump_plat_mincpu_default unless this variable is set by /etc/system */
 136  138  #define MINCPU_NOT_SET  ((uint_t)-1)
 137  139  uint_t dump_plat_mincpu = MINCPU_NOT_SET;
 138  140  
 139  141  /* tunables for pre-reserved heap */
 140  142  uint_t dump_kmem_permap = 1024;
 141      -uint_t dump_kmem_pages = 8;
      143 +uint_t dump_kmem_pages = 0;
 142  144  
 143  145  /* Define multiple buffers per helper to avoid stalling */
 144  146  #define NCBUF_PER_HELPER        2
 145  147  #define NCMAP_PER_HELPER        4
 146  148  
 147  149  /* minimum number of helpers configured */
 148  150  #define MINHELPERS      (dump_ncpu_low)
 149  151  #define MINCBUFS        (MINHELPERS * NCBUF_PER_HELPER)
 150  152  
 151  153  /*
↓ open down ↓ 520 lines elided ↑ open up ↑
 672  674  
 673  675          /* reserve VA to be backed with spare pages at crash time */
 674  676          if (new->maxsize > 0) {
 675  677                  new->maxsize = P2ROUNDUP(new->maxsize, PAGESIZE);
 676  678                  new->maxvmsize = P2ROUNDUP(new->maxsize, CBUF_MAPSIZE);
 677  679                  new->maxvm = vmem_xalloc(heap_arena, new->maxvmsize,
 678  680                      CBUF_MAPSIZE, 0, 0, NULL, NULL, VM_SLEEP);
 679  681          }
 680  682  
 681  683          /*
 682      -         * Reserve memory for kmem allocation calls made during crash
 683      -         * dump.  The hat layer allocates memory for each mapping
 684      -         * created, and the I/O path allocates buffers and data structs.
 685      -         * Add a few pages for safety.
      684 +         * Reserve memory for kmem allocation calls made during crash dump.  The
      685 +         * hat layer allocates memory for each mapping created, and the I/O path
      686 +         * allocates buffers and data structs.
      687 +         *
      688 +         * On larger systems, we easily exceed the lower amount, so we need some
      689 +         * more space; the cut-over point is relatively arbitrary.  If we run
      690 +         * out, the only impact is that kmem state in the dump becomes
      691 +         * inconsistent.
 686  692           */
      693 +
      694 +        if (dump_kmem_pages == 0) {
      695 +                if (physmem > (16 * ONE_GIG) / PAGESIZE)
      696 +                        dump_kmem_pages = 20;
      697 +                else
      698 +                        dump_kmem_pages = 8;
      699 +        }
      700 +
 687  701          kmem_dump_init((new->ncmap * dump_kmem_permap) +
 688  702              (dump_kmem_pages * PAGESIZE));
 689  703  
 690  704          /* set new config pointers */
 691  705          *old = *new;
 692  706  }
 693  707  
 694  708  /*
 695  709   * Define a struct memlist walker to optimize bitnum to pfn
 696  710   * lookup. The walker maintains the state of the list traversal.
↓ open down ↓ 2394 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX