Skip to content

mm/mempool: Fix multiple pool exact size lookup - #21035

Open
anchao wants to merge 1 commit into
apache:masterfrom
anchao:26102708
Open

anchao wants to merge 1 commit into
apache:masterfrom
anchao:26102708

Conversation

@anchao

@anchao anchao commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix the pool selection logic in multiple mempool lookup for non-linear pool
size classes.

For multiple mempools without a fixed arithmetic size delta, the lookup uses a
binary search to find the first pool that can satisfy the requested allocation
size. The previous comparison only accepted pools whose block size was strictly
greater than the requested size, so an exact-size request skipped the matching
pool and selected the next larger pool instead.

This changes the binary search condition from > to >=, making it a proper
lower-bound lookup. Exact-size requests are now served by the matching pool.

Impact

This fixes allocation behavior for multiple mempools using non-linear block
sizes.

Expected impact:

  • exact-size allocation requests use the correctly matching pool
  • avoids unnecessary use of the next larger pool
  • reduces internal waste for exact-size requests
  • preserves existing behavior for requests between two pool sizes
  • no API, ABI, build-system, documentation, or security impact is expected

Testing

sim/nsh

Use lower-bound lookup for non-linear pool size classes so exact-size
requests are served by the matching pool instead of the next larger one.

Signed-off-by: chao an <anchao.archer@bytedance.com>
@github-actions github-actions Bot added Area: Memory Management Memory Management issues Size: XS The size of the change in this PR is very small labels Oct 27, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Memory Management Memory Management issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants