From 7a90e500ba431575bf6771f88ad43380f9483061 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Thu, 9 Apr 2020 04:46:14 +0000 Subject: [PATCH] svm: use active fifo count in fifo test Type: improvement Signed-off-by: Florin Coras Change-Id: Id6c9dbf65523274768173e288431d7dbac55676d --- src/svm/fifo_segment.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index 15a5323454c..eb240b0ada1 100644 --- a/src/svm/fifo_segment.c +++ b/src/svm/fifo_segment.c @@ -90,6 +90,12 @@ fsh_active_fifos_update (fifo_segment_header_t * fsh, int inc) clib_atomic_fetch_add_rel (&fsh->n_active_fifos, inc); } +static inline u32 +fsh_n_active_fifos (fifo_segment_header_t * fsh) +{ + return clib_atomic_load_relax_n (&fsh->n_active_fifos); +} + static inline uword fsh_virtual_mem (fifo_segment_header_t * fsh) { @@ -1057,7 +1063,7 @@ fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs, u32 fifo_segment_num_fifos (fifo_segment_t * fs) { - return clib_atomic_load_relax_n (&fs->h->n_active_fifos); + return fsh_n_active_fifos (fs->h); } static u32 @@ -1215,17 +1221,7 @@ fifo_segment_fl_chunk_bytes (fifo_segment_t * fs) u8 fifo_segment_has_fifos (fifo_segment_t * fs) { - fifo_segment_header_t *fsh = fs->h; - fifo_segment_slice_t *fss; - int slice_index; - - for (slice_index = 0; slice_index < fs->n_slices; slice_index++) - { - fss = fsh_slice_get (fsh, slice_index); - if (fss->fifos) - return 1; - } - return 0; + return (fsh_n_active_fifos (fs->h) != 0); } svm_fifo_t * -- 2.16.6