]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - mm/percpu.c
Merge tag 'powerpc-4.12-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[karo-tx-linux.git] / mm / percpu.c
index 60a6488e9e6d49d5e9c5d4b611a5f5b037342316..e0aa8ae7bde708188e2d6ba84dbdc12dcf11f52e 100644 (file)
@@ -1284,18 +1284,7 @@ void free_percpu(void __percpu *ptr)
 }
 EXPORT_SYMBOL_GPL(free_percpu);
 
-/**
- * is_kernel_percpu_address - test whether address is from static percpu area
- * @addr: address to test
- *
- * Test whether @addr belongs to in-kernel static percpu area.  Module
- * static percpu areas are not considered.  For those, use
- * is_module_percpu_address().
- *
- * RETURNS:
- * %true if @addr is from in-kernel static percpu area, %false otherwise.
- */
-bool is_kernel_percpu_address(unsigned long addr)
+bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr)
 {
 #ifdef CONFIG_SMP
        const size_t static_size = __per_cpu_end - __per_cpu_start;
@@ -1304,15 +1293,38 @@ bool is_kernel_percpu_address(unsigned long addr)
 
        for_each_possible_cpu(cpu) {
                void *start = per_cpu_ptr(base, cpu);
+               void *va = (void *)addr;
 
-               if ((void *)addr >= start && (void *)addr < start + static_size)
+               if (va >= start && va < start + static_size) {
+                       if (can_addr) {
+                               *can_addr = (unsigned long) (va - start);
+                               *can_addr += (unsigned long)
+                                       per_cpu_ptr(base, get_boot_cpu_id());
+                       }
                        return true;
-        }
+               }
+       }
 #endif
        /* on UP, can't distinguish from other static vars, always false */
        return false;
 }
 
+/**
+ * is_kernel_percpu_address - test whether address is from static percpu area
+ * @addr: address to test
+ *
+ * Test whether @addr belongs to in-kernel static percpu area.  Module
+ * static percpu areas are not considered.  For those, use
+ * is_module_percpu_address().
+ *
+ * RETURNS:
+ * %true if @addr is from in-kernel static percpu area, %false otherwise.
+ */
+bool is_kernel_percpu_address(unsigned long addr)
+{
+       return __is_kernel_percpu_address(addr, NULL);
+}
+
 /**
  * per_cpu_ptr_to_phys - convert translated percpu address to physical address
  * @addr: the address to be converted to physical address