diff options
Diffstat (limited to 'src/vlib/linux/physmem.c')
-rwxr-xr-x | src/vlib/linux/physmem.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/vlib/linux/physmem.c b/src/vlib/linux/physmem.c index a708aaec778..6c6b072f70a 100755 --- a/src/vlib/linux/physmem.c +++ b/src/vlib/linux/physmem.c @@ -69,10 +69,18 @@ unix_physmem_alloc_aligned (vlib_main_t * vm, vlib_physmem_region_index_t idx, while (1) { +#if USE_DLMALLOC == 0 + mheap_get_aligned (pr->heap, n_bytes, /* align */ alignment, /* align offset */ 0, &lo_offset); +#else + lo_offset = (uword) mspace_get_aligned (pr->heap, n_bytes, + alignment, ~0ULL /* offset */ ); + if (lo_offset == 0) + lo_offset = ~0ULL; +#endif /* Allocation failed? */ if (lo_offset == ~0) @@ -94,7 +102,13 @@ unix_physmem_alloc_aligned (vlib_main_t * vm, vlib_physmem_region_index_t idx, { uword i; for (i = 0; i < vec_len (to_free); i++) - mheap_put (pr->heap, to_free[i]); + { +#if USE_DLMALLOC == 0 + mheap_put (pr->heap, to_free[i]); +#else + mspace_put_no_offset (pr->heap, (void *) to_free[i]); +#endif + } vec_free (to_free); } @@ -106,7 +120,11 @@ unix_physmem_free (vlib_main_t * vm, vlib_physmem_region_index_t idx, void *x) { vlib_physmem_region_t *pr = vlib_physmem_get_region (vm, idx); /* Return object to region's heap. */ +#if USE_DLMALLOC == 0 mheap_put (pr->heap, x - pr->heap); +#else + mspace_put_no_offset (pr->heap, x); +#endif } static clib_error_t * @@ -181,10 +199,15 @@ unix_physmem_region_alloc (vlib_main_t * vm, char *name, u32 size, if (flags & VLIB_PHYSMEM_F_INIT_MHEAP) { +#if USE_DLMALLOC == 0 pr->heap = mheap_alloc_with_flags (pr->mem, pr->size, /* Don't want mheap mmap/munmap with IO memory. */ MHEAP_FLAG_DISABLE_VM | MHEAP_FLAG_THREAD_SAFE); +#else + pr->heap = create_mspace_with_base (pr->mem, pr->size, 1 /* locked */ ); + mspace_disable_expand (pr->heap); +#endif } *idx = pr->index; |