From 8d0149d74c198f57dc795eb9e99cdb46112bd737 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Thu, 2 Jan 2020 19:22:51 +0000 Subject: session: fix per slice fifo prealloc Type: fix Signed-off-by: Florin Coras Change-Id: If6db37af6c2863a80d0787a98026b3b8171dad37 --- src/svm/fifo_segment.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index 944bf7cd34a..1d8d073a65b 100644 --- a/src/svm/fifo_segment.c +++ b/src/svm/fifo_segment.c @@ -700,10 +700,10 @@ fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs, u32 * n_fifo_pairs) { u32 rx_rounded_data_size, tx_rounded_data_size, pair_size, pairs_to_alloc; + u32 hdrs, pairs_per_slice, alloc_now; fifo_segment_header_t *fsh = fs->h; int rx_fl_index, tx_fl_index, i; fifo_segment_slice_t *fss; - u32 hdrs, pairs_per_slice; uword space_available; /* Parameter check */ @@ -735,6 +735,7 @@ fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs, pairs_to_alloc = space_available / pair_size; pairs_to_alloc = clib_min (pairs_to_alloc, *n_fifo_pairs); pairs_per_slice = pairs_to_alloc / fs->n_slices; + pairs_per_slice += pairs_to_alloc % fs->n_slices ? 1 : 0; if (!pairs_per_slice) return; @@ -742,14 +743,15 @@ fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs, for (i = 0; i < fs->n_slices; i++) { fss = fsh_slice_get (fsh, i); - if (fs_try_alloc_fifo_batch (fsh, fss, rx_fl_index, pairs_to_alloc)) - clib_warning ("rx prealloc failed: pairs %u", pairs_to_alloc); - if (fs_try_alloc_fifo_batch (fsh, fss, tx_fl_index, pairs_to_alloc)) - clib_warning ("tx prealloc failed: pairs %u", pairs_to_alloc); + alloc_now = clib_min (pairs_per_slice, *n_fifo_pairs); + 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)) + clib_warning ("tx prealloc failed: pairs %u", alloc_now); + + /* Account for the pairs allocated */ + *n_fifo_pairs -= alloc_now; } - - /* Account for the pairs allocated */ - *n_fifo_pairs -= pairs_per_slice * fs->n_slices; } int -- cgit 1.2.3-korg