41 #include <sys/types.h> 42 #include <sys/mount.h> 44 #include <sys/fcntl.h> 58 uword lo_offset, hi_offset;
82 hi_offset = lo_offset + n_bytes - 1;
96 for (i = 0; i <
vec_len (to_free); i++)
101 return lo_offset != ~0 ? pr->
heap + lo_offset : 0;
128 if ((pr - vpm->
regions) >= 256)
139 if ((flags & VLIB_PHYSMEM_F_FAKE) == 0)
165 if ((flags & VLIB_PHYSMEM_F_FAKE) == 0)
168 for (i = 0; i < pr->
n_pages; i++)
173 if (numa_node != node)
175 clib_warning (
"physmem page for region \'%s\' allocated on the" 176 " wrong numa node (requested %u actual %u)",
203 memset (pr, 0,
sizeof (*pr));
250 vlib_cli_output (vm,
"index %u name '%s' page-size %uKB num-pages %d " 251 "numa-node %u fd %d\n",
252 pr->index, pr->name, (1 << (pr->log2_page_size -10)),
253 pr->n_pages, pr->numa_node, pr->fd);
255 vlib_cli_output (vm,
" %U", format_mheap, pr->heap, 1);
257 vlib_cli_output (vm,
" no heap\n");
265 .path =
"show physmem",
266 .short_help =
"Show physical memory allocation",
#define CLIB_MEM_VM_F_HUGETLB
sll srl srl sll sra u16x4 i
#define VLIB_PHYSMEM_F_INIT_MHEAP
void vlib_buffer_add_mem_range(vlib_main_t *vm, uword start, uword size)
void(* os_physmem_region_free)(struct vlib_main_t *vm, vlib_physmem_region_index_t idx)
vlib_physmem_main_t physmem_main
#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 void * unix_physmem_alloc_aligned(vlib_main_t *vm, vlib_physmem_region_index_t idx, uword n_bytes, uword alignment)
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...)
uword size
Allocation size, set by caller.
static uword pointer_to_uword(const void *p)
static vlib_physmem_region_t * vlib_physmem_get_region(vlib_main_t *vm, u8 index)
#define CLIB_MEM_VM_F_SHARED
int fd
File desriptor, set on successful allocation if CLIB_MEM_VM_F_SHARED is set.
#define pool_put(P, E)
Free an object E in pool P.
#define CLIB_MEM_VM_F_NUMA_FORCE
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 destiptor will be provided o...
#define VLIB_CLI_COMMAND(x,...)
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
#define CLIB_MEM_VM_F_HUGETLB_PREALLOC
static void unix_physmem_free(vlib_main_t *vm, vlib_physmem_region_index_t idx, void *x)
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)
#define VLIB_PHYSMEM_F_FAKE
clib_error_t * unix_physmem_init(vlib_main_t *vm)
static long move_pages(int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags)
#define CLIB_CACHE_LINE_BYTES
#define VLIB_PHYSMEM_F_HAVE_BUFFERS
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