reiserfs: fix oops while creating privroot with selinux enabled
[safe/jmp/linux-2.6] / include / linux / module.h
index 505f20d..5e869ff 100644 (file)
 #include <linux/stringify.h>
 #include <linux/kobject.h>
 #include <linux/moduleparam.h>
-#include <linux/marker.h>
 #include <linux/tracepoint.h>
-#include <asm/local.h>
 
+#include <linux/percpu.h>
 #include <asm/module.h>
 
+#include <trace/events/module.h>
+
 /* Not Yet Implemented */
 #define MODULE_SUPPORTED_DEVICE(name)
 
-/* some toolchains uses a `_' prefix for all user symbols */
-#ifndef MODULE_SYMBOL_PREFIX
+/* Some toolchains use a `_' prefix for all user symbols. */
+#ifdef CONFIG_SYMBOL_PREFIX
+#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
+#else
 #define MODULE_SYMBOL_PREFIX ""
 #endif
 
@@ -127,7 +130,10 @@ extern struct module __this_module;
  */
 #define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
 
-/* Author, ideally of form NAME[, NAME]*[ and NAME] */
+/*
+ * Author(s), use "Name <email>" or just "Name", for multiple
+ * authors use multiple MODULE_AUTHOR() statements/lines.
+ */
 #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
   
 /* What your module does. */
@@ -169,6 +175,7 @@ struct notifier_block;
 
 #ifdef CONFIG_MODULES
 
+extern int modules_disabled; /* for sysctl */
 /* Get/put a kernel symbol (calls must be symmetric) */
 void *__symbol_get(const char *symbol);
 void *__symbol_get_gpl(const char *symbol);
@@ -307,10 +314,14 @@ struct module
 #endif
 
 #ifdef CONFIG_KALLSYMS
-       /* We keep the symbol and string tables for kallsyms. */
-       Elf_Sym *symtab;
-       unsigned int num_symtab;
-       char *strtab;
+       /*
+        * We keep the symbol and string tables for kallsyms.
+        * The core_* fields below are temporary, loader-only (they
+        * could really be discarded after module init).
+        */
+       Elf_Sym *symtab, *core_symtab;
+       unsigned int num_symtab, core_num_syms;
+       char *strtab, *core_strtab;
 
        /* Section attributes */
        struct module_sect_attrs *sect_attrs;
@@ -325,10 +336,6 @@ struct module
        /* The command line arguments (may be mangled).  People like
           keeping pointers to this stuff */
        char *args;
-#ifdef CONFIG_MARKERS
-       struct marker *markers;
-       unsigned int num_markers;
-#endif
 #ifdef CONFIG_TRACEPOINTS
        struct tracepoint *tracepoints;
        unsigned int num_tracepoints;
@@ -357,11 +364,15 @@ struct module
        /* Destruction function. */
        void (*exit)(void);
 
-#ifdef CONFIG_SMP
-       char *refptr;
-#else
-       local_t ref;
+       struct module_ref {
+               int count;
+       } __percpu *refptr;
 #endif
+
+#ifdef CONFIG_CONSTRUCTORS
+       /* Constructor functions. */
+       ctor_fn_t *ctors;
+       unsigned int num_ctors;
 #endif
 };
 #ifndef MODULE_ARCH_INIT
@@ -442,22 +453,16 @@ void __symbol_put(const char *symbol);
 #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
 void symbol_put_addr(void *addr);
 
-static inline local_t *__module_ref_addr(struct module *mod, int cpu)
-{
-#ifdef CONFIG_SMP
-       return (local_t *) (mod->refptr + per_cpu_offset(cpu));
-#else
-       return &mod->ref;
-#endif
-}
-
 /* Sometimes we know we already have a refcount, and it's easier not
    to handle the error case (which only happens with rmmod --wait). */
 static inline void __module_get(struct module *module)
 {
        if (module) {
-               local_inc(__module_ref_addr(module, get_cpu()));
-               put_cpu();
+               preempt_disable();
+               __this_cpu_inc(module->refptr->count);
+               trace_module_get(module, _THIS_IP_,
+                                __this_cpu_read(module->refptr->count));
+               preempt_enable();
        }
 }
 
@@ -466,12 +471,17 @@ static inline int try_module_get(struct module *module)
        int ret = 1;
 
        if (module) {
-               unsigned int cpu = get_cpu();
-               if (likely(module_is_live(module)))
-                       local_inc(__module_ref_addr(module, cpu));
+               preempt_disable();
+
+               if (likely(module_is_live(module))) {
+                       __this_cpu_inc(module->refptr->count);
+                       trace_module_get(module, _THIS_IP_,
+                               __this_cpu_read(module->refptr->count));
+               }
                else
                        ret = 0;
-               put_cpu();
+
+               preempt_enable();
        }
        return ret;
 }
@@ -521,8 +531,6 @@ int unregister_module_notifier(struct notifier_block * nb);
 
 extern void print_modules(void);
 
-extern void module_update_markers(void);
-
 extern void module_update_tracepoints(void);
 extern int module_get_iter_tracepoints(struct tracepoint_iter *iter);
 
@@ -637,10 +645,6 @@ static inline void print_modules(void)
 {
 }
 
-static inline void module_update_markers(void)
-{
-}
-
 static inline void module_update_tracepoints(void)
 {
 }