Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1701926

[PATCH 1/3] percpu: Add alloc_percpu_aligned()

From "Huang, Ying" <ying.huang@intel.com>
Newsgroups linux.kernel
Subject [PATCH 1/3] percpu: Add alloc_percpu_aligned()
Date 2017-08-02 11:00 +0200
Message-ID <u9XFw-7As-25@gated-at.bofh.it> (permalink)
References <u9XFv-7As-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Huang Ying <ying.huang@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.huang@intel.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] percpu: Add alloc_percpu_aligned() "Huang, Ying" <ying.huang@intel.com> - 2017-08-02 11:00 +0200
  Re: [PATCH 1/3] percpu: Add alloc_percpu_aligned() Christopher Lameter <cl@linux.com> - 2017-08-02 16:00 +0200
    Re: [PATCH 1/3] percpu: Add alloc_percpu_aligned() "Huang\, Ying" <ying.huang@intel.com> - 2017-08-03 02:40 +0200

csiph-web