mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
percpu, module: implement and use is_kernel/module_percpu_address()
lockdep has custom code to check whether a pointer belongs to static percpu area which is somewhat broken. Implement proper is_kernel/module_percpu_address() and replace the custom code. On UP, percpu variables are regular static variables and can't be distinguished from them. Always return %false on UP. Signed-off-by: Tejun Heo <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: Rusty Russell <[email protected]> Cc: Ingo Molnar <[email protected]>
This commit is contained in:
parent
259354deaa
commit
10fad5e46f
5 changed files with 77 additions and 16 deletions
26
mm/percpu.c
26
mm/percpu.c
|
|
@ -1303,6 +1303,32 @@ 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)
|
||||
{
|
||||
const size_t static_size = __per_cpu_end - __per_cpu_start;
|
||||
void __percpu *base = __addr_to_pcpu_ptr(pcpu_base_addr);
|
||||
unsigned int cpu;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
void *start = per_cpu_ptr(base, cpu);
|
||||
|
||||
if ((void *)addr >= start && (void *)addr < start + static_size)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* per_cpu_ptr_to_phys - convert translated percpu address to physical address
|
||||
* @addr: the address to be converted to physical address
|
||||
|
|
|
|||
Loading…
Reference in a new issue