Print this page
OS-6363 system went to dark side of moon for ~467 seconds OS-6404 ARC reclaim should throttle its calls to arc_kmem_reap_now() Reviewed by: Bryan Cantrill <bryan@joyent.com> Reviewed by: Dan McDonald <danmcd@joyent.com>


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
  28  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  29  */
  30 
  31 /*
  32  * Big Theory Statement for the virtual memory allocator.
  33  *
  34  * For a more complete description of the main ideas, see:
  35  *
  36  *      Jeff Bonwick and Jonathan Adams,
  37  *
  38  *      Magazines and vmem: Extending the Slab Allocator to Many CPUs and
  39  *      Arbitrary Resources.
  40  *
  41  *      Proceedings of the 2001 Usenix Conference.
  42  *      Available as http://www.usenix.org/event/usenix01/bonwick.html
  43  *
  44  * Section 1, below, is also the primary contents of vmem(9).  If for some
  45  * reason you are updating this comment, you will also wish to update the
  46  * manual.
  47  *
  48  * 1. General Concepts


1728                 /*
1729                  * Rescale the hash table to keep the hash chains short.
1730                  */
1731                 vmem_hash_rescale(vmp);
1732         }
1733         mutex_exit(&vmem_list_lock);
1734 
1735         (void) timeout(vmem_update, dummy, vmem_update_interval * hz);
1736 }
1737 
1738 void
1739 vmem_qcache_reap(vmem_t *vmp)
1740 {
1741         int i;
1742 
1743         /*
1744          * Reap any quantum caches that may be part of this vmem.
1745          */
1746         for (i = 0; i < VMEM_NQCACHE_MAX; i++)
1747                 if (vmp->vm_qcache[i])
1748                         kmem_cache_reap_now(vmp->vm_qcache[i]);
1749 }
1750 
1751 /*
1752  * Prepare vmem for use.
1753  */
1754 vmem_t *
1755 vmem_init(const char *heap_name,
1756     void *heap_start, size_t heap_size, size_t heap_quantum,
1757     void *(*heap_alloc)(vmem_t *, size_t, int),
1758     void (*heap_free)(vmem_t *, void *, size_t))
1759 {
1760         uint32_t id;
1761         int nseg = VMEM_SEG_INITIAL;
1762         vmem_t *heap;
1763 
1764         while (--nseg >= 0)
1765                 vmem_putseg_global(&vmem_seg0[nseg]);
1766 
1767         heap = vmem_create(heap_name,
1768             heap_start, heap_size, heap_quantum,




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
  28  * Copyright (c) 2017, Joyent, Inc.
  29  */
  30 
  31 /*
  32  * Big Theory Statement for the virtual memory allocator.
  33  *
  34  * For a more complete description of the main ideas, see:
  35  *
  36  *      Jeff Bonwick and Jonathan Adams,
  37  *
  38  *      Magazines and vmem: Extending the Slab Allocator to Many CPUs and
  39  *      Arbitrary Resources.
  40  *
  41  *      Proceedings of the 2001 Usenix Conference.
  42  *      Available as http://www.usenix.org/event/usenix01/bonwick.html
  43  *
  44  * Section 1, below, is also the primary contents of vmem(9).  If for some
  45  * reason you are updating this comment, you will also wish to update the
  46  * manual.
  47  *
  48  * 1. General Concepts


1728                 /*
1729                  * Rescale the hash table to keep the hash chains short.
1730                  */
1731                 vmem_hash_rescale(vmp);
1732         }
1733         mutex_exit(&vmem_list_lock);
1734 
1735         (void) timeout(vmem_update, dummy, vmem_update_interval * hz);
1736 }
1737 
1738 void
1739 vmem_qcache_reap(vmem_t *vmp)
1740 {
1741         int i;
1742 
1743         /*
1744          * Reap any quantum caches that may be part of this vmem.
1745          */
1746         for (i = 0; i < VMEM_NQCACHE_MAX; i++)
1747                 if (vmp->vm_qcache[i])
1748                         kmem_cache_reap_soon(vmp->vm_qcache[i]);
1749 }
1750 
1751 /*
1752  * Prepare vmem for use.
1753  */
1754 vmem_t *
1755 vmem_init(const char *heap_name,
1756     void *heap_start, size_t heap_size, size_t heap_quantum,
1757     void *(*heap_alloc)(vmem_t *, size_t, int),
1758     void (*heap_free)(vmem_t *, void *, size_t))
1759 {
1760         uint32_t id;
1761         int nseg = VMEM_SEG_INITIAL;
1762         vmem_t *heap;
1763 
1764         while (--nseg >= 0)
1765                 vmem_putseg_global(&vmem_seg0[nseg]);
1766 
1767         heap = vmem_create(heap_name,
1768             heap_start, heap_size, heap_quantum,