Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751968AbdHCAdZ (ORCPT ); Wed, 2 Aug 2017 20:33:25 -0400 Received: from mga01.intel.com ([192.55.52.88]:7855 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751190AbdHCAdY (ORCPT ); Wed, 2 Aug 2017 20:33:24 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,313,1498546800"; d="scan'208";a="134729495" From: "Huang\, Ying" To: Christopher Lameter Cc: "Huang\, Ying" , Peter Zijlstra , , Tejun Heo Subject: Re: [PATCH 1/3] percpu: Add alloc_percpu_aligned() References: <20170802085220.4315-1-ying.huang@intel.com> <20170802085220.4315-2-ying.huang@intel.com> Date: Thu, 03 Aug 2017 08:33:22 +0800 In-Reply-To: (Christopher Lameter's message of "Wed, 2 Aug 2017 08:50:44 -0500") Message-ID: <87tw1p5w31.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 856 Lines: 26 Christopher Lameter 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