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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/kmem.c
          +++ new/usr/src/uts/common/os/kmem.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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   * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
  24   24   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright (c) 2017, Joyent, Inc.
  25   26   */
  26   27  
  27   28  /*
  28   29   * Kernel memory allocator, as described in the following two papers and a
  29   30   * statement about the consolidator:
  30   31   *
  31   32   * Jeff Bonwick,
  32   33   * The Slab Allocator: An Object-Caching Kernel Memory Allocator.
  33   34   * Proceedings of the Summer 1994 Usenix Conference.
  34   35   * Available as /shared/sac/PSARC/1994/028/materials/kmem.pdf.
↓ open down ↓ 3207 lines elided ↑ open up ↑
3242 3243          for (cpu_seqid = 0; cpu_seqid < max_ncpus; cpu_seqid++) {
3243 3244                  kmem_cpu_cache_t *ccp = &cp->cache_cpu[cpu_seqid];
3244 3245                  mutex_enter(&ccp->cc_lock);
3245 3246                  ccp->cc_magsize = cp->cache_magtype->mt_magsize;
3246 3247                  mutex_exit(&ccp->cc_lock);
3247 3248          }
3248 3249  
3249 3250  }
3250 3251  
3251 3252  /*
3252      - * Reap (almost) everything right now.
     3253 + * Allow our caller to determine if there are running reaps.
     3254 + *
     3255 + * This call is very conservative and may return B_TRUE even when
     3256 + * reaping activity isn't active. If it returns B_FALSE, then reaping
     3257 + * activity is definitely inactive.
3253 3258   */
     3259 +boolean_t
     3260 +kmem_cache_reap_active(void)
     3261 +{
     3262 +        return (!taskq_empty(kmem_taskq));
     3263 +}
     3264 +
     3265 +/*
     3266 + * Reap (almost) everything soon.
     3267 + *
     3268 + * Note: this does not wait for the reap-tasks to complete. Caller
     3269 + * should use kmem_cache_reap_active() (above) and/or moderation to
     3270 + * avoid scheduling too many reap-tasks.
     3271 + */
3254 3272  void
3255      -kmem_cache_reap_now(kmem_cache_t *cp)
     3273 +kmem_cache_reap_soon(kmem_cache_t *cp)
3256 3274  {
3257 3275          ASSERT(list_link_active(&cp->cache_link));
3258 3276  
3259 3277          kmem_depot_ws_zero(cp);
3260 3278  
3261 3279          (void) taskq_dispatch(kmem_taskq,
3262 3280              (task_func_t *)kmem_depot_ws_reap, cp, TQ_SLEEP);
3263      -        taskq_wait(kmem_taskq);
3264 3281  }
3265 3282  
3266 3283  /*
3267 3284   * Recompute a cache's magazine size.  The trade-off is that larger magazines
3268 3285   * provide a higher transfer rate with the depot, while smaller magazines
3269 3286   * reduce memory consumption.  Magazine resizing is an expensive operation;
3270 3287   * it should not be done frequently.
3271 3288   *
3272 3289   * Changes to the magazine size are serialized by the kmem_taskq lock.
3273 3290   *
↓ open down ↓ 2148 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX