Supplement: The two types of memory in ACL make a management strategy unnecessary: (1) the run-time memory for the match tree, which is allocated as a single block during each build and freed when the ACL is reset; and (2) the temporary memory used during the build process, which is allocated multiple times within a single build and then released all at once after the build is finished.

On 12/11/2025 9:46 AM, Stephen Hemminger wrote:
On Tue, 25 Nov 2025 12:14:46 +0000
"mannywang(王永峰)" <[email protected]> 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 <[email protected]>
---

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




Reply via email to