vppinfra: make default hugepage size configurable

i.e.

memory {
  default-hugepage-size 1G
}

Type: improvement
Change-Id: I822afb51712ae92f4e4992b8ffa33dcb15ccaef1
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 036890f..3b752cf 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -75,40 +75,6 @@
   clib_atomic_release (&clib_mem_main.map_lock);
 }
 
-__clib_export uword
-clib_mem_get_default_hugepage_size (void)
-{
-  unformat_input_t input;
-  static u32 size = 0;
-  int fd;
-
-  if (size)
-    goto done;
-
-  /*
-   * If the kernel doesn't support hugepages, /proc/meminfo won't
-   * say anything about it. Use the regular page size as a default.
-   */
-  size = clib_mem_get_page_size () / 1024;
-
-  if ((fd = open ("/proc/meminfo", 0)) == -1)
-    return 0;
-
-  unformat_init_clib_file (&input, fd);
-
-  while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (&input, "Hugepagesize:%_%u kB", &size))
-	;
-      else
-	unformat_skip_line (&input);
-    }
-  unformat_free (&input);
-  close (fd);
-done:
-  return 1024ULL * size;
-}
-
 static clib_mem_page_sz_t
 legacy_get_log2_default_hugepage_size (void)
 {
@@ -156,6 +122,8 @@
   else				/* likely kernel older than 4.14 */
     mm->log2_default_hugepage_sz = legacy_get_log2_default_hugepage_size ();
 
+  mm->log2_sys_default_hugepage_sz = mm->log2_default_hugepage_sz;
+
   /* numa nodes */
   va = mmap (0, page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE |
 	     MAP_ANONYMOUS, -1, 0);
@@ -270,7 +238,7 @@
 
   if (log2_page_size == mm->log2_page_sz)
     log2_page_size = CLIB_MEM_PAGE_SZ_DEFAULT;
-  else if (log2_page_size == mm->log2_default_hugepage_sz)
+  else if (log2_page_size == mm->log2_sys_default_hugepage_sz)
     log2_page_size = CLIB_MEM_PAGE_SZ_DEFAULT_HUGE;
 
   switch (log2_page_size)