41 #include <sys/types.h> 42 #include <sys/mount.h> 44 #include <sys/fcntl.h> 61 uword lo_offset, hi_offset;
90 hi_offset = lo_offset + n_bytes - 1;
104 for (i = 0; i <
vec_len (to_free); i++)
106 #if USE_DLMALLOC == 0 115 #if USE_DLMALLOC == 0 116 return lo_offset != ~0 ? (
void *) (pr->
heap + lo_offset) : 0;
118 return lo_offset != ~0 ? (
void *) lo_offset : 0;
127 #if USE_DLMALLOC == 0 147 if ((pr - vpm->
regions) >= 256)
186 for (i = 0; i < pr->
n_pages; i++)
190 if ((
move_pages (0, 1, &ptr, 0, &node, 0) == 0) && (numa_node != node))
192 clib_warning (
"physmem page for region \'%s\' allocated on the" 193 " wrong numa node (requested %u actual %u)",
206 #if USE_DLMALLOC == 0 222 memset (pr, 0,
sizeof (*pr));
280 vlib_cli_output (vm,
"index %u name '%s' page-size %uKB num-pages %d " 281 "numa-node %u fd %d\n",
282 pr->index, pr->name, (1 << (pr->log2_page_size -10)),
283 pr->n_pages, pr->numa_node, pr->fd);
285 vlib_cli_output (vm,
" %U", format_mheap, pr->heap, 1);
287 vlib_cli_output (vm,
" no heap\n");
295 .path =
"show physmem",
296 .short_help =
"Show physical memory allocation",
#define CLIB_MEM_VM_F_HUGETLB
#define VLIB_PHYSMEM_F_INIT_MHEAP
void linux_vfio_dma_map_regions(vlib_main_t *vm)
#define VLIB_PHYSMEM_F_HUGETLB
void(* os_physmem_region_free)(struct vlib_main_t *vm, vlib_physmem_region_index_t idx)
#define CLIB_MEM_VM_F_NUMA_PREFER
void * addr
Pointer to allocated memory, set on successful allocation.
static clib_error_t * unix_physmem_region_alloc(vlib_main_t *vm, char *name, u32 size, u8 numa_node, u32 flags, vlib_physmem_region_index_t *idx)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int numa_node
numa node preference.
#define MHEAP_FLAG_THREAD_SAFE
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static uword min_log2(uword x)
static void * unix_physmem_alloc_aligned(vlib_main_t *vm, vlib_physmem_region_index_t idx, uword n_bytes, uword alignment)
#define VLIB_PHYSMEM_F_SHARED
DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, int locked)
#define VLIB_PHYSMEM_MAIN_F_HAVE_PAGEMAP
DLMALLOC_EXPORT void * mspace_get_aligned(mspace msp, unsigned long long n_user_data_bytes, unsigned long long align, unsigned long long align_offset)
memset(h->entries, 0, sizeof(h->entries[0])*entries)
clib_error_t * clib_mem_vm_ext_alloc(clib_mem_vm_alloc_t *a)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
void(* os_physmem_free)(struct vlib_main_t *vm, vlib_physmem_region_index_t idx, void *x)
#define MHEAP_FLAG_DISABLE_VM
char * name
Name for memory allocation, set by caller.
void *(* os_physmem_alloc_aligned)(struct vlib_main_t *vm, vlib_physmem_region_index_t idx, uword n_bytes, uword alignment)
#define clib_error_return(e, args...)
DLMALLOC_EXPORT void mspace_put_no_offset(mspace msp, void *p)
uword size
Allocation size, set by caller.
static vlib_physmem_region_t * vlib_physmem_get_region(vlib_main_t *vm, u8 index)
#define CLIB_MEM_VM_F_SHARED
int fd
File descriptor, set on successful allocation if CLIB_MEM_VM_F_SHARED is set.
DLMALLOC_EXPORT void mspace_disable_expand(mspace msp)
#define pool_put(P, E)
Free an object E in pool P.
#define CLIB_MEM_VM_F_NUMA_FORCE
clib_error_t * linux_vfio_init(vlib_main_t *vm)
void * mheap_get_aligned(void *v, uword n_user_data_bytes, uword align, uword align_offset, uword *offset_return)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
u32 flags
vm allocation flags: CLIB_MEM_VM_F_SHARED: request shared memory, file descriptor will be provided ...
#define VLIB_CLI_COMMAND(x,...)
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
#define CLIB_MEM_VM_F_HUGETLB_PREALLOC
#define CLIB_MEM_VM_F_LOCKED
static void unix_physmem_free(vlib_main_t *vm, vlib_physmem_region_index_t idx, void *x)
static uword pointer_to_uword(const void *p)
vlib_physmem_region_index_t index
static clib_error_t * show_physmem(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void mheap_put(void *v, uword uoffset)
static void unix_physmem_region_free(vlib_main_t *vm, vlib_physmem_region_index_t idx)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u64 * clib_mem_vm_get_paddr(void *mem, int log2_page_size, int n_pages)
clib_error_t * unix_physmem_init(vlib_main_t *vm)
vlib_physmem_main_t physmem_main
static long move_pages(int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags)
#define CLIB_CACHE_LINE_BYTES
clib_error_t *(* os_physmem_region_alloc)(struct vlib_main_t *vm, char *name, u32 size, u8 numa_node, u32 flags, vlib_physmem_region_index_t *idx)
u8 vlib_physmem_region_index_t
vlib_physmem_region_t * regions