On Mon, Jan 30, 2012 at 10:02:24AM -0800, Tejun Heo wrote:
I thought it didn't. I rememer thinking about this and determining that NULL can't be allocated for dynamic addresses. Maybe I'm imagining things. Anyways, if it can return NULL for valid allocation, it is a bug and should be fixed.
So, the default translation is
#define __addr_to_pcpu_ptr(addr) \ (void __percpu *)((unsigned long)(addr) - \ (unsigned long)pcpu_base_addr + \ (unsigned long)__per_cpu_start)
It basically offsets the virtual address of the first unit against the start of static percpu section, so if the linked percpu data address is higher than the base address of the initial chunk, I *think* overwrap is possible. I don't think this can happen on x86 regardless of first chunk allocation mode tho but there may be configurations where __per_cpu_start is higher than pcpu_base_addr (IIRC some archs locate vmalloc area lower than kernel image, dunno whether the used address range actually is enough for causing overflow tho).
Anyways, yeah, it seems we should improve this part too.
Thanks.