From patchwork Tue Feb 24 10:38:28 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Przemyslaw Marczak
X-Patchwork-Id: 442916
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 0D523140157
for ;
Tue, 24 Feb 2015 21:56:25 +1100 (AEDT)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id CE90E4A049;
Tue, 24 Feb 2015 11:56:15 +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 VbEI1fTD-imS; Tue, 24 Feb 2015 11:56:15 +0100 (CET)
Received: from theia.denx.de (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 5C5654A046;
Tue, 24 Feb 2015 11:56:02 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id A80384A01F
for ; Tue, 24 Feb 2015 11:55:51 +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 70Nn58P2uQAf for ;
Tue, 24 Feb 2015 11:55:51 +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 mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12]) by theia.denx.de (Postfix) with ESMTPS id 650324A029
for ; Tue, 24 Feb 2015 11:55:51 +0100 (CET)
Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244])
by mailout2.w1.samsung.com
(Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit
(built Nov
17 2011)) with ESMTP id <0NK900IUOVVP2S70@mailout2.w1.samsung.com>
for u-boot@lists.denx.de; Tue, 24 Feb 2015 10:59:49 +0000 (GMT)
X-AuditID: cbfec7f4-b7f126d000001e9a-f0-54ec5823dd5d
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 55.F4.07834.3285CE45;
Tue, 24 Feb 2015 10:53:23 +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 <0NK90017EVOSYH00@eusync3.samsung.com>; Tue,
24 Feb 2015 10:55:48 +0000 (GMT)
From: Przemyslaw Marczak
To: u-boot@lists.denx.de
Date: Tue, 24 Feb 2015 11:38:28 +0100
Message-id: <1424774311-23726-5-git-send-email-p.marczak@samsung.com>
X-Mailer: git-send-email 1.9.1
In-reply-to: <1424774311-23726-1-git-send-email-p.marczak@samsung.com>
References: <1424711811-3442-1-git-send-email-p.marczak@samsung.com>
<1424774311-23726-1-git-send-email-p.marczak@samsung.com>
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFlrLLMWRmVeSWpSXmKPExsVy+t/xq7rKEW9CDM60ilmc+vOY0eLTwhOs
Fm8ebma0OLrnHrNFx5EWRosdl2+wWOy6PZnF4tuWbYwW04+/ZbW4Mb2F1WLy4vnMFm/3drJb
HP1yjc2B12Pez4lMHh+OXmPzmN1wkcXj7/PrLB47Z91l95g28SOzx9k7Oxg9epvfsXn0bVnF
6HH8xnamAK4oLpuU1JzMstQifbsErozurptsBT/kKw7NWsTYwPhfoouRk0NCwERi/9Sf7BC2
mMSFe+vZuhi5OIQEljJKXD/0mxHC6WOS+LtmNhNIFZuAgcSeS2eYQWwRAQmJX/1XGUFsZoEP
zBIvn2SB2MICARKL204DTeLgYBFQlVjyhRskzCvgKnHqLUSrhICcxMljk1lBbE4BN4lT+9aC
2UICDYwSu14nTGDkXcDIsIpRNLU0uaA4KT3XUK84Mbe4NC9dLzk/dxMjJIi/7GBcfMzqEKMA
B6MSD++DslchQqyJZcWVuYcYJTiYlUR4C3zehAjxpiRWVqUW5ccXleakFh9iZOLglGpgXPCh
XLL0WMXus9xVjg9zTwa5Wx91vqjfGn/RIObiL4219dLMG+MvCksxdTw+kGNVKvRMiN9erCqP
zVd0S7kqx1XZHr6dNyQf7g067t+qufX9vepln603HNgTuCF413u5iPNHoypPbM5gWvfSv1x7
ss6U/tKFTMc/BEXKLSqZl9WazXvroZKTEktxRqKhFnNRcSIAjYXGhEACAAA=
Cc: Akshay Saraswat ,
Stephen Warren ,
Pantelis Antoniou ,
Przemyslaw Marczak , Tom Rini
Subject: [U-Boot] [PATCH v5 4/7] dlmalloc: do memset in malloc init as new
default config
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_CLEAR_ON_INIT.
This config is an expert option and is enabled by default.
The all amount of memory reserved for the malloc, is by default set
to zero in mem_malloc_init(). When the malloc reserved memory exceeds
few MiB, then the boot process can slow down.
So disabling this config, is an expert option to reduce the boot time,
and can be disabled by Kconfig.
Note:
After disable this option, only calloc() will return the pointer
to the 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
Acked-by: Lukasz Majewski
---
Changes v3:
- squash the commit with the Kconfig option
Changes v4:
- adjust commit message for the new config
Changes v5:
- change config name to CONFIG_SYS_MALLOC_CLEAR_ON_INIT
---
Kconfig | 32 +++++++++++++++++++++++++-------
common/dlmalloc.c | 10 +++++++---
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/Kconfig b/Kconfig
index 75bab7f..d6c75d5 100644
--- a/Kconfig
+++ b/Kconfig
@@ -76,13 +76,31 @@ 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)"
+ default y
+ 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_CLEAR_ON_INIT
+ bool "Init with zeros the memory reserved for malloc (slow)"
+ default y
+ help
+ This setting is enabled by default. The reserved malloc
+ memory is initialized with zeros, so first malloc calls
+ will return the pointer to the zeroed memory. But this
+ slows the boot time.
+
+ It is recommended to disable it, when CONFIG_SYS_MALLOC_LEN
+ value, has more than few MiB, e.g. when uses bzip2 or bmp logo.
+ Then the boot time can be significantly reduced.
+ Warning:
+ When disabling 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..b2ce063 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);
-
+#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
+ 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 */
+#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
#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);
+#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
#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;