Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1701926 > unrolled thread
| Started by | "Huang, Ying" <ying.huang@intel.com> |
|---|---|
| First post | 2017-08-02 11:00 +0200 |
| Last post | 2017-08-03 02:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[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
| From | "Huang, Ying" <ying.huang@intel.com> |
|---|---|
| Date | 2017-08-02 11:00 +0200 |
| Subject | [PATCH 1/3] percpu: Add alloc_percpu_aligned() |
| Message-ID | <u9XFw-7As-25@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Christopher Lameter <cl@linux.com> |
|---|---|
| Date | 2017-08-02 16:00 +0200 |
| Message-ID | <ua2lQ-281-13@gated-at.bofh.it> |
| In reply to | #1701926 |
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.
[toc] | [prev] | [next] | [standalone]
| From | "Huang\, Ying" <ying.huang@intel.com> |
|---|---|
| Date | 2017-08-03 02:40 +0200 |
| Message-ID | <uaclb-xG-1@gated-at.bofh.it> |
| In reply to | #1702126 |
Christopher Lameter <cl@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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web