X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fsvm%2Ffifo_segment.c;h=eb240b0ada1ea1a75beb3218e835b920a3d5e739;hb=7a90e500ba431575bf6771f88ad43380f9483061;hp=5d374384a332f2e76f55a6fc65a2cc643c738988;hpb=d35887297d6320efb36c24ef123480f27a736b16;p=vpp.git diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index 5d374384a33..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) { @@ -312,7 +318,7 @@ fs_chunk_size_is_valid (fifo_segment_header_t * fsh, u32 size) * with a smaller FIFO. */ return size >= FIFO_SEGMENT_MIN_FIFO_SIZE - && size <= (1 << fsh->max_log2_chunk_size); + && size <= (1ULL << fsh->max_log2_chunk_size); } static svm_fifo_t * @@ -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 * @@ -1308,12 +1304,13 @@ format_fifo_segment_type (u8 * s, va_list * args) u8 * format_fifo_segment (u8 * s, va_list * args) { - u32 count, indent, active_fifos, free_fifos, fifo_hdr = 0; + u32 count, indent, active_fifos, free_fifos; fifo_segment_t *fs = va_arg (*args, fifo_segment_t *); int verbose __attribute__ ((unused)) = va_arg (*args, int); uword est_chunk_bytes, est_free_seg_bytes, free_chunks; uword chunk_bytes = 0, free_seg_bytes, chunk_size; uword tracked_cached_bytes; + uword fifo_hdr = 0, reserved; fifo_segment_header_t *fsh; fifo_segment_slice_t *fss; svm_fifo_chunk_t *c; @@ -1389,13 +1386,13 @@ format_fifo_segment (u8 * s, va_list * args) usage = (100.0 * in_use) / allocated; mem_st = fifo_segment_get_mem_status (fs); virt = fsh_virtual_mem (fsh); + reserved = fsh->n_reserved_bytes; s = format (s, "\n%Useg free bytes: %U (%lu) estimated: %U (%lu) reserved:" " %U (%lu)\n", format_white_space, indent + 2, format_memory_size, free_seg_bytes, free_seg_bytes, format_memory_size, est_free_seg_bytes, est_free_seg_bytes, - format_memory_size, fsh->n_reserved_bytes, - fsh->n_reserved_bytes); + format_memory_size, reserved, reserved); s = format (s, "%Uchunk free bytes: %U (%lu) estimated: %U (%lu) tracked:" " %U (%lu)\n", format_white_space, indent + 2, format_memory_size, chunk_bytes, chunk_bytes,