X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Fmalloc_elem.c;h=c2c9461f1dfa636fb589436fc562cb316d3c67cb;hb=6a17919b0e2a482e0b3f505a048a2a3383e979e3;hp=885d00424bd47cdd61e01b1fb93b2b535d6adab9;hpb=2808a12cc05375e986ee1c9bb956bad8288c2b5a;p=dpdk.git diff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c index 885d00424b..c2c9461f1d 100644 --- a/lib/librte_eal/common/malloc_elem.c +++ b/lib/librte_eal/common/malloc_elem.c @@ -18,6 +18,7 @@ #include #include +#include "eal_private.h" #include "eal_internal_cfg.h" #include "eal_memalloc.h" #include "malloc_elem.h" @@ -42,6 +43,8 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align) rte_iova_t expected_iova; struct rte_memseg *ms; size_t page_sz, cur, max; + const struct internal_config *internal_conf = + eal_get_internal_configuration(); page_sz = (size_t)elem->msl->page_sz; data_start = RTE_PTR_ADD(elem, MALLOC_ELEM_HEADER_LEN); @@ -60,7 +63,7 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align) */ if (!elem->msl->external && (rte_eal_iova_mode() == RTE_IOVA_VA || - (internal_config.legacy_mem && + (internal_conf->legacy_mem && rte_eal_has_hugepages()))) return RTE_PTR_DIFF(data_end, contig_seg_start); @@ -171,7 +174,7 @@ malloc_elem_insert(struct malloc_elem *elem) next_elem = NULL; heap->last = elem; } else { - /* the new memory is somewhere inbetween start and end */ + /* the new memory is somewhere between start and end */ uint64_t dist_from_start, dist_from_end; dist_from_end = RTE_PTR_DIFF(heap->last, elem); @@ -340,18 +343,24 @@ remove_elem(struct malloc_elem *elem) static int next_elem_is_adjacent(struct malloc_elem *elem) { + const struct internal_config *internal_conf = + eal_get_internal_configuration(); + return elem->next == RTE_PTR_ADD(elem, elem->size) && elem->next->msl == elem->msl && - (!internal_config.match_allocations || + (!internal_conf->match_allocations || elem->orig_elem == elem->next->orig_elem); } static int prev_elem_is_adjacent(struct malloc_elem *elem) { + const struct internal_config *internal_conf = + eal_get_internal_configuration(); + return elem == RTE_PTR_ADD(elem->prev, elem->prev->size) && elem->prev->msl == elem->msl && - (!internal_config.match_allocations || + (!internal_conf->match_allocations || elem->orig_elem == elem->prev->orig_elem); } @@ -382,14 +391,14 @@ malloc_elem_free_list_index(size_t size) return 0; /* Find next power of 2 >= size. */ - log2 = sizeof(size) * 8 - __builtin_clzl(size-1); + log2 = sizeof(size) * 8 - __builtin_clzl(size - 1); /* Compute freelist index, based on log2(size). */ index = (log2 - MALLOC_MINSIZE_LOG2 + MALLOC_LOG2_INCREMENT - 1) / - MALLOC_LOG2_INCREMENT; + MALLOC_LOG2_INCREMENT; - return index <= RTE_HEAP_NUM_FREELISTS-1? - index: RTE_HEAP_NUM_FREELISTS-1; + return index <= RTE_HEAP_NUM_FREELISTS - 1 ? + index : RTE_HEAP_NUM_FREELISTS - 1; } /*