vm load: add SOS cmdline option for hugetlb

adding "hugepagesz=1G" and "hugepages=X" into SOS cmdline, for X, current
strategy is making it equal
	e820_mem.total_mem_size -CONFIG_REMAIN_1G_PAGES
if CONFIG_REMAIN_1G_PAGES is not set, it will use 3 by default.

CONFIG_CMA is added to indicate using cma cmdline option for SOS kernel,
by default system will use hugetlb cmdline option if no CONFIG_CMA defined.

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-04-13 09:54:06 +08:00 committed by lijinxia
parent a1145b0b55
commit 76091d0d01
4 changed files with 39 additions and 5 deletions

View File

@ -196,6 +196,7 @@ void obtain_e820_mem_info(void)
e820_mem.mem_bottom = UINT64_MAX;
e820_mem.mem_top = 0x00;
e820_mem.total_mem_size = 0;
e820_mem.max_ram_blk_base = 0;
e820_mem.max_ram_blk_size = 0;
@ -210,13 +211,15 @@ void obtain_e820_mem_info(void)
+ entry->length;
}
if (entry->baseaddr == UOS_DEFAULT_START_ADDR
&& entry->type == E820_TYPE_RAM) {
if (entry->type == E820_TYPE_RAM) {
e820_mem.total_mem_size += entry->length;
if (entry->baseaddr == UOS_DEFAULT_START_ADDR) {
e820_mem.max_ram_blk_base =
entry->baseaddr;
e820_mem.max_ram_blk_size = entry->length;
}
}
}
}
static void rebuild_vm0_e820(void)
@ -282,7 +285,9 @@ static void rebuild_vm0_e820(void)
entry->type = new_entry.type;
}
e820_mem.total_mem_size -= CONFIG_RAM_SIZE;
}
int prepare_vm0_memmap_and_e820(struct vm *vm)
{
unsigned int i;

View File

@ -45,4 +45,5 @@
#define CONFIG_LOW_RAM_SIZE 0x000CF000
#define CONFIG_RAM_START 0x6E000000
#define CONFIG_RAM_SIZE 0x02000000 /* 32M */
#define CONFIG_CMA
#endif /* BSP_CFG_H */

View File

@ -187,6 +187,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
strcpy_s((char *)hva, MEM_2K,
vm->sw.linux_info.bootargs_src_addr);
#ifdef CONFIG_CMA
/* add "cma=XXXXM@0xXXXXXXXX" to cmdline*/
if (is_vm0(vm) && (e820_mem.max_ram_blk_size > 0)) {
snprintf(dyn_bootargs, 100, " cma=%dM@0x%llx\n",
@ -197,6 +198,32 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
+vm->sw.linux_info.bootargs_size - 1,
100, dyn_bootargs);
}
#else
/* add "hugepagesz=1G hugepages=x" to cmdline for 1G hugepage
* reserving. Current strategy is "total_mem_size in Giga -
* remained 1G pages" for reserving.
*/
if (is_vm0(vm) && check_mmu_1gb_support(PTT_HOST)) {
int reserving_1g_pages;
#ifdef CONFIG_REMAIN_1G_PAGES
reserving_1g_pages = (e820_mem.total_mem_size >> 30) -
CONFIG_REMAIN_1G_PAGES;
#else
reserving_1g_pages = (e820_mem.total_mem_size >> 30) -
3;
#endif
if (reserving_1g_pages > 0) {
snprintf(dyn_bootargs, 100,
" hugepagesz=1G hugepages=%d\n",
reserving_1g_pages);
/* Delete '\n' at the end of cmdline */
strcpy_s((char *)hva
+vm->sw.linux_info.bootargs_size - 1,
100, dyn_bootargs);
}
}
#endif
/* Check if a RAM disk is present with Linux guest */
if (vm->sw.linux_info.ramdisk_src_addr) {

View File

@ -62,6 +62,7 @@ struct vhm_request;
struct e820_mem_params {
uint64_t mem_bottom;
uint64_t mem_top;
uint64_t total_mem_size;
uint64_t max_ram_blk_base; /* used for the start address of UOS */
uint64_t max_ram_blk_size;
};