From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Sat, 05 Feb 2011 20:33:59 +1100 Subject: [U-Boot] [U-BOOT] [PATCH] env: reduce the stack footprint for the env buf In-Reply-To: <20110205083050.89C7B1B921A3@gemini.denx.de> References: <1296788903-7604-1-git-send-email-leiwen@marvell.com> <20110204211837.542E4108BCC7@gemini.denx.de> <20110205083050.89C7B1B921A3@gemini.denx.de> Message-ID: <4D4D1987.5010405@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 05/02/11 19:30, Wolfgang Denk wrote: > Dear Lei Wen, > > In message 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... > >> 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. > Sounds like you have allocated too small a region for your stack - try increasing CONFIG_SYS_STACK_SIZE and decreasing CONFIG_SYS_MALLOC_LEN > 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. > > 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? > The only other thing I could think of that would make sense would be having the malloc heap in a completely different memory segment to the stack - odd, but possible Regards, Graeme