diff options
author | Aaron Tomlin <atomlin@redhat.com> | 2022-03-22 14:03:35 +0000 |
---|---|---|
committer | Luis Chamberlain <mcgrof@kernel.org> | 2022-04-05 08:43:04 -0700 |
commit | 58d208de3e8d87dbe196caf0b57cc58c7a3836ca (patch) | |
tree | c6ad5b8a4547f1c2ef08ee497b06bc6bf43853b1 /kernel/module/internal.h | |
parent | 1be9473e31ab87ad1b6ecf9fd11df461930ede85 (diff) | |
download | lwn-58d208de3e8d87dbe196caf0b57cc58c7a3836ca.tar.gz lwn-58d208de3e8d87dbe196caf0b57cc58c7a3836ca.zip |
module: Move latched RB-tree support to a separate file
No functional change.
This patch migrates module latched RB-tree support
(e.g. see __module_address()) from core module code
into kernel/module/tree_lookup.c.
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Diffstat (limited to 'kernel/module/internal.h')
-rw-r--r-- | kernel/module/internal.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/module/internal.h b/kernel/module/internal.h index ad7a444253ed..f1682e3677be 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -9,6 +9,7 @@ #include <linux/compiler.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/rculist.h> #ifndef ARCH_SHF_SMALL #define ARCH_SHF_SMALL 0 @@ -93,3 +94,35 @@ static inline void module_decompress_cleanup(struct load_info *info) { } #endif + +#ifdef CONFIG_MODULES_TREE_LOOKUP +struct mod_tree_root { + struct latch_tree_root root; + unsigned long addr_min; + unsigned long addr_max; +}; + +extern struct mod_tree_root mod_tree; + +void mod_tree_insert(struct module *mod); +void mod_tree_remove_init(struct module *mod); +void mod_tree_remove(struct module *mod); +struct module *mod_find(unsigned long addr); +#else /* !CONFIG_MODULES_TREE_LOOKUP */ + +static inline void mod_tree_insert(struct module *mod) { } +static inline void mod_tree_remove_init(struct module *mod) { } +static inline void mod_tree_remove(struct module *mod) { } +static inline struct module *mod_find(unsigned long addr) +{ + struct module *mod; + + list_for_each_entry_rcu(mod, &modules, list, + lockdep_is_held(&module_mutex)) { + if (within_module(addr, mod)) + return mod; + } + + return NULL; +} +#endif /* CONFIG_MODULES_TREE_LOOKUP */ |