aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-11-25 15:06:01 +0100
committerFlorin Coras <florin.coras@gmail.com>2020-11-26 17:45:36 +0000
commitf23b1514a85f603d17036a598b6e3f329441abe8 (patch)
tree2cddd5af9bed3b2fcb62528bce2b645bae1a0477
parentaa676749d80c815689c33dcd1973fad40d0be117 (diff)
svm: only try to pre-allocate requested number of fifo pairs
Type: fix Change-Id: I6f7679fd48d0ed98677c58f8c08d7e969e8e8220 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/svm/fifo_segment.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 815c5a29e8d..00e51cfce7d 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -485,6 +485,8 @@ fsh_try_alloc_fifo_hdr_batch (fifo_segment_header_t * fsh,
u8 *fmem;
int i;
+ ASSERT (batch_size != 0);
+
size = (uword) sizeof (*f) * batch_size;
oldheap = ssvm_push_heap (fsh->ssvm_sh);
@@ -522,6 +524,8 @@ fsh_try_alloc_chunk_batch (fifo_segment_header_t * fsh,
u8 *cmem;
int i;
+ ASSERT (batch_size != 0);
+
rounded_data_size = fs_freelist_index_to_size (fl_index);
total_chunk_bytes = (uword) batch_size *rounded_data_size;
size = (uword) (sizeof (*c) + rounded_data_size) * batch_size;
@@ -986,8 +990,11 @@ fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs,
for (i = 0; i < fs->n_slices; i++)
{
- fss = fsh_slice_get (fsh, i);
alloc_now = clib_min (pairs_per_slice, *n_fifo_pairs);
+ if (0 == alloc_now)
+ break;
+
+ fss = fsh_slice_get (fsh, i);
if (fs_try_alloc_fifo_batch (fsh, fss, rx_fl_index, alloc_now))
clib_warning ("rx prealloc failed: pairs %u", alloc_now);
if (fs_try_alloc_fifo_batch (fsh, fss, tx_fl_index, alloc_now))