-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
kernel: add k_heap_aligned_alloc #30003
kernel: add k_heap_aligned_alloc #30003
Conversation
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.
Definitely useful. Not loving the cut/paste though, can we fix?
kernel/kheap.c
Outdated
@@ -51,6 +51,31 @@ void *k_heap_alloc(struct k_heap *h, size_t bytes, k_timeout_t timeout) | |||
return ret; | |||
} | |||
|
|||
void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes, k_timeout_t timeout) |
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.
Rather than cutting and pasting the synchronization as boilerplate from k_heap_alloc(), could you please refactor the two so they use the same implementation? One simple option would be to implement k_heap_alloc() in terms of k_heap_aligned_alloc(). Or if we care about the mild performance overhead (IMHO we don't) implement both in terms of an inline function where the alignment code optimizes away.
Looks good now. CI failure looks like some infrastructure problem, can you rebase and push again, see if it goes away? |
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.
Looks good to me. Thanks for getting this in!
k_heap did not have an aligned alloc function, even though this is supported by the internal sys_heap. Signed-off-by: Maximilian Bachmann <m.bachmann@acontis.com>
@andyross can you re-review this |
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.
Sorry, my concerns were addressed, this looks great.
k_heap did not have an aligned alloc function, even though
this is supported by the internal sys_heap. (implements #29631)
@andrewboie in #29029 you wrote that
k_heap has a facility for aligned allocations you should use that instead of k_malloc to reserve memory
, but apparently this is not possible for k_heap yet