summaryrefslogtreecommitdiffstats
path: root/src/svm
diff options
context:
space:
mode:
Diffstat (limited to 'src/svm')
-rw-r--r--src/svm/fifo_segment.c15
-rw-r--r--src/svm/fifo_types.h1
-rw-r--r--src/svm/svm_fifo.c7
3 files changed, 12 insertions, 11 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)
{
diff --git a/src/svm/fifo_types.h b/src/svm/fifo_types.h
index f0a286d46a0..a80130b0e92 100644
--- a/src/svm/fifo_types.h
+++ b/src/svm/fifo_types.h
@@ -120,6 +120,7 @@ struct fifo_segment_header_
u8 n_slices; /**< Number of slices */
u8 high_watermark; /**< Memory pressure watermark high */
u8 low_watermark; /**< Memory pressure watermark low */
+ u8 pct_first_alloc; /**< Pct of fifo size to alloc */
};
#endif /* SRC_SVM_FIFO_TYPES_H_ */
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index 0168c08e49c..971eda351d5 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -368,7 +368,7 @@ void
svm_fifo_init (svm_fifo_t * f, u32 size)
{
svm_fifo_chunk_t *c, *prev;
- u32 first_chunk, min_alloc;
+ u32 min_alloc;
f->size = size;
f->ooos_list_head = OOO_SEGMENT_INVALID_INDEX;
@@ -378,9 +378,8 @@ svm_fifo_init (svm_fifo_t * f, u32 size)
f->head_chunk = f->tail_chunk = f->start_chunk;
f->ooo_deq = f->ooo_enq = 0;
- first_chunk = f->start_chunk->length;
- min_alloc = first_chunk > 16 << 10 ? first_chunk >> 2 : 4096;
- min_alloc = clib_min (first_chunk, 64 << 10);
+ min_alloc = size > 32 << 10 ? size >> 3 : 4096;
+ min_alloc = clib_min (min_alloc, 64 << 10);
f->min_alloc = min_alloc;
/*