[U-Boot] [U-BOOT] [PATCH] env: reduce the stack footprint for the env buf
Lei Wen
adrian.wenl at gmail.com
Sun Feb 6 16:25:46 CET 2011
Hi Wolfgang,
On Sat, Feb 5, 2011 at 4:30 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Lei Wen,
>
> In message <AANLkTin-EBt+PA0TmdLBPAqo3pBjwmbNLdFUj2K-JOnX at mail.gmail.com> you wrote:
>>
>> > In which way do you think this will save any memory?
>>
>> This patch is not intend to save memory...
>
> Then I don't understand at all what the benefit of that patch would
> be.
>
>> One of our project need to confine the ddr usage of uboot in the smallest case,
>> not to pollute other area. So for us, the small stack is good one...
>
> So it is still about saving memory...
Yes, it also be deemed as saving memory...
>
>> For now the uboot is relocated to the end of the dram, and malloc area is
>> almost a fix value, uboot would live happily in this area. But for env case,
>> it allocate a range which could be large, due to the CONFIG_ENV_SIZE
>> could be a big one, in the stack range. Because the stack is grown downwards,
>> so it takes more memory range than it is allocated in the malloc method.
>
> malloc arena and stack are adjacent. If you have enough free room in
> the malloc arena for the environment buffers, but cannot afford to
> have them on your stack, then this means your malloc arena has lots of
> unused space. Decrease the size of your malloc arena by the size of
> the environment buffer, and you reach the same goal as with your
> patch - actually you save more memory, as the code size of u-boot
> shrinks.
Em, what you said is also right for my case.
But I think making the malloc heap area large while limit the stack usage
could benefit those function use malloc, while keep user in mind how many
memory he is using on that board. For now, uboot just print uboot self-reserved,
malloc size, board info, global data size for the uesr. For the stack usage,
user is not quite aware of.
Just like the env case, if that ENV_SIZE goes too large, user may not notice
the memory usage just from the debug info.
>
> Can you please provide exact numbers? How big is your RAM? What is
> the debug output of arch/*/lib/board.c without and with this patch on
> your system? How big is your environment resp. the environment
> sectors?
>
My ram is big, 512MB. But for my case, I need uboot use the minimum memory
as it can. The debug output is same, for this patch don't change the
heap or other
part's size. My env is configured as 0x20000, as one nand block size.
Best regards,
Lei
More information about the U-Boot
mailing list