dm: add hugetlb memory management support

Type '-T' in DM cmdline to enable hugetlb memory allocation.
It enabled 2 level of huge page:
Level 1: size 2M, path: /run/hugepage/acrn/huge_lv1/guid
Level 2: size 1G, path: /run/hugepage/acrn/huge_lv2/guid

NOTE:
before running, please make sure system already have enough hugepages
reserved under:
/sys/kernel/mm/hugepages/hugepages-xxxxkB/nr_hugepages

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
This commit is contained in:
Jason Chen CJ
2018-03-14 22:03:52 +08:00
committed by Jack Ren
parent ac5da17e52
commit 4cad694be2
6 changed files with 546 additions and 9 deletions

View File

@@ -78,6 +78,7 @@ char *guest_uuid_str;
char *vsbl_file_name;
uint8_t trusty_enabled;
bool stdio_in_use;
bool hugetlb;
static int guest_vmexit_on_hlt, guest_vmexit_on_pause;
static int virtio_msix = 1;
@@ -127,7 +128,7 @@ static void
usage(int code)
{
fprintf(stderr,
"Usage: %s [-abehuwxACHPSWY] [-c vcpus] [-g <gdb port>] [-l <lpc>]\n"
"Usage: %s [-abehuwxACHPSTWY] [-c vcpus] [-g <gdb port>] [-l <lpc>]\n"
" %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] \n"
" %*s [--vsbl vsbl_file_name] [--part_info part_info_name]\n"
" %*s [--enable_trusty] <vm>\n"
@@ -150,6 +151,7 @@ usage(int code)
" -U: uuid\n"
" -w: ignore unimplemented MSRs\n"
" -W: force virtio to use single-vector MSI\n"
" -T: use hugetlb for memory allocation\n"
" -x: local apic is in x2APIC mode\n"
" -Y: disable MPtable generation\n"
" -k: kernel image path\n"
@@ -601,11 +603,12 @@ main(int argc, char *argv[])
rtc_localtime = 1;
memflags = 0;
quit_vm_loop = 0;
hugetlb = 0;
if (signal(SIGINT, sig_handler_term) == SIG_ERR)
fprintf(stderr, "cannot register handler for SIGINT\n");
optstr = "abehuwxACHIMPSWYvk:r:B:p:g:c:s:m:l:U:G:i:";
optstr = "abehuwxACHIMPSTWYvk:r:B:p:g:c:s:m:l:U:G:i:";
while ((c = getopt_long(argc, argv, optstr, long_options,
&option_idx)) != -1) {
switch (c) {
@@ -689,6 +692,10 @@ main(int argc, char *argv[])
case 'W':
virtio_msix = 0;
break;
case 'T':
if (check_hugetlb_support())
hugetlb = 1;
break;
case 'x':
x2apic_mode = 1;
break;