public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 4/6] dlmalloc: add option for skip memset in malloc init
Date: Fri, 20 Feb 2015 18:08:20 +0100	[thread overview]
Message-ID: <54E76A04.9070306@samsung.com> (raw)
In-Reply-To: <20150220215230.DDC4.AA925319@jp.panasonic.com>

Hello,

On 02/20/2015 01:52 PM, Masahiro Yamada wrote:
> Hi Przemyslaw,
>
>
> On Fri, 20 Feb 2015 12:06:17 +0100
> Przemyslaw Marczak <p.marczak@samsung.com> wrote:
>
>> This commit introduces new config: CONFIG_SYS_MALLOC_INIT_SKIP_ZEROING.
>>
>> Before this change, the all amount of memory reserved for the malloc,
>> was set to zero in mem_malloc_init(). When the malloc reserved memory
>> exceeds few MiB, then the boot process can slow down.
>>
>> So enabling this config, is an option to reduce the boot time.
>>
>> This option can be enabled by Kconfig.
>>
>> Note:
>> After enable this option, only calloc() will return the pointer to zeroed
>> memory area. Previously, without this option, the memory pointed to untouched
>> malloc memory region, was filled with zeros. So it means, that code with
>> malloc() calls should be reexamined.
>>
>> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> ---
>> Changes v3:
>> - squash the commit with the Kconfig option
>> ---
>>   Kconfig           | 26 +++++++++++++++++++-------
>>   common/dlmalloc.c | 10 +++++++---
>>   2 files changed, 26 insertions(+), 10 deletions(-)
>>
>> diff --git a/Kconfig b/Kconfig
>> index 75bab7f..87d4daf 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -76,13 +76,25 @@ config SYS_MALLOC_F_LEN
>>   	  initial serial device and any others that are needed.
>>
>>   menuconfig EXPERT
>> -        bool "Configure standard U-Boot features (expert users)"
>> -        help
>> -          This option allows certain base U-Boot options and settings
>> -          to be disabled or tweaked. This is for specialized
>> -          environments which can tolerate a "non-standard" U-Boot.
>> -          Only use this if you really know what you are doing.
>> -
>> +	bool "Configure standard U-Boot features (expert users)"
>> +	help
>> +	  This option allows certain base U-Boot options and settings
>> +	  to be disabled or tweaked. This is for specialized
>> +	  environments which can tolerate a "non-standard" U-Boot.
>> +	  Only use this if you really know what you are doing.
>> +
>> +if EXPERT
>> +	config SYS_MALLOC_INIT_SKIP_ZEROING
>> +	bool "Skip memset at malloc init (reduce boot time)"
>> +	help
>> +	  This avoids zeroing memory reserved for malloc at malloc init.
>> +	  Significant boot time reduction is visible for configs in which
>> +	  CONFIG_SYS_MALLOC_LEN value, has more than few MiB.
>> +	  Useful for bzip2, bmp logo.
>> +	  Warning:
>> +	  When enabling this, please check if malloc calls, maybe
>> +	  should be replaced by calloc - if expects zeroed memory.
>> +endif
>>   endmenu		# General setup
>>
>>   menu "Boot images"
>> diff --git a/common/dlmalloc.c b/common/dlmalloc.c
>> index 6453ee9..63f68ed 100644
>> --- a/common/dlmalloc.c
>> +++ b/common/dlmalloc.c
>> @@ -1535,9 +1535,9 @@ void mem_malloc_init(ulong start, ulong size)
>>
>>   	debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
>>   	      mem_malloc_end);
>> -
>> -	memset((void *)mem_malloc_start, 0, size);
>> -
>> +#ifndef CONFIG_SYS_MALLOC_INIT_SKIP_ZEROING
>> +	memset((void *)mem_malloc_start, 0x0, size);
>> +#endif
>>   	malloc_bin_reloc();
>>   }
>>
>> @@ -2948,10 +2948,12 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
>>
>>
>>     /* check if expand_top called, in which case don't need to clear */
>> +#ifndef CONFIG_SYS_MALLOC_INIT_SKIP_ZEROING
>>   #if MORECORE_CLEARS
>>     mchunkptr oldtop = top;
>>     INTERNAL_SIZE_T oldtopsize = chunksize(top);
>>   #endif
>> +#endif
>>     Void_t* mem = mALLOc (sz);
>>
>>     if ((long)n < 0) return NULL;
>> @@ -2977,6 +2979,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
>>
>>       csz = chunksize(p);
>>
>> +#ifndef CONFIG_SYS_MALLOC_INIT_SKIP_ZEROING
>>   #if MORECORE_CLEARS
>>       if (p == oldtop && csz > oldtopsize)
>>       {
>> @@ -2984,6 +2987,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
>>         csz = oldtopsize;
>>       }
>>   #endif
>> +#endif
>>
>>       MALLOC_ZERO(mem, csz - SIZE_SZ);
>>       return mem;
>
>
> You are adding only "ifndef" conditionals.
>
> IMHO,
> Isn't "#ifdef CONFIG_SYS_MALLOC_INIT_ZEROING" better?
> (Generally speaking, CONFIG options that disable a feature are not preferable.)
>
> You also need to add "default y" to the Kconfig
> and add "# CONIFG_SYS_MALLOC_INIT_ZEROING is not set" to your defconfig.
>
>
> Best Regards
> Masahiro Yamada
>

Ok, will change this to positive.

Best regards,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

  reply	other threads:[~2015-02-20 17:08 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 15:13 [U-Boot] [PATCH v2 0/8] arm: a few steps to reduce the boot time Przemyslaw Marczak
2015-02-16 15:13 ` [U-Boot] [PATCH v2 1/8] exynos: config: enable arch memcpy and arch memset Przemyslaw Marczak
2015-02-18  4:23   ` Simon Glass
2015-02-18 12:21     ` Przemyslaw Marczak
2015-02-16 15:13 ` [U-Boot] [PATCH v2 2/8] arm: relocation: clear .bss section with arch memset if defined Przemyslaw Marczak
2015-02-16 15:21   ` Przemyslaw Marczak
2015-02-18  4:32     ` Simon Glass
2015-02-18 12:31       ` Przemyslaw Marczak
2015-02-19 18:59         ` Simon Glass
2015-02-16 15:13 ` [U-Boot] [PATCH v2 3/8] dfu: mmc: file buffer: remove static allocation Przemyslaw Marczak
2015-02-18  4:32   ` Simon Glass
2015-02-16 15:13 ` [U-Boot] [PATCH v2 4/8] dlmalloc: add option for skip memset in malloc init Przemyslaw Marczak
2015-02-18  4:32   ` Simon Glass
2015-02-16 15:13 ` [U-Boot] [PATCH v2 5/8] README: add info about skip memset at " Przemyslaw Marczak
2015-02-18  4:32   ` Simon Glass
2015-02-16 15:13 ` [U-Boot] [PATCH v2 6/8] kconfig: malloc: add option for " Przemyslaw Marczak
2015-02-18  4:32   ` Simon Glass
2015-02-18 12:40     ` Przemyslaw Marczak
2015-02-19 18:59       ` Simon Glass
2015-02-20  7:32         ` Masahiro Yamada
2015-02-20  9:46           ` Przemyslaw Marczak
2015-02-16 15:13 ` [U-Boot] [PATCH v2 7/8] trats2: defconfig: enable expert and " Przemyslaw Marczak
2015-02-18  4:32   ` Simon Glass
2015-02-16 15:13 ` [U-Boot] [PATCH v2 8/8] odroid: defconfig: enable expert and skip malloc memset Przemyslaw Marczak
2015-02-18  4:32   ` Simon Glass
2015-02-18 12:42     ` Przemyslaw Marczak
2015-02-17 21:43 ` [U-Boot] [PATCH v2 0/8] arm: a few steps to reduce the boot time Stephen Warren
2015-02-17 22:39   ` Stephen Warren
2015-02-18 12:58     ` Przemyslaw Marczak
2015-02-20 11:06 ` [U-Boot] [PATCH v3 0/6] arm: a few steps to improve " Przemyslaw Marczak
2015-02-20 11:06   ` [U-Boot] [PATCH v3 1/6] exynos: config: enable arch memcpy and arch memset Przemyslaw Marczak
2015-02-20 11:06   ` [U-Boot] [PATCH v3 2/6] arm: relocation: clear .bss section with arch memset if defined Przemyslaw Marczak
2015-02-20 11:06   ` [U-Boot] [PATCH v3 3/6] dfu: mmc: file buffer: remove static allocation Przemyslaw Marczak
2015-02-20 11:06   ` [U-Boot] [PATCH v3 4/6] dlmalloc: add option for skip memset in malloc init Przemyslaw Marczak
2015-02-20 12:52     ` Masahiro Yamada
2015-02-20 17:08       ` Przemyslaw Marczak [this message]
2015-02-20 11:06   ` [U-Boot] [PATCH v3 5/6] trats2: defconfig: enable expert and skip memset at " Przemyslaw Marczak
2015-02-20 11:06   ` [U-Boot] [PATCH v3 6/6] odroid: " Przemyslaw Marczak
2015-02-23 17:16   ` [U-Boot] [PATCH v4 0/6] arm: a few steps to improve boot time Przemyslaw Marczak
2015-02-23 17:16     ` [U-Boot] [PATCH v4 1/6] exynos: config: enable arch memcpy and arch memset Przemyslaw Marczak
2015-02-23 17:16     ` [U-Boot] [PATCH v4 2/6] arm: relocation: clear .bss section with arch memset if defined Przemyslaw Marczak
2015-02-23 17:16     ` [U-Boot] [PATCH v4 3/6] dfu: mmc: file buffer: remove static allocation Przemyslaw Marczak
2015-02-23 17:16     ` [U-Boot] [PATCH v4 4/6] dlmalloc: do memset in malloc init as new default config Przemyslaw Marczak
2015-02-23 17:38       ` Simon Glass
2015-02-24 10:59         ` Przemyslaw Marczak
2015-02-23 17:16     ` [U-Boot] [PATCH v4 5/6] trats2: defconfig: disable memset at malloc init Przemyslaw Marczak
2015-02-23 17:16     ` [U-Boot] [PATCH v4 6/6] odroid: " Przemyslaw Marczak
2015-02-24 10:38     ` [U-Boot] [PATCH v5 0/7] arm: a few steps to improve boot time Przemyslaw Marczak
2015-02-24 10:38       ` [U-Boot] [PATCH v5 1/7] exynos: config: enable arch memcpy and arch memset Przemyslaw Marczak
2015-02-24 14:30         ` Lukasz Majewski
2015-02-24 10:38       ` [U-Boot] [PATCH v5 2/7] arm: relocation: clear .bss section with arch memset if defined Przemyslaw Marczak
2015-02-24 14:32         ` Lukasz Majewski
2015-02-24 10:38       ` [U-Boot] [PATCH v5 3/7] dfu: mmc: file buffer: remove static allocation Przemyslaw Marczak
2015-02-24 14:35         ` Lukasz Majewski
2015-02-24 10:38       ` [U-Boot] [PATCH v5 4/7] dlmalloc: do memset in malloc init as new default config Przemyslaw Marczak
2015-02-24 14:38         ` Lukasz Majewski
2015-02-24 10:38       ` [U-Boot] [PATCH v5 5/7] trats2: defconfig: disable memset at malloc init Przemyslaw Marczak
2015-02-24 14:39         ` Lukasz Majewski
2015-02-24 10:38       ` [U-Boot] [PATCH v5 6/7] odroid: " Przemyslaw Marczak
2015-02-24 14:39         ` Lukasz Majewski
2015-02-24 10:38       ` [U-Boot] [PATCH v5 7/7] odroid-xu3: " Przemyslaw Marczak
2015-02-24 14:40         ` Lukasz Majewski
2015-02-24 14:47       ` [U-Boot] [PATCH v5 0/7] arm: a few steps to improve boot time Przemyslaw Marczak
2015-03-04 13:01       ` [U-Boot] [PATCH v6 00/10] " Przemyslaw Marczak
2015-03-04 13:01         ` [U-Boot] [PATCH v6 01/10] exynos: config: enable arch memcpy and arch memset Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 02/10] arm: relocation: clear .bss section with arch memset if defined Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 03/10] dfu: mmc: file buffer: remove static allocation Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 04/10] dlmalloc: do memset in malloc init as new default config Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 05/10] trats2: defconfig: disable memset at malloc init Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 06/10] odroid: " Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 07/10] odroid-xu3: " Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 08/10] zynq-common: increase malloc pool len by dfu mmc file buffer size Przemyslaw Marczak
2015-03-04 13:57           ` Michal Simek
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 09/10] ti-armv7-common: " Przemyslaw Marczak
2015-03-09 16:46           ` [U-Boot] [U-Boot, v6, " Tom Rini
2015-03-04 13:01         ` [U-Boot] [PATCH v6 10/10] tegra-common: " Przemyslaw Marczak
2015-03-09 16:47           ` [U-Boot] [U-Boot, v6, " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54E76A04.9070306@samsung.com \
    --to=p.marczak@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox