From e700df8eb4f640762d5eced6623bbc2473ad0095 Mon Sep 17 00:00:00 2001 From: Miklos Tirpak Date: Wed, 13 Jan 2021 10:00:38 +0100 Subject: vlib: fix counter_will_expand prediction vlib_validate_combined_counter_will_expand() was calling _vec_resize_will_expand() with wrong arguments, which resulted in false return value. Apart from the initial call, it never indicated a vector resize. The callers relying on this function did not perform a barrier sync because of the wrong prediction even if the vector got extended by a subsequent vlib_validate_combined_counter() call. The fix introduces a new, simplified macro that is easier to call. vec_resize_will_expand() accepts the same arguments as vec_resize(). Type: fix Signed-off-by: Miklos Tirpak Change-Id: Ib2c2c8afd3e665e0e3d6ae62ff5cfa287acf670f --- src/vppinfra/vec.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/vppinfra/vec.h') diff --git a/src/vppinfra/vec.h b/src/vppinfra/vec.h index 1fcb5f1a374..e8146af7098 100644 --- a/src/vppinfra/vec.h +++ b/src/vppinfra/vec.h @@ -209,6 +209,21 @@ _vec_resize_will_expand (void *v, return 1; } +/** \brief Determine if vector will resize with next allocation + + @param V pointer to a vector + @param N number of elements to add + @return 1 if vector will resize 0 otherwise +*/ + +#define vec_resize_will_expand(V, N) \ + ({ \ + word _v (n) = (N); \ + word _v (l) = vec_len (V); \ + _vec_resize_will_expand ((V), _v (n), \ + (_v (l) + _v (n)) * sizeof ((V)[0]), 0, 0); \ + }) + /** \brief Predicate function, says whether the supplied vector is a clib heap object (general version). -- cgit 1.2.3-korg