diff options
Diffstat (limited to 'mm/percpu.c')
| -rw-r--r-- | mm/percpu.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mm/percpu.c b/mm/percpu.c index 768419d44ad7..6e09741ddc62 100644 --- a/mm/percpu.c +++ b/mm/percpu.c | |||
| @@ -1304,6 +1304,32 @@ void free_percpu(void __percpu *ptr) | |||
| 1304 | EXPORT_SYMBOL_GPL(free_percpu); | 1304 | EXPORT_SYMBOL_GPL(free_percpu); |
| 1305 | 1305 | ||
| 1306 | /** | 1306 | /** |
| 1307 | * is_kernel_percpu_address - test whether address is from static percpu area | ||
| 1308 | * @addr: address to test | ||
| 1309 | * | ||
| 1310 | * Test whether @addr belongs to in-kernel static percpu area. Module | ||
| 1311 | * static percpu areas are not considered. For those, use | ||
| 1312 | * is_module_percpu_address(). | ||
| 1313 | * | ||
| 1314 | * RETURNS: | ||
| 1315 | * %true if @addr is from in-kernel static percpu area, %false otherwise. | ||
| 1316 | */ | ||
| 1317 | bool is_kernel_percpu_address(unsigned long addr) | ||
| 1318 | { | ||
| 1319 | const size_t static_size = __per_cpu_end - __per_cpu_start; | ||
| 1320 | void __percpu *base = __addr_to_pcpu_ptr(pcpu_base_addr); | ||
| 1321 | unsigned int cpu; | ||
| 1322 | |||
| 1323 | for_each_possible_cpu(cpu) { | ||
| 1324 | void *start = per_cpu_ptr(base, cpu); | ||
| 1325 | |||
| 1326 | if ((void *)addr >= start && (void *)addr < start + static_size) | ||
| 1327 | return true; | ||
| 1328 | } | ||
| 1329 | return false; | ||
| 1330 | } | ||
| 1331 | |||
| 1332 | /** | ||
| 1307 | * per_cpu_ptr_to_phys - convert translated percpu address to physical address | 1333 | * per_cpu_ptr_to_phys - convert translated percpu address to physical address |
| 1308 | * @addr: the address to be converted to physical address | 1334 | * @addr: the address to be converted to physical address |
| 1309 | * | 1335 | * |
