From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: "Morten Brørup" <mb@smartsharesystems.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Andrew Rybchenko" <andrew.rybchenko@oktetlabs.ru>,
"Bruce Richardson" <bruce.richardson@intel.com>,
"Stephen Hemminger" <stephen@networkplumber.org>
Subject: RE: [PATCH 4/6] mempool: various cleanups
Date: Fri, 18 Sep 2026 09:42:06 +0000 [thread overview]
Message-ID: <3c0a5ad4043f4191abc0fbe37258b3c0@huawei.com> (raw)
In-Reply-To: <20260910103613.808038-5-mb@smartsharesystems.com>
> Removed audit call from dump function, where it doesn't belong.
>
> Added malloc/dealloc attribute to private cache alloc/free functions.
>
> Improved checks in mempool ops registration function.
>
> Improved cache audit checks.
>
> Added detailed description to definition of mempool name length.
>
> Updated some comments, and moved around some misplaced comments.
>
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
....
> diff --git a/lib/mempool/rte_mempool_ops.c
> b/lib/mempool/rte_mempool_ops.c
> index 066bec36fc..6d99c7a25c 100644
> --- a/lib/mempool/rte_mempool_ops.c
> +++ b/lib/mempool/rte_mempool_ops.c
> @@ -27,7 +27,7 @@ int
> rte_mempool_register_ops(const struct rte_mempool_ops *h)
> {
> struct rte_mempool_ops *ops;
> - int16_t ops_index;
> + unsigned int ops_index;
>
> rte_spinlock_lock(&rte_mempool_ops_table.sl);
>
> @@ -47,12 +47,22 @@ rte_mempool_register_ops(const struct
> rte_mempool_ops *h)
> return -EINVAL;
> }
>
> - if (strlen(h->name) >= sizeof(ops->name) - 1) {
> + if (strnlen(h->name, sizeof(h->name)) > sizeof(ops->name) - 1) {
> rte_spinlock_unlock(&rte_mempool_ops_table.sl);
> - RTE_MEMPOOL_LOG(DEBUG, "%s(): mempool_ops <%s>: name
> too long",
> - __func__, h->name);
> - rte_errno = EEXIST;
> - return -EEXIST;
> + char name[sizeof(h->name) + 1];
> + strlcpy(name, h->name, sizeof(name));
Curious, why do you need to copy?
Why can't t->name be used directly withiin the LOG()?
> + RTE_MEMPOOL_LOG(ERR, "%s(): mempool_ops <%s>: name too
> long",
> + __func__, name);
> + return -ENAMETOOLONG;
> + }
> +
> + for (ops_index = 0; ops_index < rte_mempool_ops_table.num_ops;
> ops_index++) {
> + if (!strcmp(h->name,
> rte_mempool_ops_table.ops[ops_index].name)) {
> + rte_spinlock_unlock(&rte_mempool_ops_table.sl);
> + RTE_MEMPOOL_LOG(ERR, "%s(): mempool_ops <%s>:
> name exists",
> + __func__, h->name);
> + return -EEXIST;
> + }
> }
>
> ops_index = rte_mempool_ops_table.num_ops++;
> @@ -70,6 +80,8 @@ rte_mempool_register_ops(const struct rte_mempool_ops
> *h)
>
> rte_spinlock_unlock(&rte_mempool_ops_table.sl);
>
> + RTE_MEMPOOL_LOG(DEBUG, "Registered mempool ops <%s> at index
> %u", ops->name, ops_index);
> +
> return ops_index;
> }
>
> @@ -185,8 +197,12 @@ rte_mempool_set_ops_byname(struct rte_mempool
> *mp, const char *name,
> }
> }
>
> - if (ops == NULL)
> + if (ops == NULL) {
> + RTE_MEMPOOL_LOG(DEBUG,
> + "Cannot set unknown mempool ops <%s>, of %u
> ops registered",
> + name, i);
> return -EINVAL;
> + }
>
> mp->ops_index = i;
> mp->pool_config = pool_config;
> --
> 2.43.0
next prev parent reply other threads:[~2026-09-18 9:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 10:36 [PATCH 0/6] mempool: cleanup, fixes, improvements and optimizations Morten Brørup
2026-09-10 10:36 ` [PATCH 1/6] mempool: fix private data area size alignment Morten Brørup
2026-09-10 10:36 ` [PATCH 2/6] net/sxe2: do not use deprecated mempool cache field Morten Brørup
2026-09-10 10:36 ` [PATCH 3/6] mempool: remove deprecated cache flush threshold field Morten Brørup
2026-09-10 10:36 ` [PATCH 4/6] mempool: various cleanups Morten Brørup
2026-09-18 9:42 ` Konstantin Ananyev [this message]
2026-09-18 9:48 ` Morten Brørup
2026-09-10 10:36 ` [PATCH 5/6] mempool: optimize access to private data Morten Brørup
2026-09-18 10:02 ` Konstantin Ananyev
2026-09-18 10:56 ` Morten Brørup
2026-09-10 10:36 ` [PATCH 6/6] mempool: no cache size limit Morten Brørup
2026-09-15 17:04 ` Morten Brørup
2026-09-17 9:02 ` Morten Brørup
2026-09-18 12:43 ` Konstantin Ananyev
2026-09-18 15:36 ` Morten Brørup
2026-09-18 17:21 ` Konstantin Ananyev
2026-09-19 9:47 ` Morten Brørup
2026-09-22 11:29 ` Konstantin Ananyev
2026-09-18 12:44 ` Konstantin Ananyev
2026-10-13 7:43 ` [PATCH 0/6] mempool: cleanup, fixes, improvements and optimizations Thomas Monjalon
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=3c0a5ad4043f4191abc0fbe37258b3c0@huawei.com \
--to=konstantin.ananyev@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=stephen@networkplumber.org \
/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.