Christopher Lameter <c...@linux.com> writes:

> On Wed, 2 Aug 2017, Huang, Ying wrote:
>
>> --- 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 */
>
> This is not needeed since alloc_percpu() already uses __alignof__(type).
>
> If you add an attribute to the definition of "type" that requires
> cacheline alignmet (f.e. __cacheline_aligned) then alloc_percpu() will
> align the allocation as you desire.

OK.

Best Regards,
Huang, Ying

Reply via email to