Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdHBIwe (ORCPT ); Wed, 2 Aug 2017 04:52:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:4729 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752558AbdHBIwc (ORCPT ); Wed, 2 Aug 2017 04:52:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,310,1498546800"; d="scan'208";a="294597205" From: "Huang, Ying" To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Huang Ying , Tejun Heo , Christoph Lameter Subject: [PATCH 1/3] percpu: Add alloc_percpu_aligned() Date: Wed, 2 Aug 2017 16:52:18 +0800 Message-Id: <20170802085220.4315-2-ying.huang@intel.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170802085220.4315-1-ying.huang@intel.com> References: <20170802085220.4315-1-ying.huang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1034 Lines: 29 From: Huang Ying 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" Cc: Tejun Heo Cc: Christoph Lameter --- 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