From f23b1514a85f603d17036a598b6e3f329441abe8 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Wed, 25 Nov 2020 15:06:01 +0100 Subject: svm: only try to pre-allocate requested number of fifo pairs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type: fix Change-Id: I6f7679fd48d0ed98677c58f8c08d7e969e8e8220 Signed-off-by: Benoît Ganne --- src/svm/fifo_segment.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)) -- cgit 1.2.3-korg