-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Update core with upstream umm_malloc #6438
Conversation
our current version w/o any edits. Using files from: https://github.com/rhempel/umm_malloc/tree/master/src https://github.com/rhempel/c-helper-macros/tree/develop The following file remanents from our old version were removed: umm_malloc.cpp, umm_performance.h, umm_performance.cpp, and umm_stats.h This is intended to be a "compare to" for changes made to upstream version.
See comments at the top of umm_malloc.cpp for a summary of changes so far. Added support for integrity check and poison check to refactored heap.cpp.
…realloc. Updated some comments and changed method of defining _rom_putc1.
…uino into WIP-upstream-umm_malloc
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.
Beware changing file extensions. We migrated to compile as much as possible with g++, and that shouldn't be reverted.
Also, for new features that aren't present in upstream, try to keep them in separate cpp|h files to reduce the diffs in the main files. At least if it's reasonable to do so, there is likely code where that isn't possible or reasonable.
allocation to include its nearest allocated neighbors in the heap. That is to say, if the nearest neighbor is free, then the next one over is checked. And this is done in both directions. umm_malloc() will also checks the neighbors of the selected allocation before use. Merged umm_malloc.c into umm_malloc.cpp. Added additional stats for debug build. On going comment cleanup. Removed #if 0 block from isr_safe_printf. Corrected mistyped UMM_POISON_CHECK UMM_CHECK_POISON. Corrected other conditional build issues.
Updated printing in heap.cpp to behave the way os_printf would have with regards to system_set_os_print. ie. setDebugOutput enable/disables printing Expanded #ifdef fenceing of .c files to prevent Arduino IDE from building them outside of the .cpp file they are included in. Corrected more conditional building issues. Remaining concern - umm_info(0, true) printing - does it need an ISR safe method, all printing is done from within a critical sectionn with rsil(15)? Or should be have the print option disabled for non-debug builds. ie. Debug port: "Disabled"
* R.Hempel 2019-09-07 - Separate the malloc() and free() functionality into * wrappers that use critical section protection macros * and static core functions that assume they are * running in a protected con text. Thanks @devyte
With OOM selected w/ Debug port: "Disabled" you can now use Serial.setDebugOutput(true); to enable OOM message displaying. This is the behavior previously available with os_printf. commit rev 1
53f2d0c
to
f68a64f
Compare
… for future. umm_info(NULL, true) is now treated as a debug option that is enabled by Arduino IDE->tools `Debug port: "Serial"`, etc. It now prints when DEBUG_ESP_PORT or UMM_INFO_PRINT are defined. Cleanup comments and some conditionals.
More comment cleanups Added Status TODOs marks for upstream
…upstream version at https://github.com/rhempel/umm_malloc. Some reorganizing and new code was needed to use the new version. This is a list of note worthy changes: UMM_POISON - now has a lite option as well as the previous intensive check option. The code for running the full poison test at the call of the various alloc functions was removed in the upstream version. In this port the missing code was added to heap.cpp and umm_local.cpp. * UMM_POISON - appears to have been partially changed to UMM_POISON_CHECK, I treat it as depricated and used UMM_POISON_CHECK, when needed. However, the Arduino Core's references to UMM_POISON were replaced with UMM_POISON_CHECK_LITE. * UMM_POISON_CHECK_LITE - Less intense, it just checks poison on active neighboring allocations. * UMM_POISON_CHECK - Full heap intensive check of poison UMM_INFO_PRINT - This new define makes building UMM_INFO with printing capability, optional. When umm_info(NULL, true) is used to print a debug view of heap information to the debug port, it has to walk the heap and print out information, while in a critical section. This requires that the print function be able to print w/o doing malloc calls and from an IRQ disabled context. It also requires more IRAM to handle printing. Without this define `umm_info(NULL, true)` will not print. * UMM_INFO_PRINT is enabled as part of selecting `Debug port: "Serial" or * "Serial1"`. To make available all the time use '-D UMM_INFO_PRINT`. A cautionary note, on the use of UMM_INTEGRITY_CHECK, UMM_POISON_CHECK, and UMM_INFO_PRINT. All of these run with IRQs disabled, for periods that can go into 100's of us. With umm_info(NULL, true) that may go into seconds, depending on the serial interface speed and the number of memory allocations present. Use UMM_INTEGRITY_CHECK, UMM_POISON_CHECK, and UMM_INFO_PRINT sparingly. If you want to see numbers for the disabled time, explore using UMM_CRITICAL_METRICS in umm_malloc_cfg.h.
…upstream version at https://github.com/rhempel/umm_malloc. Some reorganizing and new code was needed to use the new version. This is a list of note worthy changes: UMM_POISON - now has a lite option as well as the previous intensive check option. The code for running the full poison test at the call of the various alloc functions was removed in the upstream version. In this port the missing code was added to heap.cpp and umm_local.cpp. * UMM_POISON - appears to have been partially changed to UMM_POISON_CHECK, I treat it as depricated and used UMM_POISON_CHECK, when needed. However, the Arduino Core's references to UMM_POISON were replaced with UMM_POISON_CHECK_LITE. * UMM_POISON_CHECK_LITE - Less intense, it just checks poison on active neighboring allocations. * UMM_POISON_CHECK - Full heap intensive check of poison UMM_INFO_PRINT - This new define makes building UMM_INFO with printing capability, optional. When umm_info(NULL, true) is used to print a debug view of heap information to the debug port, it has to walk the heap and print out information, while in a critical section. This requires that the print function be able to print w/o doing malloc calls and from an IRQ disabled context. It also requires more IRAM to handle printing. Without this define `umm_info(NULL, true)` will not print. * UMM_INFO_PRINT is enabled as part of selecting `Debug port: "Serial" or * "Serial1"`. To make available all the time use '-D UMM_INFO_PRINT`. A cautionary note, on the use of UMM_INTEGRITY_CHECK, UMM_POISON_CHECK, and UMM_INFO_PRINT. All of these run with IRQs disabled, for periods that can go into 100's of us. With umm_info(NULL, true) that may go into seconds, depending on the serial interface speed and the number of memory allocations present. Use UMM_INTEGRITY_CHECK, UMM_POISON_CHECK, and UMM_INFO_PRINT sparingly. If you want to see numbers for the disabled time, explore using UMM_CRITICAL_METRICS in umm_malloc_cfg.h.
…uino into WIP-upstream-umm_malloc
…ability from an ISR vs forground with INTLEVEL 15.
keep these comments separated from the upstream code and to avoid getting lost. I'll expand this as I think of and remember more.
Refactored macro PTR_CHECK__LOG_LAST_FAIL. Replaced macros __umm_... with uppercase versions. Corrected misplaced POISON_CHECK__PANIC_FL macro in realloc. Added debug free options for OOM and Poison to umm_malloc_cfg.h Updated Notes.h. Lines that start with "//C" are meant to flag reviewer's attention.
thinking behind its placement and Integrity Checks placement with relation to the *alloc function. Just so I don't forget again :/
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.
2 minor typos.
I didn't check how close this follows upstream, but I trust your judgement.
Alright, merging this one to get exposure. |
upstream version of
umm_malloc
customized for Arduino ESP8266 CoreThis updates the heap management library, umm_malloc, to the current upstream
version at https://github.com/rhempel/umm_malloc. Some reorganizing and new code
was needed to use the new version.
This is a list of noteworthy changes:
UMM_POISON - now has a lite option as well as the previous intensive check
option. The code for running the full poison test at the call of the various
alloc functions was removed in the upstream version. In this port, the missing
code was added to heap.cpp and umm_local.cpp.
I treat it as deprecated and used UMM_POISON_CHECK when needed.
However, the Arduino Core's references to UMM_POISON were replaced with
UMM_POISON_CHECK_LITE.
neighboring allocations.
A cautionary note, on the use of UMM_INTEGRITY_CHECK and UMM_POISON_CHECK
, and. All of these run with IRQs disabled, for periods that can goUMM_INFO_PRINT
into 100's of us. With umm_info(NULL, true) that may go into seconds, depending
on the serial interface speed and the number of memory allocations present. Use
UMM_INTEGRITY_CHECK and UMM_POISON_CHECK
, and UMM_INFO_PRINTsparingly.If you want to see numbers for the disabled time, explore using
UMM_CRITICAL_METRICS in umm_malloc_cfg.h.