lib/hashtable.c: add CONFIG_ENV_MIN_ENTRIES
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 Biemann <andreas.devel@googlemail.com>
This commit is contained in:
parent
f44a928e7e
commit
fc5fc76bda
|
@ -45,6 +45,9 @@
|
||||||
# include <linux/string.h>
|
# include <linux/string.h>
|
||||||
#endif
|
#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 */
|
#ifndef CONFIG_ENV_MAX_ENTRIES /* maximum number of entries */
|
||||||
#define CONFIG_ENV_MAX_ENTRIES 512
|
#define CONFIG_ENV_MAX_ENTRIES 512
|
||||||
#endif
|
#endif
|
||||||
|
@ -647,13 +650,14 @@ int himport_r(struct hsearch_data *htab,
|
||||||
* (CONFIG_ENV_SIZE). This heuristics will result in
|
* (CONFIG_ENV_SIZE). This heuristics will result in
|
||||||
* unreasonably large numbers (and thus memory footprint) for
|
* unreasonably large numbers (and thus memory footprint) for
|
||||||
* big flash environments (>8,000 entries for 64 KB
|
* big flash environments (>8,000 entries for 64 KB
|
||||||
* envrionment size), so we clip it to a reasonable value
|
* envrionment size), so we clip it to a reasonable value.
|
||||||
* (which can be overwritten in the board config file if
|
* On the other hand we need to add some more entries for free
|
||||||
* needed).
|
* space when importing very small buffers. Both boundaries can
|
||||||
|
* be overwritten in the board config file if needed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!htab->table) {
|
if (!htab->table) {
|
||||||
int nent = size / 8;
|
int nent = CONFIG_ENV_MIN_ENTRIES + size / 8;
|
||||||
|
|
||||||
if (nent > CONFIG_ENV_MAX_ENTRIES)
|
if (nent > CONFIG_ENV_MAX_ENTRIES)
|
||||||
nent = CONFIG_ENV_MAX_ENTRIES;
|
nent = CONFIG_ENV_MAX_ENTRIES;
|
||||||
|
|
Loading…
Reference in New Issue