Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rimage
52 changes: 32 additions & 20 deletions src/platform/apollolake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,35 @@
#define SOF_TEXT_BASE (SOF_FW_START)

/* Heap section sizes for system runtime heap for primary core */
#define HEAP_SYS_RT_0_COUNT64 128
#define HEAP_SYS_RT_0_COUNT512 16
#define HEAP_SYS_RT_0_COUNT1024 4
#define HEAP_SYS_RT_0_COUNT64 64
#define HEAP_SYS_RT_0_COUNT512 8
#define HEAP_SYS_RT_0_COUNT1024 2

/* Heap section sizes for system runtime heap for secondary core */
#define HEAP_SYS_RT_X_COUNT64 64
#define HEAP_SYS_RT_X_COUNT512 8
#define HEAP_SYS_RT_X_COUNT1024 4
#define HEAP_SYS_RT_X_COUNT64 32
#define HEAP_SYS_RT_X_COUNT512 4
#define HEAP_SYS_RT_X_COUNT1024 2

/* Heap section counts base */
#define HEAP_COUNT64 128
#define HEAP_COUNT128 128
#define HEAP_COUNT256 96
#define HEAP_COUNT512 8
#define HEAP_COUNT1024 4
#define HEAP_COUNT2048 2
#define HEAP_COUNT4096 1

#define RT_TIMES 1
#define RT_SHARED_TIMES 1

/* Heap section sizes for module pool */
#define HEAP_RT_COUNT64 160
#define HEAP_RT_COUNT128 64
#define HEAP_RT_COUNT256 128
#define HEAP_RT_COUNT512 8
#define HEAP_RT_COUNT1024 4
#define HEAP_RT_COUNT2048 1
#define HEAP_RT_COUNT4096 1
#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES)
#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES)
#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES)
#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES)
#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES)
#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES)
#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES)

/* Heap configuration */
#define HEAP_RUNTIME_SIZE \
Expand All @@ -279,11 +291,11 @@
HEAP_RT_COUNT4096 * 4096)

/* Heap section sizes for runtime shared heap */
#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT)
#define HEAP_RUNTIME_SHARED_COUNT128 64
#define HEAP_RUNTIME_SHARED_COUNT256 4
#define HEAP_RUNTIME_SHARED_COUNT512 16
#define HEAP_RUNTIME_SHARED_COUNT1024 4
#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES)

#define HEAP_RUNTIME_SHARED_SIZE \
(HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \
Expand All @@ -298,8 +310,8 @@
#define HEAP_BUFFER_BLOCK_SIZE 0x100
#define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE)

#define HEAP_SYSTEM_M_SIZE 0x8000 /* heap primary core size */
#define HEAP_SYSTEM_S_SIZE 0x6000 /* heap secondary core size */
#define HEAP_SYSTEM_M_SIZE 0x4000 /* heap primary core size */
#define HEAP_SYSTEM_S_SIZE 0x3000 /* heap secondary core size */
#define HEAP_SYSTEM_T_SIZE \
(HEAP_SYSTEM_M_SIZE + ((CONFIG_CORE_COUNT - 1) * HEAP_SYSTEM_S_SIZE))

Expand Down
41 changes: 29 additions & 12 deletions src/platform/cannonlake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,31 @@
#define HEAP_SYS_RT_X_COUNT512 8
#define HEAP_SYS_RT_X_COUNT1024 4

/* Heap section counts base */
#define HEAP_COUNT64 128
#define HEAP_COUNT128 128
#define HEAP_COUNT256 96
#define HEAP_COUNT512 8
#define HEAP_COUNT1024 4
#define HEAP_COUNT2048 2
#define HEAP_COUNT4096 1

#if HP_SRAM_SIZE < 0x200000
#define RT_TIMES 3
#define RT_SHARED_TIMES 6
#else
#define RT_TIMES 8
#define RT_SHARED_TIMES 16
#endif

/* Heap section sizes for module pool */
#define HEAP_RT_COUNT64 128
#define HEAP_RT_COUNT128 64
#define HEAP_RT_COUNT256 128
#define HEAP_RT_COUNT512 8
#define HEAP_RT_COUNT1024 4
#define HEAP_RT_COUNT2048 1
#define HEAP_RT_COUNT4096 1
#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES)
#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES)
#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES)
#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES)
#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES)
#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES)
#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES)

/* Heap configuration */
#define HEAP_RUNTIME_SIZE \
Expand All @@ -260,11 +277,11 @@
HEAP_RT_COUNT4096 * 4096)

/* Heap section sizes for runtime shared heap */
#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT)
#define HEAP_RUNTIME_SHARED_COUNT128 64
#define HEAP_RUNTIME_SHARED_COUNT256 4
#define HEAP_RUNTIME_SHARED_COUNT512 16
#define HEAP_RUNTIME_SHARED_COUNT1024 4
#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES)

#define HEAP_RUNTIME_SHARED_SIZE \
(HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \
Expand Down
41 changes: 29 additions & 12 deletions src/platform/icelake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,31 @@
#define HEAP_SYS_RT_X_COUNT512 8
#define HEAP_SYS_RT_X_COUNT1024 4

/* Heap section counts base */
#define HEAP_COUNT64 128
#define HEAP_COUNT128 128
#define HEAP_COUNT256 96
#define HEAP_COUNT512 8
#define HEAP_COUNT1024 4
#define HEAP_COUNT2048 2
#define HEAP_COUNT4096 1

#if HP_SRAM_SIZE < 0x200000
#define RT_TIMES 1
#define RT_SHARED_TIMES 1
#else
#define RT_TIMES 8
#define RT_SHARED_TIMES 16
#endif

/* Heap section sizes for module pool */
#define HEAP_RT_COUNT64 128
#define HEAP_RT_COUNT128 64
#define HEAP_RT_COUNT256 128
#define HEAP_RT_COUNT512 8
#define HEAP_RT_COUNT1024 4
#define HEAP_RT_COUNT2048 1
#define HEAP_RT_COUNT4096 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to address these large block sizes later. I dont think we have any users ?

Copy link
Contributor Author

@keyonjie keyonjie Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the 2KB and 4KB blocks have no users yet per my observation, maybe we can leave it for 256Bs and 512Bs for advanced fine tuning.

#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES)
#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES)
#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES)
#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES)
#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES)
#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES)
#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES)

/* Heap configuration */
#define HEAP_RUNTIME_SIZE \
Expand All @@ -257,11 +274,11 @@
HEAP_RT_COUNT4096 * 4096)

/* Heap section sizes for runtime shared heap */
#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT)
#define HEAP_RUNTIME_SHARED_COUNT128 64
#define HEAP_RUNTIME_SHARED_COUNT256 4
#define HEAP_RUNTIME_SHARED_COUNT512 16
#define HEAP_RUNTIME_SHARED_COUNT1024 4
#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES)

#define HEAP_RUNTIME_SHARED_SIZE \
(HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \
Expand Down
123 changes: 70 additions & 53 deletions src/platform/tigerlake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,47 +135,47 @@

/*
* The HP SRAM Region on Tigerlake is organised like this :-
* +--------------------------------------------------------------------------+
* | Offset | Region | Size |
* +------------------+-------------------------+-----------------------------+
* | SRAM_SW_REG_BASE | SW Registers W0 | SRAM_SW_REG_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SRAM_OUTBOX_BASE | Outbox W0 | SRAM_MAILBOX_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SRAM_INBOX_BASE | Inbox W1 | SRAM_INBOX_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SRAM_DEBUG_BASE | Debug data W2 | SRAM_DEBUG_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SRAM_EXCEPT_BASE | Debug data W2 | SRAM_EXCEPT_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SRAM_STREAM_BASE | Stream data W2 | SRAM_STREAM_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SRAM_TRACE_BASE | Trace Buffer W3 | SRAM_TRACE_SIZE |
* +------------------+-------------------------+-----------------------------+
* | HP_SRAM_BASE | DMA | HEAP_HP_BUFFER_SIZE |
* +------------------+-------------------------+-----------------------------+
* | SOF_FW_START | text | |
* | | data | |
* | | BSS | |
* +------------------+-------------------------+-----------------------------+
* | | Runtime Heap | HEAP_RUNTIME_SIZE |
* +------------------+-------------------------+-----------------------------+
* | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE |
* | |-------------------------+-----------------------------+
* | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE |
* | |-------------------------+-----------------------------+
* | | Module Buffers | HEAP_BUFFER_SIZE |
* +------------------+-------------------------+-----------------------------+
* | | Primary core Sys Heap | HEAP_SYSTEM_M_SIZE |
* +------------------+-------------------------+-----------------------------+
* | | Pri. Sys Runtime Heap | HEAP_SYS_RUNTIME_M_SIZE |
* +------------------+-------------------------+-----------------------------+
* | | Primary core Stack | SOF_STACK_SIZE |
* +------------------+-------------------------+-----------------------------+
* | | Sec. core Sys Heap | SOF_CORE_S_T_SIZE |
* | | Sec. Sys Runtime Heap | |
* | | Secondary core Stack | |
* +------------------+-------------------------+-----------------------------+
* +----------------------------------------------------------------------------+
* | Offset | Region | Size |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_SW_REG_BASE | SW Registers W0 | SRAM_SW_REG_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_OUTBOX_BASE | Outbox W0 | SRAM_OUTBOX_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_INBOX_BASE | Inbox W1 | SRAM_INBOX_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_DEBUG_BASE | Debug data W2 | SRAM_DEBUG_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_EXCEPT_BASE | Debug data W2 | SRAM_EXCEPT_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_STREAM_BASE | Stream data W2 | SRAM_STREAM_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SRAM_TRACE_BASE | Trace Buffer W3 | SRAM_TRACE_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | HEAP_HP_BUFFER_BASE| DMA | HEAP_HP_BUFFER_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | SOF_FW_START | text | |
* | | data | |
* | | BSS | |
* +--------------------+-------------------------+-----------------------------+
* | | Runtime Heap | HEAP_RUNTIME_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE |
* | |-------------------------+-----------------------------+
* | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE |
* | |-------------------------+-----------------------------+
* | | Module Buffers | HEAP_BUFFER_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | | Primary core Sys Heap | HEAP_SYSTEM_M_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | | Pri. Sys Runtime Heap | HEAP_SYS_RUNTIME_M_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | | Primary core Stack | SOF_STACK_SIZE |
* +--------------------+-------------------------+-----------------------------+
* | | Sec. core Sys Heap | SOF_CORE_S_T_SIZE |
* | | Sec. Sys Runtime Heap | |
* | | Secondary core Stack | |
* +--------------------+-------------------------+-----------------------------+
*/

/* HP SRAM */
Expand Down Expand Up @@ -249,14 +249,31 @@
#define HEAP_SYS_RT_X_COUNT512 8
#define HEAP_SYS_RT_X_COUNT1024 4

/* Heap section counts base */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust your calculations but for the sake of others like me, can you please add an explanation for how this makes full use of the TGL memory and that it is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 'Heap section counts base' is only some use experience based summarize of how should we arrange percentage of different size sections, e.g. make 128B and 256B counts as larger as possible. This is only only a base with assumption that we have 64KB size for the specific type.

E.g. TGL and ADL share the share memory.h but with different HPSRAM size, we want to keep the percentage of different size section consistent on TGL and ADL, with only changing the RT_TIMES, e.g. 3 for ADL and 8 for TGL.

@ranj063 all those values might still need to be fine-tuned, I only did draft tuning so it is only makes more (not 'full') use of our memory.

Better solution could be do accurate calculation and put all not used memory to our pool, I think we are using too many types of zone today, and our .text/.data size are varying so this .bss section total max size varies also. It's a good topic about how to manage this well and it is not a short task IMHO.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these comments (including any TODO) belong to the source code. You already put a lot of effort there, no one should have to make the exact same effort again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better solution could be do accurate calculation and put all not used memory to our pool, I think we are using too many types of zone today, and our .text/.data size are varying so this .bss section total max size varies also. It's a good topic about how to manage this well and it is not a short task IMHO.

@keyonjie lets not make short work of this. This seems like a critical change that could make or break multi-core and dynamic platforms on our platforms. I'd prefer taking the time to do this right instead of changing it now only to realize it doesnt work as intended shortly after.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie lets not make short work of this. This seems like a critical change that could make or break multi-core and dynamic platforms on our platforms. I'd prefer taking the time to do this right instead of changing it now only to realize it doesnt work as intended shortly after.

Well, I can imagine we still have quite a lot of opens with respect to the heap block memory map (struct mm), how many types are needed, how to make sure the .share_data section is in uncached region so can be really shared among DSP COREs, how to allocate memory to make the SRAM power gating more efficient add more power saving we can benefit from it, ...

The goal of this relative small PR is not to do drive this to far, it is only to rescue those missed memory banks and help for 'out of memory' scenarios, for other (non-OOM related) multi-core + dynamic pipeline cases, it won't help and won't introduce breakage neither.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these comments (including any TODO) belong to the source code. You already put a lot of effort there, no one should have to make the exact same effort again.

As commented to Ranjani, most of them are still open and not suitable to be added to the source, to avoid misleading.

Copy link
Collaborator

@marc-hb marc-hb Jul 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's even more important to mention opens in the source than explain the current status because by default readers assume the work is done and because there's no code that opens can be "reverse-engineered" from. Comments are misleading only if they're not correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's even more important to mention opens in the source than explain the current status because by default readers assume the work is done and because there's no code that opens can be "reverse-engineered" from. Comments are misleading only if they're not correct.

No, the open is not to this specific part of code, though it could be a topic in sof-developers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie I read through the comments and still have no idea on how you determined what values are necessary/required? Is this based on an experiment using e.g. daily test devices or commercial ones?

Put differently, how do we know how much is left for each bank and the current usage on a per bank basis? If we don't have this information things will continue to break, won't they?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart it is based on our daily test and will be showed in sof-logger if you enable this logging information.
Paste an log from TGLU_VOLT_SDW (and this PR is to address issue #4424 found on it also) in case you want to get this detail:

[       11508.593293] (          12.395833) c0 memory                      src/lib/alloc.c:1130 INFO heap: system status
[       11517.395376] (           8.802083) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe110000 size 32768 blocks 0 caps 0x45
[       11526.457875] (           9.062500) c0 memory                      src/lib/alloc.c:1106 INFO   used 6912 free 25856
[       11535.572458] (           9.114583) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe130000 size 24576 blocks 0 caps 0x45
[       11544.478708] (           8.906250) c0 memory                      src/lib/alloc.c:1106 INFO   used 9496 free 15080
[       11553.437041] (           8.958333) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe140000 size 24576 blocks 0 caps 0x45
[       11562.239124] (           8.802083) c0 memory                      src/lib/alloc.c:1106 INFO   used 9496 free 15080
[       11571.249540] (           9.010416) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe150000 size 24576 blocks 0 caps 0x45
[       11580.155790] (           8.906250) c0 memory                      src/lib/alloc.c:1106 INFO   used 9496 free 15080
[       11588.697456] (           8.541666) c0 memory                      src/lib/alloc.c:1132 INFO heap: system runtime status
[       11597.291206] (           8.593750) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe118000 size 20480 blocks 3 caps 0x65
[       11606.197455] (           8.906250) c0 memory                      src/lib/alloc.c:1106 INFO   used 768 free 19712
[       11614.895372] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 1 base 0xbe11a000 size 512
[       11623.749538] (           8.854166) c0 memory                      src/lib/alloc.c:1117 INFO    count 16 free 16
[       11632.499538] (           8.750000) c0 memory                      src/lib/alloc.c:1114 INFO   block 2 base 0xbe11c000 size 1024
[       11641.197454] (           8.697916) c0 memory                      src/lib/alloc.c:1117 INFO    count 4 free 4
[       11650.103704] (           8.906250) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe136000 size 12288 blocks 3 caps 0x65
[       11659.009953] (           8.906250) c0 memory                      src/lib/alloc.c:1106 INFO   used 384 free 11904
[       11667.707870] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 1 base 0xbe137000 size 512
[       11676.562036] (           8.854166) c0 memory                      src/lib/alloc.c:1117 INFO    count 8 free 8
[       11685.259952] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 2 base 0xbe138000 size 1024
[       11694.114119] (           8.854166) c0 memory                      src/lib/alloc.c:1117 INFO    count 4 free 4
[       11703.020368] (           8.906250) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe146000 size 12288 blocks 3 caps 0x65
[       11711.822451] (           8.802083) c0 memory                      src/lib/alloc.c:1106 INFO   used 448 free 11840
[       11720.572451] (           8.750000) c0 memory                      src/lib/alloc.c:1114 INFO   block 1 base 0xbe147000 size 512
[       11729.374534] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 8 free 8
[       11738.072450] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 2 base 0xbe148000 size 1024
[       11789.791198] (          51.718746) c0 memory                      src/lib/alloc.c:1117 INFO    count 4 free 4
[       11798.905781] (           9.114583) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe156000 size 12288 blocks 3 caps 0x65
[       11807.499531] (           8.593750) c0 memory                      src/lib/alloc.c:1106 INFO   used 384 free 11904
[       11816.301614] (           8.802083) c0 memory                      src/lib/alloc.c:1114 INFO   block 1 base 0xbe157000 size 512
[       11824.895363] (           8.593750) c0 memory                      src/lib/alloc.c:1117 INFO    count 8 free 8
[       11833.853696] (           8.958333) c0 memory                      src/lib/alloc.c:1114 INFO   block 2 base 0xbe158000 size 1024
[       11842.395363] (           8.541666) c0 memory                      src/lib/alloc.c:1117 INFO    count 4 free 4
[       11851.249529] (           8.854166) c0 memory                      src/lib/alloc.c:1134 INFO heap: buffer status
[       11859.999529] (           8.750000) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe08f800 size 524288 blocks 1 caps 0x71
[       11868.905778] (           8.906250) c0 memory                      src/lib/alloc.c:1106 INFO   used 67328 free 456960
[       11877.916195] (           9.010416) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe8003b0 size 64592 blocks 1 caps 0x69
[       11886.770361] (           8.854166) c0 memory                      src/lib/alloc.c:1106 INFO   used 0 free 64592
[       11895.364111] (           8.593750) c0 memory                      src/lib/alloc.c:1136 INFO heap: runtime status
[       11903.957860] (           8.593750) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0xbe080000 size 63488 blocks 7 caps 0x45
[       11912.916193] (           8.958333) c0 memory                      src/lib/alloc.c:1106 INFO   used 12288 free 51200
[       11921.666193] (           8.750000) c0 memory                      src/lib/alloc.c:1114 INFO   block 1 base 0xbe082000 size 128
[       11930.468276] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 64 free 41
[       11939.166192] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 2 base 0xbe084000 size 256
[       11947.916192] (           8.750000) c0 memory                      src/lib/alloc.c:1117 INFO    count 128 free 116
[       11956.614108] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 3 base 0xbe08c000 size 512
[       11965.416191] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 8 free 8
[       11974.218274] (           8.802083) c0 memory                      src/lib/alloc.c:1114 INFO   block 4 base 0xbe08d000 size 1024
[       11983.020357] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 4 free 4
[       11991.822440] (           8.802083) c0 memory                      src/lib/alloc.c:1114 INFO   block 5 base 0xbe08e000 size 2048
[       12000.728690] (           8.906250) c0 memory                      src/lib/alloc.c:1117 INFO    count 1 free 0
[       12009.582856] (           8.854166) c0 memory                      src/lib/alloc.c:1114 INFO   block 6 base 0xbe08e800 size 4096
[       12018.384939] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 1 free 0
[       12027.030772] (           8.645833) c0 memory                      src/lib/alloc.c:1139 INFO heap: runtime shared status
[       12035.676605] (           8.645833) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0x9e11d000 size 37888 blocks 5 caps 0x45
[       12044.634938] (           8.958333) c0 memory                      src/lib/alloc.c:1106 INFO   used 27008 free 10880
[       12053.384938] (           8.750000) c0 memory                      src/lib/alloc.c:1114 INFO   block 1 base 0x9e120000 size 128
[       12062.187021] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 64 free 19
[       12070.884937] (           8.697916) c0 memory                      src/lib/alloc.c:1114 INFO   block 2 base 0x9e122000 size 256
[       12079.687020] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 4 free 0
[       12088.437020] (           8.750000) c0 memory                      src/lib/alloc.c:1114 INFO   block 3 base 0x9e122400 size 512
[       12097.187019] (           8.750000) c0 memory                      src/lib/alloc.c:1117 INFO    count 16 free 0
[       12105.989102] (           8.802083) c0 memory                      src/lib/alloc.c:1114 INFO   block 4 base 0x9e124400 size 1024
[       12114.791185] (           8.802083) c0 memory                      src/lib/alloc.c:1117 INFO    count 8 free 4
[       12123.280768] (           8.489583) c0 memory                      src/lib/alloc.c:1141 INFO heap: system shared status
[       12131.822435] (           8.541666) c0 memory                      src/lib/alloc.c:1104 INFO  heap: 0x9e126400 size 5376 blocks 0 caps 0x45
[       12140.780768] (           8.958333) c0 memory                      src/lib/alloc.c:1106 INFO   used 3200 free 2176
``

#define HEAP_COUNT64 128
#define HEAP_COUNT128 128
#define HEAP_COUNT256 96
#define HEAP_COUNT512 8
#define HEAP_COUNT1024 4
#define HEAP_COUNT2048 2
#define HEAP_COUNT4096 1

#if HP_SRAM_SIZE < 0x200000
#define RT_TIMES 3
#define RT_SHARED_TIMES 6
#else
#define RT_TIMES 8
#define RT_SHARED_TIMES 16
#endif

/* Heap section sizes for module pool */
#define HEAP_RT_COUNT64 128
#define HEAP_RT_COUNT128 64
#define HEAP_RT_COUNT256 128
#define HEAP_RT_COUNT512 8
#define HEAP_RT_COUNT1024 4
#define HEAP_RT_COUNT2048 1
#define HEAP_RT_COUNT4096 1
#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie for my education, what does HEAP_COUNT64 (HEap section counts base) mean?

#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES)
#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES)
#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES)
#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES)
#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES)
#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES)

/* Heap configuration */
#define HEAP_RUNTIME_SIZE \
Expand All @@ -266,11 +283,11 @@
HEAP_RT_COUNT4096 * 4096)

/* Heap section sizes for runtime shared heap */
#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT)
#define HEAP_RUNTIME_SHARED_COUNT128 64
#define HEAP_RUNTIME_SHARED_COUNT256 4
#define HEAP_RUNTIME_SHARED_COUNT512 16
#define HEAP_RUNTIME_SHARED_COUNT1024 (4 + CONFIG_CORE_COUNT)
#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES)
#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES)

#define HEAP_RUNTIME_SHARED_SIZE \
(HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \
Expand Down