diff options
author | Timo Teräs <timo.teras@iki.fi> | 2015-11-05 18:54:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-11-05 18:54:55 +0100 |
commit | 48dc80bbba994eee24ed94ae4532a1cce76d7cb7 (patch) | |
tree | 051e7aacf5538ffc07310bb4261a693a047311d2 /modutils/modutils.h | |
parent | 34adecc2b049f6941c5e075ffb58fe2183823da3 (diff) | |
download | busybox-w32-48dc80bbba994eee24ed94ae4532a1cce76d7cb7.tar.gz busybox-w32-48dc80bbba994eee24ed94ae4532a1cce76d7cb7.tar.bz2 busybox-w32-48dc80bbba994eee24ed94ae4532a1cce76d7cb7.zip |
modutils: merge module_entry and module_info to common
This merges the in-memory module info structures of modprobe
and depmod. This allows sharing hashing by modulename code
improving depmod runtime with almost factor of 2x.
function old new delta
get_or_add_modentry - 17 +17
do_modprobe 590 601 +11
moddb_get_or_create - 10 +10
load_modules_dep 195 205 +10
moddb_get - 7 +7
add_probe 81 78 -3
modprobe_main 721 714 -7
depmod_main 553 543 -10
config_file_action 434 421 -13
helper_get_module 160 144 -16
parse_module 343 320 -23
order_dep_list 105 82 -23
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/7 up/down: 55/-95) Total: -40 bytes
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils/modutils.h')
-rw-r--r-- | modutils/modutils.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/modutils/modutils.h b/modutils/modutils.h index 5f059c716..2cbd1448a 100644 --- a/modutils/modutils.h +++ b/modutils/modutils.h | |||
@@ -16,6 +16,36 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
16 | /* linux/include/linux/module.h has 64, but this is also used | 16 | /* linux/include/linux/module.h has 64, but this is also used |
17 | * internally for the maximum alias name length, which can be quite long */ | 17 | * internally for the maximum alias name length, which can be quite long */ |
18 | #define MODULE_NAME_LEN 256 | 18 | #define MODULE_NAME_LEN 256 |
19 | #define MODULE_HASH_SIZE 256 | ||
20 | |||
21 | typedef struct module_entry { | ||
22 | struct module_entry *next; | ||
23 | char *name, *modname; | ||
24 | llist_t *deps; | ||
25 | IF_MODPROBE( | ||
26 | llist_t *realnames; | ||
27 | unsigned flags; | ||
28 | const char *probed_name; /* verbatim as seen on cmdline */ | ||
29 | char *options; /* options from config files */ | ||
30 | ) | ||
31 | IF_DEPMOD( | ||
32 | llist_t *aliases; | ||
33 | llist_t *symbols; | ||
34 | struct module_entry *dnext, *dprev; | ||
35 | ) | ||
36 | } module_entry; | ||
37 | |||
38 | typedef struct module_db { | ||
39 | module_entry *buckets[MODULE_HASH_SIZE]; | ||
40 | } module_db; | ||
41 | |||
42 | #define moddb_foreach_module(db, module, index) \ | ||
43 | for ((index) = 0; (index) < MODULE_HASH_SIZE; (index)++) \ | ||
44 | for (module = (db)->buckets[index]; module; module = module->next) | ||
45 | |||
46 | module_entry *moddb_get(module_db *db, const char *s) FAST_FUNC; | ||
47 | module_entry *moddb_get_or_create(module_db *db, const char *s) FAST_FUNC; | ||
48 | void moddb_free(module_db *db) FAST_FUNC; | ||
19 | 49 | ||
20 | void replace(char *s, char what, char with) FAST_FUNC; | 50 | void replace(char *s, char what, char with) FAST_FUNC; |
21 | char *replace_underscores(char *s) FAST_FUNC; | 51 | char *replace_underscores(char *s) FAST_FUNC; |