DPDK patches and discussions
 help / color / mirror / Atom feed
From: =?gb18030?B?bWFubnl3YW5nKM3108C35Sk=?= <mannywang@tencent.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Konstantin Ananyev <konstantin.ananyev@huawei.com>, dev@dpdk.org
Subject: Re: [Internet]Re: [PATCH v3] acl: support custom memory allocator
Date: Thu, 11 Dec 2025 21:04:23 +0800	[thread overview]
Message-ID: <60D6DC43A0D9D2FB+55ec6052-7294-4833-8824-b7751454971e@tencent.com> (raw)
In-Reply-To: <20251211104625.39632870@stephen-xps.local>

Please forgive me for repeating myself, because I am worried that I did 
not express it clearly:

ACL does not need a memory manager, because for each build it only 
allocates one block of memory, and before the next build (during reset) 
the memory is freed. The temporary memory is slightly more complicated 
since it is allocated multiple times, but it is still freed all at once. 
Therefore, for ACL, we do need to allocate memory, but we do not need a 
memory manager.

However, the memory used in the current build process is indeed 
dynamically allocated, which will cause fragmentation in the 
corresponding memory manager when multiple builds are performed.

Based on the above situation, I think the most reasonable approach is to 
bind a pre-allocated static memory block to the ACL context.

On 12/11/2025 9:46 AM, Stephen Hemminger wrote:
> On Tue, 25 Nov 2025 12:14:46 +0000
> "mannywang(王永峰)" <mannywang@tencent.com> wrote:
> 
>> Reduce memory fragmentation caused by dynamic memory allocations
>> by allowing users to provide custom memory allocator.
>>
>> Add new members to struct rte_acl_config to allow passing custom
>> allocator callbacks to rte_acl_build:
>>
>> - running_alloc: allocator callback for run-time internal memory
>> - running_free: free callback for run-time internal memory
>> - running_ctx: user-defined context passed to running_alloc/free
>>
>> - temp_alloc: allocator callback for temporary memory during ACL build
>> - temp_reset: reset callback for temporary allocator
>> - temp_ctx: user-defined context passed to temp_alloc/reset
>>
>> These callbacks allow users to provide their own memory pools or
>> allocators for both persistent runtime structures and temporary
>> build-time data.
>>
>> A typical approach is to pre-allocate a static memory region
>> for rte_acl_ctx, and to provide a global temporary memory manager
>> that supports multipleallocations and a single reset during ACL build.
>>
>> Since tb_mem_pool handles allocation failures using siglongjmp,
>> temp_alloc follows the same approach for failure handling.
>>
>> Signed-off-by: YongFeng Wang <mannywang@tencent.com>
>> ---
> 
> Rather than custom allocators, I did a couple of quick AI queries about
> alternatives. It looks like there are some big global gains possible
> here:
> 
> Summary of Recommendations
> Improvement	Benefit	Complexity	Priority
> ACL Object Pooling	Eliminates ACL-specific fragmentation	Medium	High
> Size-Class Segregation	Reduces general fragmentation	High	High
> Slab Allocator for Build	Better hugepage utilization	Medium	Medium
> Deferred Coalescing	Reduces fragmentation from churn	Medium	Medium
> Thread-Local Caching	Reduces contention, improves locality	Medium	Medium
> 
> Also adding some malloc_trim() would help.
> 
> https://claude.ai/share/75fcf73c-17e3-4f41-8590-f2ab640f9512
> 
> 



      parent reply	other threads:[~2025-12-11 13:04 UTC|newest]

Thread overview: 38+ 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
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-12 15:00                 ` Konstantin Ananyev
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=?= [this message]

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=60D6DC43A0D9D2FB+55ec6052-7294-4833-8824-b7751454971e@tencent.com \
    --to=mannywang@tencent.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.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 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).