From: "Andreas Bießmann" <andreas.devel@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] lib/hashtable.c: add CONFIG_ENV_MIN_ENTRIES
Date: Fri, 1 Oct 2010 22:51:02 +0200 [thread overview]
Message-ID: <1285966262-73388-1-git-send-email-andreas.devel@googlemail.com> (raw)
In-Reply-To: <1285788486-43901-1-git-send-email-andreas.devel@googlemail.com>
This patch adds a new config parameter for adjusting the calculation of
hash table size when importing a buffer.
When importing a extremely small buffer (e.g. the default_environment)
the old calculation generated a hash table which could hold at most the
buffer content but no more entires.
The new calculation add a fixed number of entries to the result to fit
better for small import buffers. This amount may be configured by the
user in board file to adjust the behaviour.
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
v2: implement as suggested by Wolfgang
lib/hashtable.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/hashtable.c b/lib/hashtable.c
index b747f1f..57802cf 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -45,6 +45,9 @@
# include <linux/string.h>
#endif
+#ifndef CONFIG_ENV_MIN_ENTRIES /* minimum number of entries */
+#define CONFIG_ENV_MIN_ENTRIES 64
+#endif
#ifndef CONFIG_ENV_MAX_ENTRIES /* maximum number of entries */
#define CONFIG_ENV_MAX_ENTRIES 512
#endif
@@ -647,13 +650,14 @@ int himport_r(struct hsearch_data *htab,
* (CONFIG_ENV_SIZE). This heuristics will result in
* unreasonably large numbers (and thus memory footprint) for
* big flash environments (>8,000 entries for 64 KB
- * envrionment size), so we clip it to a reasonable value
- * (which can be overwritten in the board config file if
- * needed).
+ * envrionment size), so we clip it to a reasonable value.
+ * On the other hand we need to add some more entries for free
+ * space when importing very small buffers. Both boundaries can
+ * be overwritten in the board config file if needed.
*/
if (!htab->table) {
- int nent = size / 8;
+ int nent = CONFIG_ENV_MIN_ENTRIES + size / 8;
if (nent > CONFIG_ENV_MAX_ENTRIES)
nent = CONFIG_ENV_MAX_ENTRIES;
--
1.7.3.1
next prev parent reply other threads:[~2010-10-01 20:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-29 19:28 [U-Boot] [PATCH] lib/hashtable.c: add algorithm for small buffer import Andreas Bießmann
2010-09-29 20:01 ` Wolfgang Denk
2010-09-29 20:43 ` Andreas Bießmann
2010-09-29 21:02 ` Wolfgang Denk
2010-09-29 21:43 ` Andreas Bießmann
2010-10-01 20:51 ` Andreas Bießmann [this message]
2010-10-06 20:47 ` [U-Boot] [PATCH v2] lib/hashtable.c: add CONFIG_ENV_MIN_ENTRIES Wolfgang Denk
2010-10-08 6:28 ` Andreas Bießmann
2010-10-08 8:15 ` Wolfgang Denk
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=1285966262-73388-1-git-send-email-andreas.devel@googlemail.com \
--to=andreas.devel@googlemail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.