[dpdk-dev,v6,17/19] ring: add support to non-EAL thread
Commit Message
ring debug stat won't take care non-EAL thread.
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
---
v6 changes:
rollback v5 changes
v5 changes:
check __lcore_id with LCORE_ID_ANY instead of RTE_MAX_LCORE
lib/librte_ring/rte_ring.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -188,10 +188,12 @@ struct rte_ring {
* The number to add to the object-oriented statistics.
*/
#ifdef RTE_LIBRTE_RING_DEBUG
-#define __RING_STAT_ADD(r, name, n) do { \
- unsigned __lcore_id = rte_lcore_id(); \
- r->stats[__lcore_id].name##_objs += n; \
- r->stats[__lcore_id].name##_bulk += 1; \
+#define __RING_STAT_ADD(r, name, n) do { \
+ unsigned __lcore_id = rte_lcore_id(); \
+ if (__lcore_id < RTE_MAX_LCORE) { \
+ r->stats[__lcore_id].name##_objs += n; \
+ r->stats[__lcore_id].name##_bulk += 1; \
+ } \
} while(0)
#else
#define __RING_STAT_ADD(r, name, n) do {} while(0)