module: Prepare for handling several RB trees
In order to separate text and data, we need to setup two rb trees. Modify functions to give the tree as a parameter. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
committed by
Luis Chamberlain
parent
80b8bf4369
commit
446d55666d
@@ -157,13 +157,13 @@ extern struct mod_tree_root mod_tree;
|
|||||||
void mod_tree_insert(struct module *mod);
|
void mod_tree_insert(struct module *mod);
|
||||||
void mod_tree_remove_init(struct module *mod);
|
void mod_tree_remove_init(struct module *mod);
|
||||||
void mod_tree_remove(struct module *mod);
|
void mod_tree_remove(struct module *mod);
|
||||||
struct module *mod_find(unsigned long addr);
|
struct module *mod_find(unsigned long addr, struct mod_tree_root *tree);
|
||||||
#else /* !CONFIG_MODULES_TREE_LOOKUP */
|
#else /* !CONFIG_MODULES_TREE_LOOKUP */
|
||||||
|
|
||||||
static inline void mod_tree_insert(struct module *mod) { }
|
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_init(struct module *mod) { }
|
||||||
static inline void mod_tree_remove(struct module *mod) { }
|
static inline void mod_tree_remove(struct module *mod) { }
|
||||||
static inline struct module *mod_find(unsigned long addr)
|
static inline struct module *mod_find(unsigned long addr, struct mod_tree_root *tree)
|
||||||
{
|
{
|
||||||
struct module *mod;
|
struct module *mod;
|
||||||
|
|
||||||
|
|||||||
@@ -91,22 +91,22 @@ struct symsearch {
|
|||||||
* Bounds of module text, for speeding up __module_address.
|
* Bounds of module text, for speeding up __module_address.
|
||||||
* Protected by module_mutex.
|
* Protected by module_mutex.
|
||||||
*/
|
*/
|
||||||
static void __mod_update_bounds(void *base, unsigned int size)
|
static void __mod_update_bounds(void *base, unsigned int size, struct mod_tree_root *tree)
|
||||||
{
|
{
|
||||||
unsigned long min = (unsigned long)base;
|
unsigned long min = (unsigned long)base;
|
||||||
unsigned long max = min + size;
|
unsigned long max = min + size;
|
||||||
|
|
||||||
if (min < module_addr_min)
|
if (min < tree->addr_min)
|
||||||
module_addr_min = min;
|
tree->addr_min = min;
|
||||||
if (max > module_addr_max)
|
if (max > tree->addr_max)
|
||||||
module_addr_max = max;
|
tree->addr_max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mod_update_bounds(struct module *mod)
|
static void mod_update_bounds(struct module *mod)
|
||||||
{
|
{
|
||||||
__mod_update_bounds(mod->core_layout.base, mod->core_layout.size);
|
__mod_update_bounds(mod->core_layout.base, mod->core_layout.size, &mod_tree);
|
||||||
if (mod->init_layout.size)
|
if (mod->init_layout.size)
|
||||||
__mod_update_bounds(mod->init_layout.base, mod->init_layout.size);
|
__mod_update_bounds(mod->init_layout.base, mod->init_layout.size, &mod_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void module_assert_mutex_or_preempt(void)
|
static void module_assert_mutex_or_preempt(void)
|
||||||
@@ -3017,7 +3017,7 @@ struct module *__module_address(unsigned long addr)
|
|||||||
|
|
||||||
module_assert_mutex_or_preempt();
|
module_assert_mutex_or_preempt();
|
||||||
|
|
||||||
mod = mod_find(addr);
|
mod = mod_find(addr, &mod_tree);
|
||||||
if (mod) {
|
if (mod) {
|
||||||
BUG_ON(!within_module(addr, mod));
|
BUG_ON(!within_module(addr, mod));
|
||||||
if (mod->state == MODULE_STATE_UNFORMED)
|
if (mod->state == MODULE_STATE_UNFORMED)
|
||||||
|
|||||||
@@ -61,14 +61,14 @@ static const struct latch_tree_ops mod_tree_ops = {
|
|||||||
.comp = mod_tree_comp,
|
.comp = mod_tree_comp,
|
||||||
};
|
};
|
||||||
|
|
||||||
static noinline void __mod_tree_insert(struct mod_tree_node *node)
|
static noinline void __mod_tree_insert(struct mod_tree_node *node, struct mod_tree_root *tree)
|
||||||
{
|
{
|
||||||
latch_tree_insert(&node->node, &mod_tree.root, &mod_tree_ops);
|
latch_tree_insert(&node->node, &tree->root, &mod_tree_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __mod_tree_remove(struct mod_tree_node *node)
|
static void __mod_tree_remove(struct mod_tree_node *node, struct mod_tree_root *tree)
|
||||||
{
|
{
|
||||||
latch_tree_erase(&node->node, &mod_tree.root, &mod_tree_ops);
|
latch_tree_erase(&node->node, &tree->root, &mod_tree_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -80,28 +80,28 @@ void mod_tree_insert(struct module *mod)
|
|||||||
mod->core_layout.mtn.mod = mod;
|
mod->core_layout.mtn.mod = mod;
|
||||||
mod->init_layout.mtn.mod = mod;
|
mod->init_layout.mtn.mod = mod;
|
||||||
|
|
||||||
__mod_tree_insert(&mod->core_layout.mtn);
|
__mod_tree_insert(&mod->core_layout.mtn, &mod_tree);
|
||||||
if (mod->init_layout.size)
|
if (mod->init_layout.size)
|
||||||
__mod_tree_insert(&mod->init_layout.mtn);
|
__mod_tree_insert(&mod->init_layout.mtn, &mod_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mod_tree_remove_init(struct module *mod)
|
void mod_tree_remove_init(struct module *mod)
|
||||||
{
|
{
|
||||||
if (mod->init_layout.size)
|
if (mod->init_layout.size)
|
||||||
__mod_tree_remove(&mod->init_layout.mtn);
|
__mod_tree_remove(&mod->init_layout.mtn, &mod_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mod_tree_remove(struct module *mod)
|
void mod_tree_remove(struct module *mod)
|
||||||
{
|
{
|
||||||
__mod_tree_remove(&mod->core_layout.mtn);
|
__mod_tree_remove(&mod->core_layout.mtn, &mod_tree);
|
||||||
mod_tree_remove_init(mod);
|
mod_tree_remove_init(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct module *mod_find(unsigned long addr)
|
struct module *mod_find(unsigned long addr, struct mod_tree_root *tree)
|
||||||
{
|
{
|
||||||
struct latch_tree_node *ltn;
|
struct latch_tree_node *ltn;
|
||||||
|
|
||||||
ltn = latch_tree_find((void *)addr, &mod_tree.root, &mod_tree_ops);
|
ltn = latch_tree_find((void *)addr, &tree->root, &mod_tree_ops);
|
||||||
if (!ltn)
|
if (!ltn)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user