-
Notifications
You must be signed in to change notification settings - Fork 349
allocator: make aligned allocations precise #3607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give some background here, what is this fixing ?
|
|
@lyakh after your explanation i feel this PR should be split into 3 patches each with proper commit message explaining why it is needed. |
|
@lyakh please also check CI |
No need for two divisions for an alignment macro, one is enough. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Simplify the align_ptr() function by re-using an existing ALIGN() macro. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
alloc_block() and alloc_cont_blocks() don't use their "caps" parameter, remote it. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The condition "size + alignment <= block_size" for allocating memory from a signle buffer is sufficient but not precise enough. For example if we want to allocate 20 bytes with 64-byte alignment, a 32-byte buffer *might* be sufficient if it's suitably aligned. Fix the algorithm to account for such cases. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
alloc_heap_buffer() is trying to allocate memory from a single heap, no need to check its size on each iteration of an internal loop over maps. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
When allocating multiple buffers the first free buffer might not contain a suitably aligned start address. Skip it instead of allocating it with the others. Also don't add alignment to the allocation size, but find a suitably aligned start address instead. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
|
SOFCI TEST |
|
@dbaluta it looks like you got 6 patches now ! |
|
@lyakh can you check CI. |
|
@lgirdwood splitting this into #3642, #3646 and #3647, we can close this one then. |
Currently when the allocator tries to allocate aligned buffers, if it detects, that the current alignment isn't suitable, it adds alignment to the requested size and tries to allocate that. This is too imprecise and counterintuitive. In the very worst theoretical case alignment - 1 bytes might be needed additionally. Also no need to begin grabbing buffers for continuous allocations, which don't contain an address with required alignment. Simplify the alignment macro too to only perform division once.