From: Huang Ying <ying.hu...@intel.com> To allocate percpu memory that is aligned with cache line size dynamically. We can statically allocate percpu memory that is aligned with cache line size with DEFINE_PER_CPU_ALIGNED(), but we have no correspondent API for dynamic allocation.
Signed-off-by: "Huang, Ying" <ying.hu...@intel.com> Cc: Tejun Heo <t...@kernel.org> Cc: Christoph Lameter <c...@linux.com> --- include/linux/percpu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 491b3f5a5f8a..8b80a965d64a 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -129,5 +129,8 @@ extern phys_addr_t per_cpu_ptr_to_phys(void *addr); #define alloc_percpu(type) \ (typeof(type) __percpu *)__alloc_percpu(sizeof(type), \ __alignof__(type)) +#define alloc_percpu_aligned(type) \ + ((typeof(type) __percpu *)__alloc_percpu(sizeof(type), \ + max_t(unsigned int, cache_line_size(), __alignof__(type)))) #endif /* __LINUX_PERCPU_H */ -- 2.13.2