From: Stephen Hemminger <stephen@networkplumber.org>
To: Konstantin Ananyev <konstantin.ananyev@huawei.com>
Cc: "mannywang(王永峰)" <mannywang@tencent.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH v6] acl: support custom memory allocators
Date: Mon, 8 Dec 2025 11:29:16 -0800 [thread overview]
Message-ID: <20251208112916.2743f596@phoenix.local> (raw)
In-Reply-To: <2571c074e438491e837c51d1bdc5a538@huawei.com>
On Mon, 8 Dec 2025 09:43:01 +0000
Konstantin Ananyev <konstantin.ananyev@huawei.com> wrote:
> > Allow users to provide custom
> > memory allocation hooks for runtime memory in rte_acl_ctx, via
> > struct rte_acl_mem_hook.
>
> LGTM in general, few extra comments below.
>
> > Key changes:
> > - Added struct rte_acl_mem_hook with zalloc, free, and udata.
> > - Added rte_acl_set_mem_hook / rte_acl_get_mem_hook to set/get callbacks.
> > - Default allocation uses existing rte_zmalloc_socket/rte_free.
> > - Modified ACL code to call callbacks for runtime allocations instead
> > of rte_zmalloc_socket/rte_free directly.
> >
> > v5:
> > - Remove temporary memory allocation callback for build stage.
> > - Introduce new API (rte_acl_set_mem_hook / rte_acl_get_mem_hook)
> > instead of modifying existing rte_acl_config to preserve
> > ABI compatibility.
> >
> > v6:
> > - Reworked API to meet consistency and naming conventions.
> > - Adjusted parameter order for better readability and alignment.
> > - Renamed internal variables for clarity and code consistency.
> >
> > Signed-off-by: YongFeng Wang <mannywang@tencent.com>
> > ---
> > app/test/test_acl.c | 121 ++++++++++++++++++
> > .../prog_guide/packet_classif_access_ctrl.rst | 31 +++++
> > lib/acl/acl.h | 1 +
> > lib/acl/acl_bld.c | 2 +-
> > lib/acl/acl_gen.c | 4 +-
> > lib/acl/rte_acl.c | 45 ++++++-
> > lib/acl/rte_acl.h | 47 +++++++
> > 7 files changed, 247 insertions(+), 4 deletions(-)
> >
> > diff --git a/app/test/test_acl.c b/app/test/test_acl.c
> > index 43d13b5b0f..3c9a0cb8c0 100644
> > --- a/app/test/test_acl.c
> > +++ b/app/test/test_acl.c
> > @@ -1721,6 +1721,125 @@ test_u32_range(void)
> > return rc;
> > }
> >
> > +struct acl_ctx_wrapper {
> > + struct rte_acl_ctx *ctx;
> > + void *running_buf;
> > + bool running_buf_using;
> > +};
> > +
> > +#define ACL_RUNNING_BUF_SIZE (10 * 1024 * 1024)
> > +
> > +static void *running_alloc(char *name, size_t size,
> > + size_t align, int32_t socket_id, void *udata)
> > +{
> > + RTE_SET_USED(align);
> > + RTE_SET_USED(name);
> > + RTE_SET_USED(socket_id);
> > + if (size > ACL_RUNNING_BUF_SIZE)
> > + return NULL;
> > + struct acl_ctx_wrapper *acl_ctx = (struct acl_ctx_wrapper *)udata;
> > + if (acl_ctx->running_buf_using)
> > + return NULL;
> > + printf("running memory alloc for acl context, size=%zu, pointer=%p\n",
> > + size,
> > + acl_ctx->running_buf);
> > + memset(acl_ctx->running_buf, 0, size);
> > + acl_ctx->running_buf_using = true;
> > + return acl_ctx->running_buf;
> > +}
>
> Is there any point to have such memhook in our UT?
> From one side: it doesn't test anything new, as memory is still allocsted via rte_zmalloc().
> From other side it is error prone, as you don't check that pre-allocated buffer
> will really satisfy requested size and alignment parameters.
> Might be just use libc malloc/free here?
A lot of the problems would go away if ACL just used regular malloc/free more,
and rte_malloc/rte_free less. The existing rte_malloc is slow and fragments badly
next prev parent reply other threads:[~2025-12-08 19:29 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 2:51 [RFC] rte_acl_build memory fragmentation concern and proposal for external memory support mannywang(王永峰)
2025-11-17 12:51 ` Konstantin Ananyev
2025-11-25 9:40 ` [PATCH] acl: support custom memory allocator =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-25 12:06 ` [PATCH v2] " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-25 12:14 ` [PATCH v3] " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-25 14:59 ` Stephen Hemminger
2025-11-26 2:37 ` [Internet]Re: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-25 18:01 ` Dmitry Kozlyuk
2025-11-26 2:44 ` [Internet]Re: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-26 7:57 ` Dmitry Kozlyuk
2025-11-26 8:09 ` =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-26 21:28 ` Stephen Hemminger
2025-11-27 2:05 ` [Internet]Re: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-11-28 13:26 ` Konstantin Ananyev
2025-11-28 15:07 ` =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-01 12:05 ` [PATCH v4] acl: support custom memory allocators in rte_acl_build =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-01 15:59 ` Patrick Robb
2025-12-01 16:42 ` Stephen Hemminger
2025-12-02 9:33 ` [Internet]Re: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-01 12:45 ` [PATCH v5] " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-02 2:47 ` fengchengwen
2025-12-02 9:25 ` [PATCH v6] acl: support custom memory allocators =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-08 9:43 ` Konstantin Ananyev
2025-12-08 12:48 ` =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-08 19:29 ` Stephen Hemminger [this message]
2025-12-09 2:30 ` [Internet]Re: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-09 11:06 ` Konstantin Ananyev
2025-12-10 4:09 ` fengchengwen
2025-12-08 12:57 ` [PATCH v7] " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-09 10:59 ` Konstantin Ananyev
2025-12-09 12:56 ` [Internet]RE: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-09 12:52 ` [PATCH v8] " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-02 9:31 ` [Internet]Re: [PATCH v5] acl: support custom memory allocators in rte_acl_build =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-11 1:46 ` [PATCH v3] acl: support custom memory allocator Stephen Hemminger
2025-12-11 2:22 ` [Internet]Re: " =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-11 2:29 ` =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
2025-12-11 13:04 ` =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?=
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=20251208112916.2743f596@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@huawei.com \
--cc=mannywang@tencent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).