-#define CLIB_MEM_VM_F_SHARED (1 << 0)
-#define CLIB_MEM_VM_F_HUGETLB (1 << 1)
-#define CLIB_MEM_VM_F_NUMA_PREFER (1 << 2)
-#define CLIB_MEM_VM_F_NUMA_FORCE (1 << 3)
-#define CLIB_MEM_VM_F_HUGETLB_PREALLOC (1 << 4)
-#define CLIB_MEM_VM_F_LOCKED (1 << 5)
- u32 flags; /**< vm allocation flags:
- <br> CLIB_MEM_VM_F_SHARED: request shared memory, file
- descriptor will be provided on successful allocation.
- <br> CLIB_MEM_VM_F_HUGETLB: request hugepages.
- <br> CLIB_MEM_VM_F_NUMA_PREFER: numa_node field contains valid
- numa node preference.
- <br> CLIB_MEM_VM_F_NUMA_FORCE: fail if setting numa policy fails.
- <br> CLIB_MEM_VM_F_HUGETLB_PREALLOC: pre-allocate hugepages if
- number of available pages is not sufficient.
- <br> CLIB_MEM_VM_F_LOCKED: request locked memory.
- */
- char *name; /**< Name for memory allocation, set by caller. */
- uword size; /**< Allocation size, set by caller. */
- int numa_node; /**< numa node preference. Valid if CLIB_MEM_VM_F_NUMA_PREFER set. */
- void *addr; /**< Pointer to allocated memory, set on successful allocation. */
- int fd; /**< File descriptor, set on successful allocation if CLIB_MEM_VM_F_SHARED is set. */
- int log2_page_size; /* Page size in log2 format, set on successful allocation. */
- int n_pages; /* Number of pages. */
- uword requested_va; /**< Request fixed position mapping */
-} clib_mem_vm_alloc_t;
-
-clib_error_t *clib_mem_create_hugetlb_fd (char *name, int *fdp);
-clib_error_t *clib_mem_vm_ext_alloc (clib_mem_vm_alloc_t * a);
-void clib_mem_vm_ext_free (clib_mem_vm_alloc_t * a);
-u64 clib_mem_vm_get_page_size (int fd);
-uword clib_mem_get_default_hugepage_size (void);
-int clib_mem_vm_get_log2_page_size (int fd);
-u64 *clib_mem_vm_get_paddr (void *mem, int log2_page_size, int n_pages);
+ clib_mem_page_sz_t log2_page_sz;
+ uword total;
+ uword mapped;
+ uword not_mapped;
+ uword per_numa[CLIB_MAX_NUMAS];
+ uword unknown;
+} clib_mem_page_stats_t;
+
+void clib_mem_get_page_stats (void *start, clib_mem_page_sz_t log2_page_size,
+ uword n_pages, clib_mem_page_stats_t * stats);
+
+static_always_inline int
+vlib_mem_get_next_numa_node (int numa)
+{
+ clib_mem_main_t *mm = &clib_mem_main;
+ u32 bitmap = mm->numa_node_bitmap;