locking/lockdep: Handle statically initialized PER_CPU locks properly
[linux-2.6-block.git] / kernel / module.c
index 7eba6dea4f417dbf363731cf2a3cc374ce1d703b..5ef6181338494e25113afd4806c124db9896c6d0 100644 (file)
@@ -665,16 +665,7 @@ static void percpu_modcopy(struct module *mod,
                memcpy(per_cpu_ptr(mod->percpu, cpu), from, size);
 }
 
-/**
- * is_module_percpu_address - test whether address is from module static percpu
- * @addr: address to test
- *
- * Test whether @addr belongs to module static percpu area.
- *
- * RETURNS:
- * %true if @addr is from module static percpu area
- */
-bool is_module_percpu_address(unsigned long addr)
+bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
 {
        struct module *mod;
        unsigned int cpu;
@@ -688,9 +679,11 @@ bool is_module_percpu_address(unsigned long addr)
                        continue;
                for_each_possible_cpu(cpu) {
                        void *start = per_cpu_ptr(mod->percpu, cpu);
+                       void *va = (void *)addr;
 
-                       if ((void *)addr >= start &&
-                           (void *)addr < start + mod->percpu_size) {
+                       if (va >= start && va < start + mod->percpu_size) {
+                               if (can_addr)
+                                       *can_addr = (unsigned long) (va - start);
                                preempt_enable();
                                return true;
                        }
@@ -701,6 +694,20 @@ bool is_module_percpu_address(unsigned long addr)
        return false;
 }
 
+/**
+ * is_module_percpu_address - test whether address is from module static percpu
+ * @addr: address to test
+ *
+ * Test whether @addr belongs to module static percpu area.
+ *
+ * RETURNS:
+ * %true if @addr is from module static percpu area
+ */
+bool is_module_percpu_address(unsigned long addr)
+{
+       return __is_module_percpu_address(addr, NULL);
+}
+
 #else /* ... !CONFIG_SMP */
 
 static inline void __percpu *mod_percpu(struct module *mod)
@@ -732,6 +739,11 @@ bool is_module_percpu_address(unsigned long addr)
        return false;
 }
 
+bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
+{
+       return false;
+}
+
 #endif /* CONFIG_SMP */
 
 #define MODINFO_ATTR(field)    \