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


1565         ctx = do_open(vmname);
1566 
1567         max_vcpus = num_vcpus_allowed(ctx);
1568         if (guest_ncpus > max_vcpus) {
1569                 fprintf(stderr, "%d vCPUs requested but only %d available\n",
1570                         guest_ncpus, max_vcpus);
1571                 exit(4);
1572         }
1573 
1574         fbsdrun_set_capabilities(ctx, BSP);
1575 
1576         memflags = 0;
1577         if (get_config_bool_default("memory.wired", false))
1578                 memflags |= VM_MEM_F_WIRED;
1579         if (get_config_bool_default("memory.guest_in_core", false))
1580                 memflags |= VM_MEM_F_INCORE;
1581         vm_set_memflags(ctx, memflags);
1582 #ifdef  __FreeBSD__
1583         err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
1584 #else
1585         err = vm_arc_resv(ctx, memsize);
1586         if (err != 0) {
1587                 (void) fprintf(stderr, "Could not shrink ARC: %s\n",
1588                     strerror(err));
1589                 exit(4);
1590         }
1591 
1592         do {
1593                 errno = 0;
1594                 err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
1595                 error = errno;
1596                 if (err != 0 && error == ENOMEM) {
1597                         (void) fprintf(stderr, "Unable to allocate memory "
1598                             "(%llu), retrying in 1 second\n", memsize);
1599                         sleep(1);
1600                 }
1601         } while (error == ENOMEM);
1602 #endif
1603         if (err) {
1604                 fprintf(stderr, "Unable to set up memory (%d)\n", errno);
1605                 exit(4);
1606         }
1607 
1608         error = init_msr();
1609         if (error) {
1610                 fprintf(stderr, "init_msr error %d", error);
1611                 exit(4);




1565         ctx = do_open(vmname);
1566 
1567         max_vcpus = num_vcpus_allowed(ctx);
1568         if (guest_ncpus > max_vcpus) {
1569                 fprintf(stderr, "%d vCPUs requested but only %d available\n",
1570                         guest_ncpus, max_vcpus);
1571                 exit(4);
1572         }
1573 
1574         fbsdrun_set_capabilities(ctx, BSP);
1575 
1576         memflags = 0;
1577         if (get_config_bool_default("memory.wired", false))
1578                 memflags |= VM_MEM_F_WIRED;
1579         if (get_config_bool_default("memory.guest_in_core", false))
1580                 memflags |= VM_MEM_F_INCORE;
1581         vm_set_memflags(ctx, memflags);
1582 #ifdef  __FreeBSD__
1583         err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
1584 #else







1585         do {
1586                 errno = 0;
1587                 err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
1588                 error = errno;
1589                 if (err != 0 && error == ENOMEM) {
1590                         (void) fprintf(stderr, "Unable to allocate memory "
1591                             "(%llu), retrying in 1 second\n", memsize);
1592                         sleep(1);
1593                 }
1594         } while (error == ENOMEM);
1595 #endif
1596         if (err) {
1597                 fprintf(stderr, "Unable to set up memory (%d)\n", errno);
1598                 exit(4);
1599         }
1600 
1601         error = init_msr();
1602         if (error) {
1603                 fprintf(stderr, "init_msr error %d", error);
1604                 exit(4);