devicemodel/core/hugetlb.c
/* check if enough free huge pages for the User VM */
check if enough free huge pages for the User VM
check if enough free huge pages for the User VM
static bool hugetlb_check_memgap(void)
{
	int lvl, free_pages, need_pages;
	bool has_gap = false;
	for (lvl = HUGETLB_LV1; lvl < hugetlb_lv_max; lvl++) {
		if (hugetlb_priv[lvl].fd < 0) {
			hugetlb_priv[lvl].pages_delta = 0;
			continue;
		}
		free_pages = read_sys_info(hugetlb_priv[lvl].free_pages_path);
		need_pages = (hugetlb_priv[lvl].lowmem + hugetlb_priv[lvl].fbmem +
			hugetlb_priv[lvl].biosmem + hugetlb_priv[lvl].highmem) /
			hugetlb_priv[lvl].pg_size;
		hugetlb_priv[lvl].pages_delta = need_pages - free_pages;
		if (hugetlb_priv[lvl].pages_delta > 0)
			has_gap = true;
		pr_info("level %d free/need pages:%d/%d page size:0x%x\n", lvl,
			free_pages, need_pages, hugetlb_priv[lvl].pg_size);
	}
	return has_gap;
}
static bool hugetlb_check_memgap ( void ) { int lvl , free_pages , need_pages ; bool has_gap = false ; for ( lvl = HUGETLB_LV1 ; lvl < hugetlb_lv_max ; lvl ++ ) { if ( hugetlb_priv [ lvl ] . fd < 0 ) { hugetlb_priv [ lvl ] . pages_delta = 0 ; continue ; } free_pages = read_sys_info ( hugetlb_priv [ lvl ] . free_pages_path ) ; need_pages = ( hugetlb_priv [ lvl ] . lowmem + hugetlb_priv [ lvl ] . fbmem + hugetlb_priv [ lvl ] . biosmem + hugetlb_priv [ lvl ] . highmem ) / hugetlb_priv [ lvl ] . pg_size ; hugetlb_priv [ lvl ] . pages_delta = need_pages - free_pages ; if ( hugetlb_priv [ lvl ] . pages_delta > 0 ) has_gap = true ; pr_info ( " \n " , lvl , free_pages , need_pages , hugetlb_priv [ lvl ] . pg_size ) ; } return has_gap ; }
check if enough free huge pages for the User VM
check if enough free huge pages for the User VM
/* if delta > 0, it's a gap for needed pages, to be handled */