From patchwork Fri Feb 20 11:06:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemyslaw Marczak X-Patchwork-Id: 441912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 9116E140188 for ; Fri, 20 Feb 2015 22:07:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28CD24B7E9; Fri, 20 Feb 2015 12:07:34 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bOWlu_tzwa4C; Fri, 20 Feb 2015 12:07:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2EC074B7F2; Fri, 20 Feb 2015 12:07:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AFF774B72A for ; Fri, 20 Feb 2015 12:07:17 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mXbhyZAStvf6 for ; Fri, 20 Feb 2015 12:07:17 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout4.w1.samsung.com (mailout4.w1.samsung.com [210.118.77.14]) by theia.denx.de (Postfix) with ESMTPS id 6F5124B765 for ; Fri, 20 Feb 2015 12:07:17 +0100 (CET) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NK2004SGHQP2010@mailout4.w1.samsung.com> for u-boot@lists.denx.de; Fri, 20 Feb 2015 11:11:13 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-e4-54e714cd8456 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id E4.AA.26295.DC417E45; Fri, 20 Feb 2015 11:04:45 +0000 (GMT) Received: from AMDC1186.digital.local ([106.116.147.185]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NK20002RHJVJD90@eusync3.samsung.com>; Fri, 20 Feb 2015 11:07:13 +0000 (GMT) From: Przemyslaw Marczak To: u-boot@lists.denx.de Date: Fri, 20 Feb 2015 12:06:17 +0100 Message-id: <1424430379-12599-5-git-send-email-p.marczak@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1424430379-12599-1-git-send-email-p.marczak@samsung.com> References: <1424099601-14979-1-git-send-email-p.marczak@samsung.com> <1424430379-12599-1-git-send-email-p.marczak@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLLMWRmVeSWpSXmKPExsVy+t/xq7pnRZ6HGDTuNLc49ecxo8WnhSdY Ld483MxocXTPPWaLjiMtjBY7Lt9gsdh1ezKLxbct2xgtph9/y2pxY3oLq8XkxfOZLd7u7WS3 OPrlGpsDr8e8nxOZPD4cvcbmMbvhIovH3+fXWTx2zrrL7jFt4kdmj7N3djB69Da/Y/Po27KK 0eP4je1MAVxRXDYpqTmZZalF+nYJXBlz96sW/JOp+LjnMVMD4wOxLkZODgkBE4k/L+6xQ9hi EhfurWfrYuTiEBJYyihxZPUDRginj0mi5ftuFpAqNgEDiT2XzjCD2CICEhK/+q8ygtjMAh+Y JS5MKwKxhQW8Jd78fwEWZxFQlfj5fQcTiM0r4CoxbX07C8Q2OYmTxyazgticAm4SDRsOg80U EmhklFiwhHsCI+8CRoZVjKKppckFxUnpuUZ6xYm5xaV56XrJ+bmbGCFB/HUH49JjVocYBTgY lXh4BS49CxFiTSwrrsw9xCjBwawkwhsv/DxEiDclsbIqtSg/vqg0J7X4ECMTB6dUA2N9XcmN neHKXyds8r5TdGPOap/qzT9NT3xtMp20ZOOT8tnXtrg8+2tyf9Yl2TnLr98XKwzckXeC9Y/D +VptFs1jJfM27//440s1X21kqemsQsZ+3rLVkfvuLN4k/PbxRBlRHWvtw9W3LrB4npOVO2DP 22rdKj3x4pEv+n/mLDDTeCWuJfuVP2+lEktxRqKhFnNRcSIAL5dyYEACAAA= Cc: Akshay Saraswat , Stephen Warren , Pantelis Antoniou , Przemyslaw Marczak , Tom Rini Subject: [U-Boot] [PATCH v3 4/6] dlmalloc: add option for skip memset in malloc init X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Simon Glass --- 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;