Skip to content

Commit 446d556

Browse files
chleroymcgrof
authored andcommitted
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 80b8bf4 commit 446d556

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

kernel/module/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ extern struct mod_tree_root mod_tree;
157157
void mod_tree_insert(struct module *mod);
158158
void mod_tree_remove_init(struct module *mod);
159159
void mod_tree_remove(struct module *mod);
160-
struct module *mod_find(unsigned long addr);
160+
struct module *mod_find(unsigned long addr, struct mod_tree_root *tree);
161161
#else /* !CONFIG_MODULES_TREE_LOOKUP */
162162

163163
static inline void mod_tree_insert(struct module *mod) { }
164164
static inline void mod_tree_remove_init(struct module *mod) { }
165165
static inline void mod_tree_remove(struct module *mod) { }
166-
static inline struct module *mod_find(unsigned long addr)
166+
static inline struct module *mod_find(unsigned long addr, struct mod_tree_root *tree)
167167
{
168168
struct module *mod;
169169

kernel/module/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ struct symsearch {
9191
* Bounds of module text, for speeding up __module_address.
9292
* Protected by module_mutex.
9393
*/
94-
static void __mod_update_bounds(void *base, unsigned int size)
94+
static void __mod_update_bounds(void *base, unsigned int size, struct mod_tree_root *tree)
9595
{
9696
unsigned long min = (unsigned long)base;
9797
unsigned long max = min + size;
9898

99-
if (min < module_addr_min)
100-
module_addr_min = min;
101-
if (max > module_addr_max)
102-
module_addr_max = max;
99+
if (min < tree->addr_min)
100+
tree->addr_min = min;
101+
if (max > tree->addr_max)
102+
tree->addr_max = max;
103103
}
104104

105105
static void mod_update_bounds(struct module *mod)
106106
{
107-
__mod_update_bounds(mod->core_layout.base, mod->core_layout.size);
107+
__mod_update_bounds(mod->core_layout.base, mod->core_layout.size, &mod_tree);
108108
if (mod->init_layout.size)
109-
__mod_update_bounds(mod->init_layout.base, mod->init_layout.size);
109+
__mod_update_bounds(mod->init_layout.base, mod->init_layout.size, &mod_tree);
110110
}
111111

112112
static void module_assert_mutex_or_preempt(void)
@@ -3017,7 +3017,7 @@ struct module *__module_address(unsigned long addr)
30173017

30183018
module_assert_mutex_or_preempt();
30193019

3020-
mod = mod_find(addr);
3020+
mod = mod_find(addr, &mod_tree);
30213021
if (mod) {
30223022
BUG_ON(!within_module(addr, mod));
30233023
if (mod->state == MODULE_STATE_UNFORMED)

kernel/module/tree_lookup.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ static const struct latch_tree_ops mod_tree_ops = {
6161
.comp = mod_tree_comp,
6262
};
6363

64-
static noinline void __mod_tree_insert(struct mod_tree_node *node)
64+
static noinline void __mod_tree_insert(struct mod_tree_node *node, struct mod_tree_root *tree)
6565
{
66-
latch_tree_insert(&node->node, &mod_tree.root, &mod_tree_ops);
66+
latch_tree_insert(&node->node, &tree->root, &mod_tree_ops);
6767
}
6868

69-
static void __mod_tree_remove(struct mod_tree_node *node)
69+
static void __mod_tree_remove(struct mod_tree_node *node, struct mod_tree_root *tree)
7070
{
71-
latch_tree_erase(&node->node, &mod_tree.root, &mod_tree_ops);
71+
latch_tree_erase(&node->node, &tree->root, &mod_tree_ops);
7272
}
7373

7474
/*
@@ -80,28 +80,28 @@ void mod_tree_insert(struct module *mod)
8080
mod->core_layout.mtn.mod = mod;
8181
mod->init_layout.mtn.mod = mod;
8282

83-
__mod_tree_insert(&mod->core_layout.mtn);
83+
__mod_tree_insert(&mod->core_layout.mtn, &mod_tree);
8484
if (mod->init_layout.size)
85-
__mod_tree_insert(&mod->init_layout.mtn);
85+
__mod_tree_insert(&mod->init_layout.mtn, &mod_tree);
8686
}
8787

8888
void mod_tree_remove_init(struct module *mod)
8989
{
9090
if (mod->init_layout.size)
91-
__mod_tree_remove(&mod->init_layout.mtn);
91+
__mod_tree_remove(&mod->init_layout.mtn, &mod_tree);
9292
}
9393

9494
void mod_tree_remove(struct module *mod)
9595
{
96-
__mod_tree_remove(&mod->core_layout.mtn);
96+
__mod_tree_remove(&mod->core_layout.mtn, &mod_tree);
9797
mod_tree_remove_init(mod);
9898
}
9999

100-
struct module *mod_find(unsigned long addr)
100+
struct module *mod_find(unsigned long addr, struct mod_tree_root *tree)
101101
{
102102
struct latch_tree_node *ltn;
103103

104-
ltn = latch_tree_find((void *)addr, &mod_tree.root, &mod_tree_ops);
104+
ltn = latch_tree_find((void *)addr, &tree->root, &mod_tree_ops);
105105
if (!ltn)
106106
return NULL;
107107

0 commit comments

Comments
 (0)