aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/fifo_segment.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/svm/fifo_segment.c')
-rw-r--r--src/svm/fifo_segment.c33
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