From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 03/12] netfilter: x_tables: align per cpu xt_counter
Date: Fri, 19 Jun 2015 19:17:40 +0200 [thread overview]
Message-ID: <1434734269-4545-4-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1434734269-4545-1-git-send-email-pablo@netfilter.org>
From: Eric Dumazet <edumazet@google.com>
Let's force a 16 bytes alignment on xt_counter percpu allocations,
so that bytes and packets sit in same cache line.
xt_counter being exported to user space, we cannot add __align(16) on
the structure itself.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Florian Westphal <fw@strlen.de>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/linux/netfilter/x_tables.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 95693c4..1c97a22 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -356,7 +356,8 @@ static inline unsigned long ifname_compare_aligned(const char *_a,
* so nothing needs to be done there.
*
* xt_percpu_counter_alloc returns the address of the percpu
- * counter, or 0 on !SMP.
+ * counter, or 0 on !SMP. We force an alignment of 16 bytes
+ * so that bytes/packets share a common cache line.
*
* Hence caller must use IS_ERR_VALUE to check for error, this
* allows us to return 0 for single core systems without forcing
@@ -365,7 +366,8 @@ static inline unsigned long ifname_compare_aligned(const char *_a,
static inline u64 xt_percpu_counter_alloc(void)
{
if (nr_cpu_ids > 1) {
- void __percpu *res = alloc_percpu(struct xt_counters);
+ void __percpu *res = __alloc_percpu(sizeof(struct xt_counters),
+ sizeof(struct xt_counters));
if (res == NULL)
return (u64) -ENOMEM;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
next prev parent reply other threads:[~2015-06-19 17:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 17:17 [PATCH 00/12] Netfilter updates for net-next Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 01/12] netfilter: nfnetlink_queue: add security context information Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 02/12] netfilter: xt_socket: add XT_SOCKET_RESTORESKMARK flag Pablo Neira Ayuso
2015-06-19 17:17 ` Pablo Neira Ayuso [this message]
2015-06-22 11:49 ` [PATCH 03/12] netfilter: x_tables: align per cpu xt_counter David Laight
2015-06-22 13:27 ` Eric Dumazet
2015-06-19 17:17 ` [PATCH 04/12] netfilter: bridge: rename br_netfilter.c to br_netfilter_hooks.c Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 05/12] netfilter: bridge: split ipv6 code into separated file Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 06/12] netfilter: Kill unused copies of RCV_SKB_FAIL Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 07/12] net: sched: Simplify em_ipset_match Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 08/12] net: include missing headers in net/net_namespace.h Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 09/12] netfilter: use forward declaration instead of including linux/proc_fs.h Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 10/12] netfilter: don't pull include/linux/netfilter.h from netns headers Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 11/12] netfilter: Remove spurios included of netfilter.h Pablo Neira Ayuso
2015-06-19 17:17 ` [PATCH 12/12] netfilter: xtables: fix warnings on 32bit platforms Pablo Neira Ayuso
2015-06-20 22:40 ` [PATCH 00/12] Netfilter updates for net-next David Miller
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=1434734269-4545-4-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.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).