summaryrefslogtreecommitdiffstats
path: root/src/svm/fifo_segment.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-02-02 19:30:39 +0000
committerDave Barach <openvpp@barachs.net>2020-02-25 19:18:49 +0000
commit2de9c0f92bb486072d8371a24d9b23fd85e1aa80 (patch)
treea152a70c5df089ff4a8ea2b7cabab75daa0c712e /src/svm/fifo_segment.c
parentd8f48e2166747b529aa23762ac314dd686590c89 (diff)
svm: minimal initial fifo
Type: refactor Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I4ee46a6c3c53c58199c275e20702f7fd11b60d9a
Diffstat (limited to 'src/svm/fifo_segment.c')
-rw-r--r--src/svm/fifo_segment.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 88600b84e36..7b1163e0750 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -294,8 +294,7 @@ fs_chunk_size_is_valid (fifo_segment_header_t * fsh, u32 size)
}
static svm_fifo_t *
-fs_try_alloc_fifo_freelist (fifo_segment_slice_t * fss,
- u32 fl_index, u32 data_bytes)
+fs_try_alloc_fifo_freelist (fifo_segment_slice_t * fss, u32 fl_index)
{
svm_fifo_chunk_t *c;
svm_fifo_t *f;
@@ -471,14 +470,16 @@ fs_try_alloc_fifo (fifo_segment_header_t * fsh, fifo_segment_slice_t * fss,
u32 fifo_sz, fl_index;
svm_fifo_t *f = 0;
uword n_free_bytes;
+ u32 min_size;
- fl_index = fs_freelist_for_size (data_bytes);
+ min_size = clib_max ((fsh->pct_first_alloc * data_bytes) / 100, 4096);
+ fl_index = fs_freelist_for_size (min_size);
fifo_sz = sizeof (svm_fifo_t) + sizeof (svm_fifo_chunk_t);
- fifo_sz += 1 << max_log2 (data_bytes);
+ fifo_sz += 1 << max_log2 (min_size);
if (fss->free_fifos && fss->free_chunks[fl_index])
{
- f = fs_try_alloc_fifo_freelist (fss, fl_index, data_bytes);
+ f = fs_try_alloc_fifo_freelist (fss, fl_index);
if (f)
{
fsh_cached_bytes_sub (fsh, fs_freelist_index_to_size (fl_index));
@@ -494,7 +495,7 @@ fs_try_alloc_fifo (fifo_segment_header_t * fsh, fifo_segment_slice_t * fss,
FIFO_SEGMENT_ALLOC_BATCH_SIZE))
goto done;
- f = fs_try_alloc_fifo_freelist (fss, fl_index, data_bytes);
+ f = fs_try_alloc_fifo_freelist (fss, fl_index);
if (f)
fsh_cached_bytes_sub (fsh, fs_freelist_index_to_size (fl_index));
goto done;
@@ -502,7 +503,7 @@ fs_try_alloc_fifo (fifo_segment_header_t * fsh, fifo_segment_slice_t * fss,
if (fifo_sz <= n_free_bytes)
{
void *oldheap = ssvm_push_heap (fsh->ssvm_sh);
- f = svm_fifo_alloc (data_bytes);
+ f = svm_fifo_alloc (min_size);
ssvm_pop_heap (oldheap);
if (f)
{