Print this page
Revert "OS-8005 bhyve memory pressure needs to target ARC better (#354)"
This reverts commit a6033573eedd94118d2b9e65f45deca0bf4b42f7.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/arc.c
          +++ new/usr/src/uts/common/fs/zfs/arc.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  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   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2020 Joyent, Inc.
       23 + * Copyright (c) 2019, Joyent, Inc.
  24   24   * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
  25   25   * Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
  26   26   * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  27   27   * Copyright (c) 2011, 2019, Delphix. All rights reserved.
  28   28   * Copyright (c) 2020, George Amanakis. All rights reserved.
  29   29   * Copyright (c) 2020, The FreeBSD Foundation [1]
  30   30   *
  31   31   * [1] Portions of this software were developed by Allan Jude
  32   32   *     under sponsorship from the FreeBSD Foundation.
  33   33   */
↓ open down ↓ 4503 lines elided ↑ open up ↑
4537 4537  }
4538 4538  
4539 4539  typedef enum free_memory_reason_t {
4540 4540          FMR_UNKNOWN,
4541 4541          FMR_NEEDFREE,
4542 4542          FMR_LOTSFREE,
4543 4543          FMR_SWAPFS_MINFREE,
4544 4544          FMR_PAGES_PP_MAXIMUM,
4545 4545          FMR_HEAP_ARENA,
4546 4546          FMR_ZIO_ARENA,
4547      -        FMR_VIRT_MACHINE,       /* 'VM' seems ambiguous in this context */
4548 4547  } free_memory_reason_t;
4549 4548  
4550 4549  int64_t last_free_memory;
4551 4550  free_memory_reason_t last_free_reason;
4552 4551  
4553 4552  /*
4554 4553   * Additional reserve of pages for pp_reserve.
4555 4554   */
4556 4555  int64_t arc_pages_pp_reserve = 64;
4557 4556  
4558 4557  /*
4559 4558   * Additional reserve of pages for swapfs.
4560 4559   */
4561 4560  int64_t arc_swapfs_reserve = 64;
4562 4561  
4563      -static volatile uint64_t arc_virt_machine_reserved;
4564      -
4565 4562  /*
4566      - * XXX: A possible concern is that we allow arc_virt_machine_reserved to
4567      - * get so large that we cause the arc to perform a lot of additional
4568      - * work to keep the arc extremely small. We may want to set limits to
4569      - * the size of arc_virt_machine_reserved and disallow reservations
4570      - * beyond that limit.
4571      - */
4572      -int
4573      -arc_virt_machine_reserve(size_t pages)
4574      -{
4575      -        uint64_t newv;
4576      -
4577      -        newv = atomic_add_64_nv(&arc_virt_machine_reserved, pages);
4578      -
4579      -        /*
4580      -         * Since arc_virt_machine_reserved effectively lowers arc_c_max
4581      -         * as needed for vmm memory, if this request would put the arc
4582      -         * under arc_c_min, we reject it.  arc_c_min should be a value that
4583      -         * ensures reasonable performance for non-VMM stuff, as well as keep
4584      -         * us from dipping below lotsfree, which could trigger the pager
4585      -         * (and send the system toa grinding halt while it pages).
4586      -         *
4587      -         * XXX: This is a bit hacky and might be better done w/ a mutex
4588      -         * instead of atomic ops.
4589      -         */
4590      -        if (newv + arc_c_min > arc_c_max) {
4591      -                atomic_add_64(&arc_virt_machine_reserved, -(int64_t)pages);
4592      -                return (ENOMEM);
4593      -        }
4594      -
4595      -        zthr_wakeup(arc_reap_zthr);
4596      -        return (0);
4597      -}
4598      -
4599      -void
4600      -arc_virt_machine_release(size_t pages)
4601      -{
4602      -        atomic_add_64(&arc_virt_machine_reserved, -(int64_t)pages);
4603      -}
4604      -
4605      -/*
4606 4563   * Return the amount of memory that can be consumed before reclaim will be
4607 4564   * needed.  Positive if there is sufficient free memory, negative indicates
4608 4565   * the amount of memory that needs to be freed up.
4609 4566   */
4610 4567  static int64_t
4611 4568  arc_available_memory(void)
4612 4569  {
4613 4570          int64_t lowest = INT64_MAX;
4614 4571          int64_t n;
4615 4572          free_memory_reason_t r = FMR_UNKNOWN;
↓ open down ↓ 42 lines elided ↑ open up ↑
4658 4615           * drops below pages_pp_maximum, page locking mechanisms such as
4659 4616           * page_pp_lock() will fail.)
4660 4617           */
4661 4618          n = PAGESIZE * (availrmem - pages_pp_maximum -
4662 4619              arc_pages_pp_reserve);
4663 4620          if (n < lowest) {
4664 4621                  lowest = n;
4665 4622                  r = FMR_PAGES_PP_MAXIMUM;
4666 4623          }
4667 4624  
4668      -        /*
4669      -         * Check that we have enough memory for any virtual machines that
4670      -         * are running or starting. We add desfree to keep us out of
4671      -         * particularly dire circumstances.
4672      -         */
4673      -        n = PAGESIZE * (availrmem - arc_virt_machine_reserved - desfree);
4674      -        if (n < lowest) {
4675      -                lowest = n;
4676      -                r = FMR_VIRT_MACHINE;
4677      -        }
4678      -
4679 4625  #if defined(__i386)
4680 4626          /*
4681 4627           * If we're on an i386 platform, it's possible that we'll exhaust the
4682 4628           * kernel heap space before we ever run out of available physical
4683 4629           * memory.  Most checks of the size of the heap_area compare against
4684 4630           * tune.t_minarmem, which is the minimum available real memory that we
4685 4631           * can have in the system.  However, this is generally fixed at 25 pages
4686 4632           * which is so low that it's useless.  In this comparison, we seek to
4687 4633           * calculate the total heap-size, and reclaim if more than 3/4ths of the
4688 4634           * heap is allocated.  (Or, in the calculation, if less than 1/4th is
↓ open down ↓ 5468 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX