[4/6] mempool: make header size calculation internal

Message ID 20211018144907.1145028-5-andrew.rybchenko@oktetlabs.ru (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series mempool: cleanup namespace |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Oct. 18, 2021, 2:49 p.m. UTC
  Add RTE_ prefix to helper macro to calculate mempool header size and
make it internal. Old macro is still available, but deprecated.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 app/test/test_mempool.c                |  2 +-
 doc/guides/rel_notes/deprecation.rst   |  4 ++++
 doc/guides/rel_notes/release_21_11.rst |  3 +++
 lib/mempool/rte_mempool.c              |  6 +++---
 lib/mempool/rte_mempool.h              | 10 +++++++---
 5 files changed, 18 insertions(+), 7 deletions(-)
  

Comments

David Marchand Oct. 19, 2021, 8:48 a.m. UTC | #1
On Mon, Oct 18, 2021 at 4:49 PM Andrew Rybchenko
<andrew.rybchenko@oktetlabs.ru> wrote:
>
> Add RTE_ prefix to helper macro to calculate mempool header size and
> make it internal. Old macro is still available, but deprecated.
>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

No reference to this macro out there:
$ git grep-all -w MEMPOOL_HEADER_SIZE


The change looks fine to me.
I just wonder if we really need to expose this helper, is it
performance sensitive?
  
Andrew Rybchenko Oct. 19, 2021, 8:59 a.m. UTC | #2
On 10/19/21 11:48 AM, David Marchand wrote:
> On Mon, Oct 18, 2021 at 4:49 PM Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru> wrote:
>>
>> Add RTE_ prefix to helper macro to calculate mempool header size and
>> make it internal. Old macro is still available, but deprecated.
>>
>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> 
> No reference to this macro out there:
> $ git grep-all -w MEMPOOL_HEADER_SIZE
> 
> 
> The change looks fine to me.
> I just wonder if we really need to expose this helper, is it
> performance sensitive?
> 

As far as I can see it is used by rte_mempool_get_priv()
which is inline and could be used on datapath.
  

Patch

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index ffe69e2d03..8ecd0f10b8 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -111,7 +111,7 @@  test_mempool_basic(struct rte_mempool *mp, int use_external_cache)
 
 	printf("get private data\n");
 	if (rte_mempool_get_priv(mp) != (char *)mp +
-			MEMPOOL_HEADER_SIZE(mp, mp->cache_size))
+			RTE_MEMPOOL_HEADER_SIZE(mp, mp->cache_size))
 		GOTO_ERR(ret, out);
 
 #ifndef RTE_EXEC_ENV_FREEBSD /* rte_mem_virt2iova() not supported on bsd */
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 83a453b9bc..33ad418be7 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -43,6 +43,10 @@  Deprecation Notices
   removed in DPDK 22.11. Corresponding flags with ``RTE_MEMPOOL_F_*``
   should be used instead.
 
+* mempool: Helper macro ``MEMPOOL_HEADER_SIZE()`` is deprecated and will
+  be removed in DPDK 22.11. The replacement macro
+  ``RTE_MEMPOOL_HEADER_SIZE()`` is internal only.
+
 * mbuf: The mbuf offload flags ``PKT_*`` will be renamed as ``RTE_MBUF_F_*``.
   A compatibility layer will be kept until DPDK 22.11, except for the flags
   that are already deprecated (``PKT_RX_L4_CKSUM_BAD``, ``PKT_RX_IP_CKSUM_BAD``,
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 84bcad0e4a..dae421225b 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -267,6 +267,9 @@  API Changes
 * mempool: The mempool flags ``MEMPOOL_F_*`` are deprecated.
   Newly added flags with ``RTE_MEMPOOL_F_`` prefix should be used instead.
 
+* mempool: Helper macro ``MEMPOOL_HEADER_SIZE()`` is deprecated.
+  The replacement macro ``RTE_MEMPOOL_HEADER_SIZE()`` is internal only.
+
 * net: Renamed ``s_addr`` and ``d_addr`` fields of ``rte_ether_hdr`` structure
   to ``src_addr`` and ``dst_addr``, respectively.
 
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 638eaa5fa2..4e3a15e49c 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -861,7 +861,7 @@  rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 		goto exit_unlock;
 	}
 
-	mempool_size = MEMPOOL_HEADER_SIZE(mp, cache_size);
+	mempool_size = RTE_MEMPOOL_HEADER_SIZE(mp, cache_size);
 	mempool_size += private_data_size;
 	mempool_size = RTE_ALIGN_CEIL(mempool_size, RTE_MEMPOOL_ALIGN);
 
@@ -877,7 +877,7 @@  rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	/* init the mempool structure */
 	mp = mz->addr;
-	memset(mp, 0, MEMPOOL_HEADER_SIZE(mp, cache_size));
+	memset(mp, 0, RTE_MEMPOOL_HEADER_SIZE(mp, cache_size));
 	ret = strlcpy(mp->name, name, sizeof(mp->name));
 	if (ret < 0 || ret >= (int)sizeof(mp->name)) {
 		rte_errno = ENAMETOOLONG;
@@ -901,7 +901,7 @@  rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	 * The local_cache points to just past the elt_pa[] array.
 	 */
 	mp->local_cache = (struct rte_mempool_cache *)
-		RTE_PTR_ADD(mp, MEMPOOL_HEADER_SIZE(mp, 0));
+		RTE_PTR_ADD(mp, RTE_MEMPOOL_HEADER_SIZE(mp, 0));
 
 	/* Init all default caches. */
 	if (cache_size != 0) {
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 11540c0d52..b1dbcf7361 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -295,17 +295,21 @@  struct rte_mempool {
 #endif
 
 /**
- * Calculate the size of the mempool header.
+ * @internal Calculate the size of the mempool header.
  *
  * @param mp
  *   Pointer to the memory pool.
  * @param cs
  *   Size of the per-lcore cache.
  */
-#define MEMPOOL_HEADER_SIZE(mp, cs) \
+#define RTE_MEMPOOL_HEADER_SIZE(mp, cs) \
 	(sizeof(*(mp)) + (((cs) == 0) ? 0 : \
 	(sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
 
+/** Deprecated. Use RTE_MEMPOOL_HEADER_SIZE() for internal purposes only. */
+#define MEMPOOL_HEADER_SIZE(mp, cs) \
+	RTE_DEPRECATED(RTE_MEMPOOL_HEADER_SIZE(mp, cs))
+
 /* return the header of a mempool object (internal) */
 static inline struct rte_mempool_objhdr *
 rte_mempool_get_header(void *obj)
@@ -1722,7 +1726,7 @@  void rte_mempool_audit(struct rte_mempool *mp);
 static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
 {
 	return (char *)mp +
-		MEMPOOL_HEADER_SIZE(mp, mp->cache_size);
+		RTE_MEMPOOL_HEADER_SIZE(mp, mp->cache_size);
 }
 
 /**