41 #include <sys/types.h> 42 #include <sys/mount.h> 44 #include <sys/fcntl.h> 61 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;
125 if ((pr - vpm->
regions) >= 256)
164 for (i = 0; i < pr->
n_pages; i++)
168 if ((
move_pages (0, 1, &ptr, 0, &node, 0) == 0) && (numa_node != node))
170 clib_warning (
"physmem page for region \'%s\' allocated on the" 171 " wrong numa node (requested %u actual %u)",
195 memset (pr, 0,
sizeof (*pr));
253 vlib_cli_output (vm,
"index %u name '%s' page-size %uKB num-pages %d " 254 "numa-node %u fd %d\n",
255 pr->index, pr->name, (1 << (pr->log2_page_size -10)),
256 pr->n_pages, pr->numa_node, pr->fd);
258 vlib_cli_output (vm,
" %U", format_mheap, pr->heap, 1);
260 vlib_cli_output (vm,
" no heap\n");
268 .path =
"show physmem",
269 .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
#define VLIB_PHYSMEM_MAIN_F_HAVE_PAGEMAP
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 descriptor, 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
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)
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