1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00
M Hightower 7a43092df0 Update core with upstream umm_malloc (#6438)
* WIP: Initial overlay of upstream version of umm_malloc over
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.

* WIP: upstream version of umm_malloc customized for Arduino ESP8266 Core
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.

* Resoved Travis CI - issue

* Corrected #ifdef's for UMM_STATS/UMM_STATS_FULL

* Corrected UMM_REALLOC_DEFRAG option to be more like the original umm_realloc.
Updated some comments and changed method of defining _rom_putc1.

* Updated UMM_POISON_CHECK_LITE - Expanded the poison check on the current
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 did.

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"

* Merged latest, 2019-09-07, from upstream umm_malloc

* 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

* Resolved issue where OOM selected w/ Debug port: "Disabled" caused hang.

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

* Fixed realloc OOM bug introduced due to confusing code, added comment 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.

* Updated to track PRs for various print definitions. Cleaned up comments

* Added missing "#ifdef __cplusplus"

* Reorganize local enhancements
More comment cleanups
Added Status TODOs marks for upstream

* Print notice message for the need of -DUMM_INFO_PRINT

* This 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 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.

* This 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 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.

* Updated upstream TODO

* Changes on printing to comply with new understanding of SPI bus availability
from an ISR vs forground with INTLEVEL 15.

* Removed no longer needed files.

* OOM build option now saves file and line number for post mortem reporting.

* Missed change.

* Consolated upstream integration comments into Notes.h. This helps
keep these comments separated from the upstream code and to avoid
getting lost. I'll expand this as I think of and remember more.

* Comment updates.

* Notes update.

* Changes to heap.cpp -
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.

* Corrected Full Poison Check's placement and documented the
thinking behind its placement and Integrity Checks placement
with relation to the *alloc function. Just so I don't forget
again :/

* Fixed typos
2019-10-29 03:42:30 -03:00
..
2019-10-07 19:31:30 -03:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-03-14 11:19:21 +01:00
2019-10-07 19:31:30 -03:00
2019-10-07 19:31:30 -03:00
2019-07-26 22:57:27 -07:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-10-28 08:55:00 -03:00
2019-10-28 08:55:00 -03:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-05-14 00:09:54 +02:00
2019-10-08 05:36:39 -07:00
2019-10-08 05:36:39 -07:00
2019-05-14 00:09:54 +02:00
2014-12-01 00:34:28 +03:00
2019-05-14 00:09:54 +02:00