From ff7bd7083f36db8092ded1bca8866ede1069150f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 21 Jul 2021 17:44:05 -0300 Subject: [PATCH] core: Allow sizing the loader hash table For now this will only apply to the dwarf loader, for experimenting as time passes and kernels grow bigger or with more symbols. Signed-off-by: Arnaldo Carvalho de Melo --- dwarf_loader.c | 15 +++++++++++++++ dwarves.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/dwarf_loader.c b/dwarf_loader.c index e88f368..4d15abc 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -3042,6 +3042,21 @@ static int dwarf__load_file(struct cus *cus, struct conf_load *conf, { int fd, err; + if (conf->max_hashtable_bits != 0) { + if (conf->max_hashtable_bits > 31) + return -E2BIG; + + max_hashtags__bits = conf->max_hashtable_bits; + } + + if (conf->hashtable_bits != 0) { + if (conf->hashtable_bits > max_hashtags__bits) + return -E2BIG; + + hashtags__bits = conf->hashtable_bits; + } else if (hashtags__bits > max_hashtags__bits) + return -EINVAL; + elf_version(EV_CURRENT); fd = open(filename, O_RDONLY); diff --git a/dwarves.h b/dwarves.h index 2445820..7c7c9dc 100644 --- a/dwarves.h +++ b/dwarves.h @@ -56,6 +56,8 @@ struct conf_load { bool ignore_alignment_attr; bool ignore_inline_expansions; bool ignore_labels; + uint8_t hashtable_bits; + uint8_t max_hashtable_bits; uint16_t kabi_prefix_len; const char *kabi_prefix; struct btf *base_btf;