From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645AbdHBNvV (ORCPT ); Wed, 2 Aug 2017 09:51:21 -0400 Received: from resqmta-ch2-02v.sys.comcast.net ([69.252.207.34]:60834 "EHLO resqmta-ch2-02v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbdHBNvT (ORCPT ); Wed, 2 Aug 2017 09:51:19 -0400 Date: Wed, 2 Aug 2017 08:50:44 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: "Huang, Ying" cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Tejun Heo Subject: Re: [PATCH 1/3] percpu: Add alloc_percpu_aligned() In-Reply-To: <20170802085220.4315-2-ying.huang@intel.com> Message-ID: References: <20170802085220.4315-1-ying.huang@intel.com> <20170802085220.4315-2-ying.huang@intel.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfKqWpJ/F6JeHrpyBMYK9wzODiLJQ2zzWJPsyY47CRonVvt2aR+jbZVud3+RkqMr+Drt5GdeC/jrAY+nP/jEpid8brEcNjs9ePFPbR2o+4FFjDYVWFkw4 KzDflXWTqaTA5lyb8wpiEJrRMzEadVE4yY3ocZ0C+ff0EAH4R+Ir1H3ar4rpApMf9VUcm4EdhKOjzU4SRjJ2tPS8uM7VH29vNeXOvVNbZcdJh6nXYvS1fYZ1 +dhTLapzoVN4JUiT6jZXtQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.