dm: use hugetlb by default

use hugetlb to set vm memory by default.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1 2018-06-29 10:54:16 +08:00 committed by lijinxia
parent 136d5c30fb
commit 652e37e908
6 changed files with 27 additions and 46 deletions

View File

@ -72,7 +72,6 @@ char *guest_uuid_str;
char *vsbl_file_name; char *vsbl_file_name;
uint8_t trusty_enabled; uint8_t trusty_enabled;
bool stdio_in_use; bool stdio_in_use;
bool hugetlb;
static int guest_vmexit_on_hlt, guest_vmexit_on_pause; static int guest_vmexit_on_hlt, guest_vmexit_on_pause;
static int virtio_msix = 1; static int virtio_msix = 1;
@ -145,7 +144,6 @@ usage(int code)
" -U: uuid\n" " -U: uuid\n"
" -w: ignore unimplemented MSRs\n" " -w: ignore unimplemented MSRs\n"
" -W: force virtio to use single-vector MSI\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" " -x: local apic is in x2APIC mode\n"
" -Y: disable MPtable generation\n" " -Y: disable MPtable generation\n"
" -k: kernel image path\n" " -k: kernel image path\n"
@ -649,14 +647,13 @@ main(int argc, char *argv[])
mptgen = 1; mptgen = 1;
memflags = 0; memflags = 0;
quit_vm_loop = 0; quit_vm_loop = 0;
hugetlb = 0;
if (signal(SIGHUP, sig_handler_term) == SIG_ERR) if (signal(SIGHUP, sig_handler_term) == SIG_ERR)
fprintf(stderr, "cannot register handler for SIGHUP\n"); fprintf(stderr, "cannot register handler for SIGHUP\n");
if (signal(SIGINT, sig_handler_term) == SIG_ERR) if (signal(SIGINT, sig_handler_term) == SIG_ERR)
fprintf(stderr, "cannot register handler for SIGINT\n"); fprintf(stderr, "cannot register handler for SIGINT\n");
optstr = "abehuwxACHIPSTWYvk:r:B:p:g:c:s:m:l:U:G:i:"; optstr = "abehuwxACHIPSWYvk:r:B:p:g:c:s:m:l:U:G:i:";
while ((c = getopt_long(argc, argv, optstr, long_options, while ((c = getopt_long(argc, argv, optstr, long_options,
&option_idx)) != -1) { &option_idx)) != -1) {
switch (c) { switch (c) {
@ -740,10 +737,6 @@ main(int argc, char *argv[])
case 'W': case 'W':
virtio_msix = 0; virtio_msix = 0;
break; break;
case 'T':
if (check_hugetlb_support())
hugetlb = 1;
break;
case 'x': case 'x':
x2apic_mode = 1; x2apic_mode = 1;
break; break;
@ -807,6 +800,11 @@ main(int argc, char *argv[])
if (argc != 1) if (argc != 1)
usage(1); usage(1);
if (!check_hugetlb_support()) {
fprintf(stderr, "check_hugetlb_support failed\n");
exit(1);
}
vmname = argv[0]; vmname = argv[0];
for (;;) { for (;;) {

View File

@ -385,7 +385,6 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
objsize = ctx->lowmem; objsize = ctx->lowmem;
} }
if (hugetlb)
return hugetlb_setup_memory(ctx); return hugetlb_setup_memory(ctx);
/* /*
@ -431,10 +430,8 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
void void
vm_unsetup_memory(struct vmctx *ctx) vm_unsetup_memory(struct vmctx *ctx)
{ {
if (hugetlb) {
hugetlb_unsetup_memory(ctx); hugetlb_unsetup_memory(ctx);
return; return;
}
if (ctx->lowmem > 0) if (ctx->lowmem > 0)
munmap(ctx->mmap_lowmem, ctx->lowmem); munmap(ctx->mmap_lowmem, ctx->lowmem);

View File

@ -159,6 +159,4 @@ int vm_reset_ptdev_intx_info(struct vmctx *ctx, int virt_pin, bool pic_pin);
int vm_create_vcpu(struct vmctx *ctx, uint16_t vcpu_id); int vm_create_vcpu(struct vmctx *ctx, uint16_t vcpu_id);
int vm_get_cpu_state(struct vmctx *ctx, void *state_buf); int vm_get_cpu_state(struct vmctx *ctx, void *state_buf);
extern bool hugetlb;
#endif /* _VMMAPI_H_ */ #endif /* _VMMAPI_H_ */

View File

@ -107,7 +107,7 @@ else
fi fi
acrn-dm -T -A -m $mem_size -c $2$boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \ acrn-dm -A -m $mem_size -c $2$boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-s 5,virtio-console,@pty:pty_port \ -s 5,virtio-console,@pty:pty_port \
-s 6,virtio-hyper_dmabuf \ -s 6,virtio-hyper_dmabuf \
-s 8,wdt-i6300esb \ -s 8,wdt-i6300esb \
@ -274,7 +274,7 @@ else
GVT_args='' GVT_args=''
fi fi
acrn-dm -T -A -m $mem_size -c $2$boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \ acrn-dm -A -m $mem_size -c $2$boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-l com1,stdio \ -l com1,stdio \
-s 9,virtio-net,$tap \ -s 9,virtio-net,$tap \
-s 3,virtio-blk$boot_dev_flag,/data/$5/$5.img \ -s 3,virtio-blk$boot_dev_flag,/data/$5/$5.img \

View File

@ -19,7 +19,7 @@ mem_size=1000M
# make sure there is enough 2M hugepages in the pool # make sure there is enough 2M hugepages in the pool
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
acrn-dm -T -A -m $mem_size -c $2 -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \ acrn-dm -A -m $mem_size -c $2 -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-s 2,pci-gvt -G "$3" \ -s 2,pci-gvt -G "$3" \
-s 5,virtio-console,@pty:pty_port \ -s 5,virtio-console,@pty:pty_port \
-s 6,virtio-hyper_dmabuf \ -s 6,virtio-hyper_dmabuf \

View File

@ -330,27 +330,17 @@ Set up Reference UOS
Device Manager memory allocation mechanism Device Manager memory allocation mechanism
========================================== ==========================================
There are two Device Manager memory allocation mechanisms available: The ACRN Device Manager (DM) virtual memory allocation uses the HugeTLB mechanism.
(You can read more about `HugeTLB in the linux kernel <https://linuxgazette.net/155/krishnakumar.html>`_
for more information about how this mechanism works.)
- Contiguous Memory Allocator (CMA), and For hugeTLB to work, you'll need to reserve huge pages:
- Huge Page Tables (HugeTLB). HugeTLB is the default.
To choose CMA, do the following: - For a (large) 1GB huge page reservation, add ``hugepagesz=1G hugepages=reserved_pg_num``
1) Add ``cma=reserved_mem_size@recommend_memory_offset-0``, (for example
``cma=2560M@0x100000000-0``) to the SOS cmdline in ``acrn.conf``
2) Start ``acrn-dm`` *without* the ``-T`` option
To support HugeTLB, do the following:
1) Do huge page reservation
- For 1G huge page reservation, add ``hugepagesz=1G hugepages=reserved_pg_num``
(for example, ``hugepagesz=1G hugepages=4``) to the SOS cmdline in (for example, ``hugepagesz=1G hugepages=4``) to the SOS cmdline in
``acrn.conf`` (for EFI) ``acrn.conf`` (for EFI)
- For 2M huge page reservation, after the SOS starts up, run the - For a (smaller) 2MB huge page reservation, after the SOS starts up, run the
command:: command::
echo reserved_pg_num > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages echo reserved_pg_num > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
@ -361,8 +351,6 @@ To support HugeTLB, do the following:
by using a 2M page, but make sure your huge page reservation size is by using a 2M page, but make sure your huge page reservation size is
large enough for your usage. large enough for your usage.
2) Start ``acrn-dm`` *with* the ``-T`` option.
Build ACRN from Source Build ACRN from Source
********************** **********************