Skip to content

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Dec 23, 2025

add an allocator for equal size pool management where allocated elements are never freed but only added to a free pool

Copilot AI review requested due to automatic review settings December 23, 2025 11:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a simple batch allocator for managing equal-size memory pools where allocated elements are returned to a free pool rather than being deallocated. The allocator dynamically grows the pool using power-of-2 sized batches (starting with 2 elements, up to a maximum of 32 per batch) and uses bitmasks to track allocation state.

Key Changes

  • New batch allocator API with batch_alloc() and batch_free() functions
  • Dynamic pool growth strategy using power-of-2 batch sizes
  • Comprehensive unit test suite for the batch allocator

Reviewed changes

Copilot reviewed 7 out of 11 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/include/sof/batch.h New public API header declaring batch allocator functions
src/lib/batch.c Implementation of batch allocator with dynamic growth and bitmask-based tracking
src/lib/CMakeLists.txt Added batch.c to the common source files list
test/ztest/unit/batch/testcase.yaml Test configuration for batch allocator unit tests
test/ztest/unit/batch/test_batch_ztest.c Unit tests validating allocation/deallocation across multiple batch sizes
test/ztest/unit/batch/prj.conf Ztest project configuration for batch tests
test/ztest/unit/batch/CMakeLists.txt CMake build configuration for batch unit tests
test/ztest/unit/math/basic/trigonometry/prj.conf No functional change (formatting only)
test/ztest/unit/math/basic/arithmetic/prj.conf No functional change (formatting only)
test/ztest/unit/list/prj.conf No functional change (formatting only)
test/ztest/unit/fast-get/prj.conf No functional change (formatting only)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lyakh lyakh force-pushed the batch branch 2 times, most recently from 46b8123 to 33f9c9e Compare December 23, 2025 12:56
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the use case here ?

@lyakh
Copy link
Collaborator Author

lyakh commented Dec 23, 2025

Whats the use case here ?

@lgirdwood memory domains

@lyakh
Copy link
Collaborator Author

lyakh commented Dec 23, 2025

The PTL Jenkins failure https://sof-ci.01.org/sofpr/PR10456/build18317/devicetest/index.html?model=PTLP_RVP_SDW&testcase=check-runtime-pm-status is strange. I cannot find earlier occurrences and it couldn't be caused by this PR, because it isn't changing runtime by itself. The test has been run on top of 70828dd - before #10386 was merged

Add missing "new line" symbols in multiple prj.conf files.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Add a simple "batch allocator." It allocates memory for equally
sized objects, that never has to be freed, but can be reused instead.
The first call to this allocator allocates two instances of the
object, the next one allocates 4, then 8, 16, and after that every
new allocation request adds 32 instances. When those objects are
freed, they are only marked as free and kept for reuse. Also add a
unit test for it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants