Repository navigation
[proposal]alloc: don't log error if failure was allowed #2058
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,10 +106,11 @@ struct mm { | |
| /* heap allocation and free */ | ||
| void *_malloc(int zone, uint32_t caps, size_t bytes); | ||
| void *_zalloc(int zone, uint32_t caps, size_t bytes); | ||
| void *_balloc(int zone, uint32_t caps, size_t bytes, uint32_t alignment); | ||
| void *_balloc(int zone, uint32_t caps, size_t bytes, uint32_t alignment, | ||
| bool can_fail); | ||
| void *_realloc(void *ptr, int zone, uint32_t caps, size_t bytes); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding a new parameter I think we can extend the caps field to also include a flag named SOF_MEM_NOWARN (similar with GFP_NOWARN from Linux kernel). When this flag is set it has the same meaning as your can_fail parameter. Also, it might worth renaming caps parameter to flags.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about that too. However I am afraid it may confuse people more than extra single argument. Anyway it is worth discussing - if more people like this idea too I am more than happy to go with this direction.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. caps is for capabilities, not error reporting so it would be confusing, I'd go for another function
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jajanusz will rename parameter from caps to flags and so that we can avoid confusion. Have a look at GFP_ macros in Linux kernel (GFP_NOWARN).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbaluta If you change it to |
||
| void *_brealloc(void *ptr, int zone, uint32_t caps, size_t bytes, | ||
| uint32_t alignment); | ||
| uint32_t alignment, bool can_fail); | ||
| void rfree(void *ptr); | ||
|
|
||
| #if CONFIG_DEBUG_HEAP | ||
|
|
@@ -142,10 +143,11 @@ void rfree(void *ptr); | |
| } while (0); \ | ||
| _ptr; }) | ||
|
|
||
| #define rballoc(zone, caps, bytes) \ | ||
| #define rballoc(zone, caps, bytes, can_fail) \ | ||
| ({void *_ptr; \ | ||
| do { \ | ||
| _ptr = _balloc(zone, caps, bytes, PLATFORM_DCACHE_ALIGN);\ | ||
| _ptr = _balloc(zone, caps, bytes, PLATFORM_DCACHE_ALIGN, \ | ||
| can_fail);\ | ||
| if (!_ptr) { \ | ||
| trace_error(TRACE_CLASS_MEM, \ | ||
| "failed to alloc 0x%x bytes caps 0x%x", \ | ||
|
|
@@ -168,11 +170,11 @@ void rfree(void *ptr); | |
| } while (0); \ | ||
| _ptr; }) | ||
|
|
||
| #define rbrealloc(ptr, zone, caps, bytes) \ | ||
| #define rbrealloc(ptr, zone, caps, bytes, can_fail) \ | ||
| ({void *_ptr; \ | ||
| do { \ | ||
| _ptr = _brealloc(ptr, zone, caps, bytes,\ | ||
| PLATFORM_DCACHE_ALIGN);\ | ||
| PLATFORM_DCACHE_ALIGN, can_fail);\ | ||
| if (!_ptr) { \ | ||
| trace_error(TRACE_CLASS_MEM, \ | ||
| "failed to alloc 0x%x bytes caps 0x%x", \ | ||
|
|
@@ -182,10 +184,11 @@ void rfree(void *ptr); | |
| } while (0); \ | ||
| _ptr; }) | ||
|
|
||
| #define rbrealloc_align(ptr, zone, caps, bytes, alignment) \ | ||
| #define rbrealloc_align(ptr, zone, caps, bytes, alignment, can_fail) \ | ||
| ({void *_ptr; \ | ||
| do { \ | ||
| _ptr = _brealloc(ptr, zone, caps, bytes, alignment); \ | ||
| _ptr = _brealloc(ptr, zone, caps, bytes, alignment, \ | ||
| can_fail); \ | ||
| if (!_ptr) { \ | ||
| trace_error(TRACE_CLASS_MEM, \ | ||
| "failed to alloc 0x%x bytes caps 0x%x", \ | ||
|
|
@@ -195,10 +198,10 @@ void rfree(void *ptr); | |
| } while (0); \ | ||
| _ptr; }) | ||
|
|
||
| #define rballoc_align(zone, caps, bytes, alignment) \ | ||
| #define rballoc_align(zone, caps, bytes, alignment, can_fail) \ | ||
| ({void *_ptr; \ | ||
| do { \ | ||
| _ptr = _balloc(zone, caps, bytes, alignment); \ | ||
| _ptr = _balloc(zone, caps, bytes, alignment, can_fail); \ | ||
| if (!_ptr) { \ | ||
| trace_error(TRACE_CLASS_MEM, \ | ||
| "failed to alloc 0x%x bytes caps 0x%x", \ | ||
|
|
@@ -215,16 +218,16 @@ void alloc_trace_buffer_heap(int zone, uint32_t caps, size_t bytes); | |
|
|
||
| #define rmalloc(zone, caps, bytes) _malloc(zone, caps, bytes) | ||
| #define rzalloc(zone, caps, bytes) _zalloc(zone, caps, bytes) | ||
| #define rballoc(zone, caps, bytes) \ | ||
| _balloc(zone, caps, bytes, PLATFORM_DCACHE_ALIGN) | ||
| #define rballoc_align(zone, caps, bytes, alignment) \ | ||
| _balloc(zone, caps, bytes, alignment) | ||
| #define rballoc(zone, caps, bytes, can_fail) \ | ||
| _balloc(zone, caps, bytes, PLATFORM_DCACHE_ALIGN, can_fail) | ||
| #define rballoc_align(zone, caps, bytes, alignment, can_fail) \ | ||
| _balloc(zone, caps, bytes, alignment, can_fail) | ||
| #define rrealloc(ptr, zone, caps, bytes) \ | ||
| _realloc(ptr, zone, caps, bytes) | ||
| #define rbrealloc(ptr, zone, caps, bytes) \ | ||
| _brealloc(ptr, zone, caps, bytes, PLATFORM_DCACHE_ALIGN) | ||
| #define rbrealloc_align(ptr, zone, caps, bytes, alignment) \ | ||
| _brealloc(ptr, zone, caps, bytes, alignment) | ||
| #define rbrealloc(ptr, zone, caps, bytes, can_fail) \ | ||
| _brealloc(ptr, zone, caps, bytes, PLATFORM_DCACHE_ALIGN, can_fail) | ||
| #define rbrealloc_align(ptr, zone, caps, bytes, alignment, can_fail) \ | ||
| _brealloc(ptr, zone, caps, bytes, alignment, can_fail) | ||
|
|
||
| #endif | ||
|
|
||
|
|
||
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.
@mrajwa But we will still see errors logged here right?
Uh oh!
There was an error while loading. Please reload this page.
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.
@dbaluta, no you will see only regular log message which shall be treated as a warning. Previously it was error message and people were confused, linking almost every WoV issue with this error message like "Ohh of course it happens because there was not enough memory".