* [RFC PATCH 5/8] module: add function to map address to containing module
@ 2008-04-21 12:34 Peter Oberparleiter
2008-04-21 15:40 ` Rusty Russell
0 siblings, 1 reply; 3+ messages in thread
From: Peter Oberparleiter @ 2008-04-21 12:34 UTC (permalink / raw)
To: linux-kernel, ltp-list, ltp-coverage, Andrew Morton, rusty
From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
module_address() maps an address to the module containing it in either
text or data section. Required by the gcov profiling infrastructure to
associate profiling data structures with modules.
Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
---
include/linux/module.h | 1 +
kernel/module.c | 23 ++++++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
Index: linux-2.6.25/include/linux/module.h
===================================================================
--- linux-2.6.25.orig/include/linux/module.h
+++ linux-2.6.25/include/linux/module.h
@@ -380,6 +380,7 @@ static inline int module_is_live(struct
/* Is this address in a module? (second is with no locks, for oops) */
struct module *module_text_address(unsigned long addr);
struct module *__module_text_address(unsigned long addr);
+struct module *module_address(unsigned long addr);
int is_module_address(unsigned long addr);
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
Index: linux-2.6.25/kernel/module.c
===================================================================
--- linux-2.6.25.orig/kernel/module.c
+++ linux-2.6.25/kernel/module.c
@@ -2527,10 +2527,16 @@ const struct exception_table_entry *sear
return e;
}
-/*
- * Is this a valid module address?
+/**
+ * module_address - map an address to the containing module
+ * @addr: address for which the containing module should be searched
+ *
+ * Return the module which contains the address in either text or data
+ * section. Return NULL if no matching module was found. Callers should
+ * be aware that no reference counting is being performed for the returned
+ * module reference.
*/
-int is_module_address(unsigned long addr)
+struct module *module_address(unsigned long addr)
{
struct module *mod;
@@ -2539,15 +2545,22 @@ int is_module_address(unsigned long addr
list_for_each_entry(mod, &modules, list) {
if (within(addr, mod->module_core, mod->core_size)) {
preempt_enable();
- return 1;
+ return mod;
}
}
preempt_enable();
- return 0;
+ return NULL;
}
+/*
+ * Is this a valid module address?
+ */
+int is_module_address(unsigned long addr)
+{
+ return module_address(addr) ? 1 : 0;
+}
/* Is this a valid kernel address? */
struct module *__module_text_address(unsigned long addr)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC PATCH 5/8] module: add function to map address to containing module
2008-04-21 12:34 [RFC PATCH 5/8] module: add function to map address to containing module Peter Oberparleiter
@ 2008-04-21 15:40 ` Rusty Russell
2008-04-22 12:40 ` [Ltp-coverage] " Peter Oberparleiter
0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2008-04-21 15:40 UTC (permalink / raw)
To: Peter Oberparleiter; +Cc: linux-kernel, ltp-list, ltp-coverage, Andrew Morton
On Monday 21 April 2008 22:34:39 Peter Oberparleiter wrote:
> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>
> module_address() maps an address to the module containing it in either
> text or data section. Required by the gcov profiling infrastructure to
> associate profiling data structures with modules.
Locking problem; this isn't safe. Note that we block preemption to traverse
the module list. You could grab a reference, and fix up all the callers to
put it once they're done?
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Ltp-coverage] [RFC PATCH 5/8] module: add function to map address to containing module
2008-04-21 15:40 ` Rusty Russell
@ 2008-04-22 12:40 ` Peter Oberparleiter
0 siblings, 0 replies; 3+ messages in thread
From: Peter Oberparleiter @ 2008-04-22 12:40 UTC (permalink / raw)
To: Rusty Russell; +Cc: ltp-list, Andrew Morton, ltp-coverage, linux-kernel
Rusty Russell wrote:
> On Monday 21 April 2008 22:34:39 Peter Oberparleiter wrote:
>> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>>
>> module_address() maps an address to the module containing it in either
>> text or data section. Required by the gcov profiling infrastructure to
>> associate profiling data structures with modules.
>
> Locking problem; this isn't safe. Note that we block preemption to traverse
> the module list. You could grab a reference, and fix up all the callers to
> put it once they're done?
Hm, problem: in this patchset, module_address() is called when the module is going (mod->state = MODULE_STATE_GOING) and try_module_get() would most likely fail and/or make no sense since we're already past reference counting with this module anyway.
On the other hand, what I actually need is a way to find out if a given module contains a certain address so I could replace this function with something like module_contains(mod, addr).
I'll go that route if there are no objections.
Regards,
Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-22 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-21 12:34 [RFC PATCH 5/8] module: add function to map address to containing module Peter Oberparleiter
2008-04-21 15:40 ` Rusty Russell
2008-04-22 12:40 ` [Ltp-coverage] " Peter Oberparleiter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox