This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[patch 2/5] Add apply_modules() which applies a function to each module.
- From: Greg Banks <gnb at sgi dot com>
- To: Linux Kernel ML <linux-kernel at vger dot kernel dot org>
- Cc: Linux NFS ML <linux-nfs at vger dot kernel dot org>, Linux NFSv4 ML <nfsv4 at linux-nfs dot org>, SystemTAP ML <systemtap at sources dot redhat dot com>
- Date: Tue, 20 Jan 2009 12:29:32 +1100
- Subject: [patch 2/5] Add apply_modules() which applies a function to each module.
- References: <20090120012930.020621000@sgi.com>
The new dprintk module needs to apply a particular function
to each module when the dprintk module loads.
Signed-off-by: Greg Banks <gnb@sgi.com>
---
include/linux/module.h | 1 +
kernel/module.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
Index: bfields/kernel/module.c
===================================================================
--- bfields.orig/kernel/module.c
+++ bfields/kernel/module.c
@@ -365,6 +365,19 @@ static struct module *find_module(const
return NULL;
}
+void apply_modules(void (*func)(struct module*, void *), void *closure)
+{
+ struct module *mod;
+
+ preempt_disable();
+ list_for_each_entry_rcu(mod, &modules, list) {
+ func(mod, closure);
+ }
+ preempt_enable();
+}
+EXPORT_SYMBOL(apply_modules);
+
+
#ifdef CONFIG_SMP
/* Number of blocks used and allocated. */
static unsigned int pcpu_num_used, pcpu_num_allocated;
Index: bfields/include/linux/module.h
===================================================================
--- bfields.orig/include/linux/module.h
+++ bfields/include/linux/module.h
@@ -475,6 +475,7 @@ extern void module_update_markers(void);
extern void module_update_tracepoints(void);
extern int module_get_iter_tracepoints(struct tracepoint_iter *iter);
+extern void apply_modules(void (*func)(struct module*, void *), void *closure);
#else /* !CONFIG_MODULES... */
#define EXPORT_SYMBOL(sym)
--
--
Greg Banks, P.Engineer, SGI Australian Software Group.
the brightly coloured sporks of revolution.
I don't speak for SGI.