All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dharmik Thakkar <dharmik.thakkar@arm.com>
To: Olivier Matz <olivier.matz@6wind.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: dev@dpdk.org, nd@arm.com, joyce.kong@arm.com,
	Dharmik Thakkar <dharmik.thakkar@arm.com>
Subject: [dpdk-dev] [PATCH v3 1/2] lib/mempool: make stats macro generic
Date: Mon, 19 Apr 2021 19:07:59 -0500	[thread overview]
Message-ID: <20210420000800.1504-2-dharmik.thakkar@arm.com> (raw)
In-Reply-To: <20210420000800.1504-1-dharmik.thakkar@arm.com>

Make __MEMPOOL_STAT_ADD macro more generic and delete
__MEMPOOL_CONTIG_BLOCKS_STAT_ADD macro

Suggested-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 lib/librte_mempool/rte_mempool.h | 34 +++++++++++++++-----------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index c551cf733acf..848a19226149 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -273,20 +273,11 @@ struct rte_mempool {
 #define __MEMPOOL_STAT_ADD(mp, name, n) do {                    \
 		unsigned __lcore_id = rte_lcore_id();           \
 		if (__lcore_id < RTE_MAX_LCORE) {               \
-			mp->stats[__lcore_id].name##_objs += n;	\
-			mp->stats[__lcore_id].name##_bulk += 1;	\
+			mp->stats[__lcore_id].name += n;	\
 		}                                               \
 	} while(0)
-#define __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, name, n) do {                    \
-		unsigned int __lcore_id = rte_lcore_id();       \
-		if (__lcore_id < RTE_MAX_LCORE) {               \
-			mp->stats[__lcore_id].name##_blks += n;	\
-			mp->stats[__lcore_id].name##_bulk += 1;	\
-		}                                               \
-	} while (0)
 #else
 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
-#define __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, name, n) do {} while (0)
 #endif
 
 /**
@@ -1288,7 +1279,8 @@ __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
 	void **cache_objs;
 
 	/* increment stat now, adding in mempool always success */
-	__MEMPOOL_STAT_ADD(mp, put, n);
+	__MEMPOOL_STAT_ADD(mp, put_bulk, 1);
+	__MEMPOOL_STAT_ADD(mp, put_objs, n);
 
 	/* No cache provided or if put would overflow mem allocated for cache */
 	if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE))
@@ -1446,7 +1438,8 @@ __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
 
 	cache->len -= n;
 
-	__MEMPOOL_STAT_ADD(mp, get_success, n);
+	__MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+	__MEMPOOL_STAT_ADD(mp, get_success_objs, n);
 
 	return 0;
 
@@ -1455,10 +1448,13 @@ __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
 	/* get remaining objects from ring */
 	ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
 
-	if (ret < 0)
-		__MEMPOOL_STAT_ADD(mp, get_fail, n);
-	else
-		__MEMPOOL_STAT_ADD(mp, get_success, n);
+	if (ret < 0) {
+		__MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
+		__MEMPOOL_STAT_ADD(mp, get_fail_objs, n);
+	} else {
+		__MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+		__MEMPOOL_STAT_ADD(mp, get_success_objs, n);
+	}
 
 	return ret;
 }
@@ -1581,11 +1577,13 @@ rte_mempool_get_contig_blocks(struct rte_mempool *mp,
 
 	ret = rte_mempool_ops_dequeue_contig_blocks(mp, first_obj_table, n);
 	if (ret == 0) {
-		__MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_success, n);
+		__MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+		__MEMPOOL_STAT_ADD(mp, get_success_blks, n);
 		__mempool_contig_blocks_check_cookies(mp, first_obj_table, n,
 						      1);
 	} else {
-		__MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_fail, n);
+		__MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
+		__MEMPOOL_STAT_ADD(mp, get_fail_blks, n);
 	}
 
 	rte_mempool_trace_get_contig_blocks(mp, first_obj_table, n);
-- 
2.17.1


  reply	other threads:[~2021-04-20  0:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 11:20 [dpdk-dev] [PATCH v2] lib/mempool: distinguish debug counters from cache and pool Joyce Kong
2021-04-07 14:28 ` Olivier Matz
2021-04-20  0:31   ` Dharmik Thakkar
2021-04-20  0:07 ` [dpdk-dev] [PATCH v3 0/2] lib/mempool: add debug stats Dharmik Thakkar
2021-04-20  0:07   ` Dharmik Thakkar [this message]
2021-04-21 16:09     ` [dpdk-dev] [PATCH v3 1/2] lib/mempool: make stats macro generic Olivier Matz
2021-04-20  0:08   ` [dpdk-dev] [PATCH v3 2/2] lib/mempool: distinguish debug counters from cache and pool Dharmik Thakkar
2021-04-21 16:29     ` Olivier Matz
2021-04-22 21:27       ` Dharmik Thakkar
2021-04-22 21:47         ` Honnappa Nagarahalli
2021-04-23 10:41       ` Kinsella, Ray
2021-04-23  1:29   ` [dpdk-dev] [PATCH v4 0/2] lib/mempool: add debug stats Dharmik Thakkar
2021-04-23  1:29     ` [dpdk-dev] [PATCH v4 1/2] lib/mempool: make stats macro generic Dharmik Thakkar
2021-04-23  1:29     ` [dpdk-dev] [PATCH v4 2/2] lib/mempool: distinguish debug counters from cache and pool Dharmik Thakkar
2021-04-23 20:29       ` Dharmik Thakkar
2021-04-27 12:18       ` Olivier Matz
2021-04-27 12:28     ` [dpdk-dev] [PATCH v4 0/2] lib/mempool: add debug stats Olivier Matz
2021-04-27 16:01     ` [dpdk-dev] [PATCH v5 0/2] mempool: " Dharmik Thakkar
2021-04-27 16:01       ` [dpdk-dev] [PATCH v5 1/2] mempool: make stats macro generic Dharmik Thakkar
2021-04-27 16:01       ` [dpdk-dev] [PATCH v5 2/2] mempool: distinguish debug counters from cache and pool Dharmik Thakkar
2021-05-04  6:54         ` Olivier Matz
2021-05-04  7:02       ` [dpdk-dev] [PATCH v5 0/2] mempool: add debug stats David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210420000800.1504-2-dharmik.thakkar@arm.com \
    --to=dharmik.thakkar@arm.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=joyce.kong@arm.com \
    --cc=nd@arm.com \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.