diff options
author | Florin Coras <fcoras@cisco.com> | 2020-11-26 11:34:38 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-11-26 19:37:44 +0000 |
commit | fe1ab7e21663ef382fb59eed6ed5795e5c47c4fe (patch) | |
tree | be6adddc83947df0d782e21b272446f9d6b43848 | |
parent | 6bf3dfd2cab5fc907c4698a35801e027eb01ab17 (diff) |
svm: use internal function to prealloc fifo hdrs
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ic13828e235d01ec5b73658e4bdd19e510932713d
-rw-r--r-- | src/svm/fifo_segment.c | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index 00e51cfce7d..e25967ee81a 100644 --- a/src/svm/fifo_segment.c +++ b/src/svm/fifo_segment.c @@ -509,6 +509,8 @@ fsh_try_alloc_fifo_hdr_batch (fifo_segment_header_t * fsh, fmem += sizeof (*f); } + fsh_free_bytes_sub (fsh, size); + return 0; } @@ -885,38 +887,9 @@ fifo_segment_prealloc_fifo_hdrs (fifo_segment_t * fs, u32 slice_index, { fifo_segment_header_t *fsh = fs->h; fifo_segment_slice_t *fss; - svm_fifo_t *f; - void *oldheap; - uword size; - u8 *fmem; - int i; fss = fsh_slice_get (fsh, slice_index); - size = (uword) (sizeof (*f)) * batch_size; - - oldheap = ssvm_push_heap (fsh->ssvm_sh); - fmem = clib_mem_alloc_aligned_at_offset (size, CLIB_CACHE_LINE_BYTES, - 0 /* align_offset */ , - 0 /* os_out_of_memory */ ); - ssvm_pop_heap (oldheap); - - /* Out of space.. */ - if (fmem == 0) - return -1; - - /* Carve fifo + chunk space */ - for (i = 0; i < batch_size; i++) - { - f = (svm_fifo_t *) fmem; - memset (f, 0, sizeof (*f)); - f->next = fss->free_fifos; - fss->free_fifos = f; - fmem += sizeof (*f); - } - - fsh_free_bytes_sub (fsh, size); - - return 0; + return fsh_try_alloc_fifo_hdr_batch (fsh, fss, batch_size); } int |