kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/heap_tlsf_overhead_tune' into 'master'
heap: reduce the per-pool overhead by tunning TLSF control structure Closes IDF-2282 See merge request espressif/esp-idf!10907pull/6192/head
commit
8472f0a6bf
|
@ -37,6 +37,7 @@
|
|||
#include "multi_heap_config.h"
|
||||
#include "multi_heap.h"
|
||||
#include "multi_heap_internal.h"
|
||||
#include "heap_tlsf_config.h"
|
||||
#include "heap_tlsf.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -37,13 +37,23 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "soc/soc.h"
|
||||
|
||||
#if !CONFIG_SPIRAM
|
||||
#define TLSF_MAX_POOL_SIZE (SOC_DIRAM_DRAM_HIGH - SOC_DIRAM_DRAM_LOW)
|
||||
#else
|
||||
#define TLSF_MAX_POOL_SIZE SOC_EXTRAM_DATA_SIZE
|
||||
#endif
|
||||
|
||||
enum tlsf_config
|
||||
{
|
||||
/* log2 of number of linear subdivisions of block sizes. Larger
|
||||
** values require more memory in the control structure. Values of
|
||||
** 4 or 5 are typical.
|
||||
*/
|
||||
SL_INDEX_COUNT_LOG2 = 5,
|
||||
SL_INDEX_COUNT_LOG2 = 3,
|
||||
|
||||
/* All allocation sizes and addresses are aligned to 4 bytes. */
|
||||
ALIGN_SIZE_LOG2 = 2,
|
||||
|
@ -60,6 +70,40 @@ enum tlsf_config
|
|||
** blocks below that size into the 0th first-level list.
|
||||
*/
|
||||
|
||||
/* Tunning the first level, we can reduce TLSF pool overhead
|
||||
* in exchange of manage a pool smaller than 4GB
|
||||
*/
|
||||
#if (TLSF_MAX_POOL_SIZE <= (256 * 1024))
|
||||
FL_INDEX_MAX = 18, //Each pool can have up 256KB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (512 * 1024))
|
||||
FL_INDEX_MAX = 19, //Each pool can have up 512KB
|
||||
#elif (TLSF_MAX_POOL_SIZE <= (16 * 1024 * 1024))
|
||||
FL_INDEX_MAX = 24, //Each pool can have up 16MB
|
||||
#else
|
||||
#error "Higher TLSF pool sizes should be added for this new config"
|
||||
#endif
|
||||
|
||||
SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2),
|
||||
FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2),
|
||||
FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1),
|
||||
|
||||
SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
|
||||
};
|
||||
#else
|
||||
enum tlsf_config
|
||||
{
|
||||
//Specific configuration for host test.
|
||||
|
||||
/* log2 of number of linear subdivisions of block sizes. Larger
|
||||
** values require more memory in the control structure. Values of
|
||||
** 4 or 5 are typical.
|
||||
*/
|
||||
SL_INDEX_COUNT_LOG2 = 5,
|
||||
|
||||
/* All allocation sizes and addresses are aligned to 4 bytes. */
|
||||
ALIGN_SIZE_LOG2 = 2,
|
||||
ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2),
|
||||
|
||||
/* Tunning the first level, we can reduce TLSF pool overhead
|
||||
* in exchange of manage a pool smaller than 4GB
|
||||
*/
|
||||
|
@ -71,3 +115,4 @@ enum tlsf_config
|
|||
|
||||
SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#endif
|
||||
|
||||
/* Configuration macros for multi-heap */
|
||||
|
|
Ładowanie…
Reference in New Issue