diff options
Diffstat (limited to 'mm/percpu.c')
-rw-r--r-- | mm/percpu.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/mm/percpu.c b/mm/percpu.c index 60a6488e9e6d..e0aa8ae7bde7 100644 --- a/mm/percpu.c +++ b/mm/percpu.c | |||
@@ -1284,18 +1284,7 @@ void free_percpu(void __percpu *ptr) | |||
1284 | } | 1284 | } |
1285 | EXPORT_SYMBOL_GPL(free_percpu); | 1285 | EXPORT_SYMBOL_GPL(free_percpu); |
1286 | 1286 | ||
1287 | /** | 1287 | bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr) |
1288 | * is_kernel_percpu_address - test whether address is from static percpu area | ||
1289 | * @addr: address to test | ||
1290 | * | ||
1291 | * Test whether @addr belongs to in-kernel static percpu area. Module | ||
1292 | * static percpu areas are not considered. For those, use | ||
1293 | * is_module_percpu_address(). | ||
1294 | * | ||
1295 | * RETURNS: | ||
1296 | * %true if @addr is from in-kernel static percpu area, %false otherwise. | ||
1297 | */ | ||
1298 | bool is_kernel_percpu_address(unsigned long addr) | ||
1299 | { | 1288 | { |
1300 | #ifdef CONFIG_SMP | 1289 | #ifdef CONFIG_SMP |
1301 | const size_t static_size = __per_cpu_end - __per_cpu_start; | 1290 | const size_t static_size = __per_cpu_end - __per_cpu_start; |
@@ -1304,16 +1293,39 @@ bool is_kernel_percpu_address(unsigned long addr) | |||
1304 | 1293 | ||
1305 | for_each_possible_cpu(cpu) { | 1294 | for_each_possible_cpu(cpu) { |
1306 | void *start = per_cpu_ptr(base, cpu); | 1295 | void *start = per_cpu_ptr(base, cpu); |
1296 | void *va = (void *)addr; | ||
1307 | 1297 | ||
1308 | if ((void *)addr >= start && (void *)addr < start + static_size) | 1298 | if (va >= start && va < start + static_size) { |
1299 | if (can_addr) { | ||
1300 | *can_addr = (unsigned long) (va - start); | ||
1301 | *can_addr += (unsigned long) | ||
1302 | per_cpu_ptr(base, get_boot_cpu_id()); | ||
1303 | } | ||
1309 | return true; | 1304 | return true; |
1310 | } | 1305 | } |
1306 | } | ||
1311 | #endif | 1307 | #endif |
1312 | /* on UP, can't distinguish from other static vars, always false */ | 1308 | /* on UP, can't distinguish from other static vars, always false */ |
1313 | return false; | 1309 | return false; |
1314 | } | 1310 | } |
1315 | 1311 | ||
1316 | /** | 1312 | /** |
1313 | * is_kernel_percpu_address - test whether address is from static percpu area | ||
1314 | * @addr: address to test | ||
1315 | * | ||
1316 | * Test whether @addr belongs to in-kernel static percpu area. Module | ||
1317 | * static percpu areas are not considered. For those, use | ||
1318 | * is_module_percpu_address(). | ||
1319 | * | ||
1320 | * RETURNS: | ||
1321 | * %true if @addr is from in-kernel static percpu area, %false otherwise. | ||
1322 | */ | ||
1323 | bool is_kernel_percpu_address(unsigned long addr) | ||
1324 | { | ||
1325 | return __is_kernel_percpu_address(addr, NULL); | ||
1326 | } | ||
1327 | |||
1328 | /** | ||
1317 | * per_cpu_ptr_to_phys - convert translated percpu address to physical address | 1329 | * per_cpu_ptr_to_phys - convert translated percpu address to physical address |
1318 | * @addr: the address to be converted to physical address | 1330 | * @addr: the address to be converted to physical address |
1319 | * | 1331 | * |