From patchwork Thu Dec 19 12:45:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 303529 X-Patchwork-Delegate: trini@ti.com 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 ACC402C00DB for ; Thu, 19 Dec 2013 23:45:30 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 74BAB4A08D; Thu, 19 Dec 2013 13:45:27 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 suGiQIMwWMhU; Thu, 19 Dec 2013 13:45:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6A26C4A237; Thu, 19 Dec 2013 13:45:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CBEFA4A237 for ; Thu, 19 Dec 2013 13:45:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 82AjZoyYAxmn for ; Thu, 19 Dec 2013 13:45:12 +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 pollux.denx.de (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by theia.denx.de (Postfix) with ESMTP id C061F4A08D for ; Thu, 19 Dec 2013 13:45:05 +0100 (CET) Received: by pollux.denx.de (Postfix, from userid 515) id 3F5B4FE6; Thu, 19 Dec 2013 13:45:05 +0100 (CET) From: Heiko Schocher To: u-boot@lists.denx.de Date: Thu, 19 Dec 2013 13:45:04 +0100 Message-Id: <1387457104-3048-1-git-send-email-hs@denx.de> X-Mailer: git-send-email 1.8.3.1 Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH] common, env: optimize boottime X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de when creating the hashtable, for each environmentvariable getenv(ENV_CALLBACK_VAR) and getenv(ENV_FLAGS_VAR) is called, which costs at this point a lot of time. So call this two getenv() calls only once. Boottime on the ids8313 board without this patch: 2013-12-19 13:38:22,894: NAND: 128 MiB 2013-12-19 13:38:27,659: In: serial (~4.8 sec) Bootime with this patch on the ids8313 board: 2013-12-19 13:40:25,332: NAND: 128 MiB 2013-12-19 13:40:25,546: In: serial (~0.2 sec) Signed-off-by: Heiko Schocher Cc: Tom Rini Cc: Joe Hershberger Cc: Wolfgang Denk --- common/env_callback.c | 9 ++++++++- common/env_flags.c | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/env_callback.c b/common/env_callback.c index 34bb58e..d03fa03 100644 --- a/common/env_callback.c +++ b/common/env_callback.c @@ -35,6 +35,9 @@ static struct env_clbk_tbl *find_env_callback(const char *name) return NULL; } +static int first_call = 1; +static const char *callback_list; + /* * Look for a possible callback for a newly added variable * This is called specifically when the variable did not exist in the hash @@ -43,11 +46,15 @@ static struct env_clbk_tbl *find_env_callback(const char *name) void env_callback_init(ENTRY *var_entry) { const char *var_name = var_entry->key; - const char *callback_list = getenv(ENV_CALLBACK_VAR); char callback_name[256] = ""; struct env_clbk_tbl *clbkp; int ret = 1; + if (first_call) { + callback_list = getenv(ENV_CALLBACK_VAR); + first_call = 0; + } + /* look in the ".callbacks" var for a reference to this variable */ if (callback_list != NULL) ret = env_attr_lookup(callback_list, var_name, callback_name); diff --git a/common/env_flags.c b/common/env_flags.c index e9b72e6..985f92e 100644 --- a/common/env_flags.c +++ b/common/env_flags.c @@ -395,6 +395,9 @@ static int env_parse_flags_to_bin(const char *flags) return binflags; } +static int first_call = 1; +static const char *flags_list; + /* * Look for possible flags for a newly added variable * This is called specifically when the variable did not exist in the hash @@ -403,10 +406,13 @@ static int env_parse_flags_to_bin(const char *flags) void env_flags_init(ENTRY *var_entry) { const char *var_name = var_entry->key; - const char *flags_list = getenv(ENV_FLAGS_VAR); char flags[ENV_FLAGS_ATTR_MAX_LEN + 1] = ""; int ret = 1; + if (first_call) { + flags_list = getenv(ENV_FLAGS_VAR); + first_call = 0; + } /* look in the ".flags" and static for a reference to this variable */ ret = env_flags_lookup(flags_list, var_name, flags);