From: "Huang, Ying" <ying.huang@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Huang Ying <ying.huang@intel.com>,
Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>
Subject: [PATCH 1/3] percpu: Add alloc_percpu_aligned()
Date: Wed, 2 Aug 2017 16:52:18 +0800 [thread overview]
Message-ID: <20170802085220.4315-2-ying.huang@intel.com> (raw)
In-Reply-To: <20170802085220.4315-1-ying.huang@intel.com>
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
next prev parent reply other threads:[~2017-08-02 8:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 8:52 [PATCH 0/3] IPI: Avoid to use 2 cache lines for one call_single_data Huang, Ying
2017-08-02 8:52 ` Huang, Ying [this message]
2017-08-02 13:50 ` [PATCH 1/3] percpu: Add alloc_percpu_aligned() Christopher Lameter
2017-08-03 0:33 ` Huang, Ying
2017-08-02 8:52 ` [PATCH 2/3] iova: Use alloc_percpu_aligned() Huang, Ying
2017-08-02 8:52 ` [PATCH 3/3] IPI: Avoid to use 2 cache lines for one call_single_data Huang, Ying
2017-08-02 10:18 ` Eric Dumazet
2017-08-02 10:53 ` Peter Zijlstra
2017-08-03 8:35 ` Huang, Ying
2017-08-03 8:57 ` Peter Zijlstra
2017-08-04 1:28 ` Huang, Ying
2017-08-04 2:05 ` Huang, Ying
2017-08-04 9:27 ` Peter Zijlstra
2017-08-05 0:47 ` Huang, Ying
2017-08-07 8:28 ` Peter Zijlstra
2017-08-08 4:30 ` Huang, Ying
2017-08-14 5:44 ` Huang, Ying
2017-08-28 5:19 ` Huang, Ying
2017-08-28 8:49 ` Peter Zijlstra
2017-08-29 14:23 ` [tip:locking/core] smp: Avoid using two cache lines for struct call_single_data tip-bot for Ying Huang
2017-08-04 9:20 ` [PATCH 3/3] IPI: Avoid to use 2 cache lines for one call_single_data Peter Zijlstra
2017-08-02 13:54 ` [PATCH 0/3] " Christopher Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170802085220.4315-2-ying.huang@intel.com \
--to=ying.huang@intel.com \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).