Skip to contentSkip to conversation

spl: add debug print for early malloc usage

PATCH In review Simon Goldschmidt 3 participants 6 messages Feb 26, 2019 – Mar 1, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: add debug print for early malloc usage

To find out how big the early malloc heap must be in SPL, add a debug print statement that dumps its usage before switching to relocated heap in spl_relocate_stack_gd() via CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN.

---

 common/spl/spl.c | 2 ++
 1 file changed, 2 insertions(+)
common/spl/spl.c +2 -0
index 2e2af1b28e..88d4b8a9bf 100644
@@ -728,6 +728,8 @@ ulong spl_relocate_stack_gd(void)
 
 #if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN)
 	if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
+		debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n",
+		      gd->malloc_ptr, gd->malloc_ptr / 1024);
 		ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
 		gd->malloc_base = ptr;
 		gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Simon Goldschmidt

To find out how big the early malloc heap must be in SPL, add a debug print statement that dumps its usage before switching to relocated heap in spl_relocate_stack_gd() via CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190228/3cb99d12/attachment.sig>
#2 lore raw

PATCH 1/1 spl: add debug print for early malloc usage

In reply to Simon Goldschmidt
Quoted 15 lines · Simon Goldschmidt

To find out how big the early malloc heap must be in SPL, add a debug print statement that dumps its usage before switching to relocated heap in spl_relocate_stack_gd() via CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN.

---

 common/spl/spl.c | 2 ++
 1 file changed, 2 insertions(+)
common/spl/spl.c +0 -0
index 2e2af1b28e..88d4b8a9bf 100644

common/spl/spl.c ulong spl_relocate_stack_gd(void) · line 732

Quoted 5 lines
common/spl/spl.c +2 -0
@@ -728,6 +728,8 @@ ulong spl_relocate_stack_gd(void)
 
 #if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN)
 	if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
+		debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n",
+		      gd->malloc_ptr, gd->malloc_ptr / 1024);

Shouldn't this use %p ?

Quoted 4 lines
common/spl/spl.c +0 -0
 		ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
 		gd->malloc_base = ptr;
 		gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/1 spl: add debug print for early malloc usage

Quoted 18 lines · Marek Vasut
Quoted 16 lines · Simon Goldschmidt

To find out how big the early malloc heap must be in SPL, add a debug print statement that dumps its usage before switching to relocated heap in spl_relocate_stack_gd() via CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN.

---

 common/spl/spl.c | 2 ++
 1 file changed, 2 insertions(+)
common/spl/spl.c +0 -0
index 2e2af1b28e..88d4b8a9bf 100644
@@ -728,6 +728,8 @@ ulong spl_relocate_stack_gd(void)
 
Quoted 6 lines

common/spl/spl.c ulong spl_relocate_stack_gd(void) · line 732

Quoted 4 lines
common/spl/spl.c +2 -0
 #if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN)
      if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
+             debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n",
+                   gd->malloc_ptr, gd->malloc_ptr / 1024);

Shouldn't this use %p ?

Despite its name, 'gd->malloc_ptr' is of type 'unsigned long', so I think this is
correct. After all, I only copied the code from other places where the heap usage is dumped, too.

Regards,
Simon

Quoted 10 lines

common/spl/spl.c ulong spl_relocate_stack_gd(void) · line 735

Quoted 5 lines
common/spl/spl.c +0 -0
              ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
              gd->malloc_base = ptr;
              gd->malloc_limit = CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;

--
Best regards,
Marek Vasut

#4 lore raw

PATCH 1/1 spl: add debug print for early malloc usage

Quoted 26 lines · Simon Goldschmidt
Quoted 18 lines · Marek Vasut
Quoted 16 lines · Simon Goldschmidt

To find out how big the early malloc heap must be in SPL, add a debug print statement that dumps its usage before switching to relocated heap in spl_relocate_stack_gd() via CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN.

---

 common/spl/spl.c | 2 ++
 1 file changed, 2 insertions(+)
common/spl/spl.c +0 -0
index 2e2af1b28e..88d4b8a9bf 100644
@@ -728,6 +728,8 @@ ulong spl_relocate_stack_gd(void)
 
Quoted 6 lines

common/spl/spl.c ulong spl_relocate_stack_gd(void) · line 732

Quoted 4 lines
common/spl/spl.c +2 -0
 #if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN)
      if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
+             debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n",
+                   gd->malloc_ptr, gd->malloc_ptr / 1024);

Shouldn't this use %p ?

Quoted 4 lines

Despite its name, 'gd->malloc_ptr' is of type 'unsigned long', so I think this is
correct. After all, I only copied the code from other places where the heap usage is dumped, too.

Isn't that broken on some arm64 systems then ? :)

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH 1/1 spl: add debug print for early malloc usage

Quoted 28 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 24 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt

To find out how big the early malloc heap must be in SPL, add a debug print statement that dumps its usage before switching to relocated heap in spl_relocate_stack_gd() via CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN.

---

 common/spl/spl.c | 2 ++
 1 file changed, 2 insertions(+)
common/spl/spl.c +0 -0
index 2e2af1b28e..88d4b8a9bf 100644

common/spl/spl.c ulong spl_relocate_stack_gd(void) · line 732

Quoted 5 lines
common/spl/spl.c +2 -0
@@ -728,6 +728,8 @@ ulong spl_relocate_stack_gd(void)
 
 #if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN)
      if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
+             debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n",
+                   gd->malloc_ptr, gd->malloc_ptr / 1024);

Shouldn't this use %p ?

Quoted 6 lines
Quoted 4 lines

Despite its name, 'gd->malloc_ptr' is of type 'unsigned long', so I think this is
correct. After all, I only copied the code from other places where the heap usage is dumped, too.

Isn't that broken on some arm64 systems then ? :)

I don't think it's broken for 'ptr' as that seems to be the offset into the malloc pool.

Some 64-bit platforms migth have a problem with gd->malloc_base being unsigned long though - I don't know the size of unsigned long on arm64.

Regards,
Simon