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/i86pc/io/vmm/vmm.c
          +++ new/usr/src/uts/i86pc/io/vmm/vmm.c
↓ open down ↓ 30 lines elided ↑ open up ↑
  31   31   * This file and its contents are supplied under the terms of the
  32   32   * Common Development and Distribution License ("CDDL"), version 1.0.
  33   33   * You may only use this file in accordance with the terms of version
  34   34   * 1.0 of the CDDL.
  35   35   *
  36   36   * A full copy of the text of the CDDL should have accompanied this
  37   37   * source.  A copy of the CDDL is also available via the Internet at
  38   38   * http://www.illumos.org/license/CDDL.
  39   39   *
  40   40   * Copyright 2015 Pluribus Networks Inc.
  41      - * Copyright 2021 Joyent, Inc.
       41 + * Copyright 2018 Joyent, Inc.
  42   42   * Copyright 2021 Oxide Computer Company
  43   43   * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
  44   44   */
  45   45  
  46   46  #include <sys/cdefs.h>
  47   47  __FBSDID("$FreeBSD$");
  48   48  
  49   49  #include <sys/param.h>
  50   50  #include <sys/systm.h>
  51   51  #include <sys/kernel.h>
↓ open down ↓ 130 lines elided ↑ open up ↑
 182  182          struct mem_seg  mem_segs[VM_MAX_MEMSEGS]; /* (o) guest memory regions */
 183  183          struct vmspace  *vmspace;               /* (o) guest's address space */
 184  184          char            name[VM_MAX_NAMELEN];   /* (o) virtual machine name */
 185  185          struct vcpu     vcpu[VM_MAXCPU];        /* (i) guest vcpus */
 186  186          /* The following describe the vm cpu topology */
 187  187          uint16_t        sockets;                /* (o) num of sockets */
 188  188          uint16_t        cores;                  /* (o) num of cores/socket */
 189  189          uint16_t        threads;                /* (o) num of threads/core */
 190  190          uint16_t        maxcpus;                /* (o) max pluggable cpus */
 191  191          uint64_t        boot_tsc_offset;        /* (i) TSC offset at VM boot */
 192      -        size_t          arc_resv;               /* # of pages take from ARC */
 193  192  
 194  193          struct ioport_config ioports;           /* (o) ioport handling */
 195  194  };
 196  195  
 197  196  static int vmm_initialized;
 198  197  
 199  198  
 200  199  static void
 201  200  nullop_panic(void)
 202  201  {
↓ open down ↓ 65 lines elided ↑ open up ↑
 268  267  
 269  268  /* Trap into hypervisor on all guest exceptions and reflect them back */
 270  269  static int trace_guest_exceptions;
 271  270  
 272  271  static void vm_free_memmap(struct vm *vm, int ident);
 273  272  static bool sysmem_mapping(struct vm *vm, struct mem_map *mm);
 274  273  static void vcpu_notify_event_locked(struct vcpu *vcpu, vcpu_notify_t);
 275  274  static bool vcpu_sleep_bailout_checks(struct vm *vm, int vcpuid);
 276  275  static int vcpu_vector_sipi(struct vm *vm, int vcpuid, uint8_t vector);
 277  276  
 278      -extern int arc_virt_machine_reserve(size_t);
 279      -extern void arc_virt_machine_release(size_t);
 280      -
 281  277  /* Flags for vtc_status */
 282  278  #define VTCS_FPU_RESTORED       1 /* guest FPU restored, host FPU saved */
 283  279  #define VTCS_FPU_CTX_CRITICAL   2 /* in ctx where FPU restore cannot be lazy */
 284  280  
 285  281  typedef struct vm_thread_ctx {
 286  282          struct vm       *vtc_vm;
 287  283          int             vtc_vcpuid;
 288  284          uint_t          vtc_status;
 289  285          enum vcpu_ustate vtc_ustate;
 290  286  } vm_thread_ctx_t;
↓ open down ↓ 325 lines elided ↑ open up ↑
 616  612                          mm->flags &= ~VM_MEMMAP_F_IOMMU;
 617  613                  }
 618  614          }
 619  615  
 620  616          if (destroy) {
 621  617                  for (i = 0; i < VM_MAX_MEMSEGS; i++)
 622  618                          vm_free_memseg(vm, i);
 623  619  
 624  620                  VMSPACE_FREE(vm->vmspace);
 625  621                  vm->vmspace = NULL;
 626      -
 627      -                arc_virt_machine_release(vm->arc_resv);
 628      -                vm->arc_resv = 0;
 629  622          }
 630  623  }
 631  624  
 632  625  void
 633  626  vm_destroy(struct vm *vm)
 634  627  {
 635  628          vm_cleanup(vm, true);
 636  629          free(vm, M_VM);
 637  630  }
 638  631  
↓ open down ↓ 3017 lines elided ↑ open up ↑
3656 3649  
3657 3650          vvk->vvk_time_init.value.ui64 = vcpu->ustate_total[VU_INIT];
3658 3651          vvk->vvk_time_run.value.ui64 = vcpu->ustate_total[VU_RUN];
3659 3652          vvk->vvk_time_idle.value.ui64 = vcpu->ustate_total[VU_IDLE];
3660 3653          vvk->vvk_time_emu_kern.value.ui64 = vcpu->ustate_total[VU_EMU_KERN];
3661 3654          vvk->vvk_time_emu_user.value.ui64 = vcpu->ustate_total[VU_EMU_USER];
3662 3655          vvk->vvk_time_sched.value.ui64 = vcpu->ustate_total[VU_SCHED];
3663 3656  
3664 3657          return (0);
3665 3658  }
3666      -
3667      -int
3668      -vm_arc_resv(struct vm *vm, uint64_t len)
3669      -{
3670      -        /* Since we already have the compat macros included, we use those */
3671      -        size_t pages = (size_t)roundup2(len, PAGE_SIZE) >> PAGE_SHIFT;
3672      -        int err = 0;
3673      -
3674      -        err = arc_virt_machine_reserve(pages);
3675      -        if (err != 0)
3676      -                return (err);
3677      -
3678      -        vm->arc_resv += pages;
3679      -        return (0);
3680      -}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX