* [PATCH net-next] x_table: align per cpu xt_counter
@ 2015-06-16 1:10 Eric Dumazet
2015-06-17 17:08 ` Florian Westphal
2015-06-18 10:43 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Eric Dumazet @ 2015-06-16 1:10 UTC (permalink / raw)
To: Pablo Neira Ayuso, David Miller; +Cc: netfilter-devel, netdev, Florian Westphal
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>
---
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 95693c4cebdda473a2f3e427dcc2511e83bf7405..1c97a2204379e14676ee33f0b15c5174b7afe680 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;
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next] x_table: align per cpu xt_counter
2015-06-16 1:10 [PATCH net-next] x_table: align per cpu xt_counter Eric Dumazet
@ 2015-06-17 17:08 ` Florian Westphal
2015-06-18 19:04 ` Pablo Neira Ayuso
2015-06-18 10:43 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Florian Westphal @ 2015-06-17 17:08 UTC (permalink / raw)
To: Eric Dumazet
Cc: Pablo Neira Ayuso, David Miller, netfilter-devel, netdev,
Florian Westphal
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 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.
Sorry, I was away. Looks great.
Acked-by: Florian Westphal <fw@strlen.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] x_table: align per cpu xt_counter
2015-06-17 17:08 ` Florian Westphal
@ 2015-06-18 19:04 ` Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-18 19:04 UTC (permalink / raw)
To: Florian Westphal; +Cc: Eric Dumazet, David Miller, netfilter-devel, netdev
On Wed, Jun 17, 2015 at 07:08:15PM +0200, Florian Westphal wrote:
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > 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.
>
> Sorry, I was away. Looks great.
>
> Acked-by: Florian Westphal <fw@strlen.de>
Applied, thanks Eric and Florian !
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] x_table: align per cpu xt_counter
2015-06-16 1:10 [PATCH net-next] x_table: align per cpu xt_counter Eric Dumazet
2015-06-17 17:08 ` Florian Westphal
@ 2015-06-18 10:43 ` David Miller
2015-06-18 10:50 ` Pablo Neira Ayuso
1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2015-06-18 10:43 UTC (permalink / raw)
To: eric.dumazet; +Cc: pablo, netfilter-devel, netdev, fw
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 15 Jun 2015 18:10:13 -0700
> 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>
Pablo, I assume you will take this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] x_table: align per cpu xt_counter
2015-06-18 10:43 ` David Miller
@ 2015-06-18 10:50 ` Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-18 10:50 UTC (permalink / raw)
To: David Miller; +Cc: eric.dumazet, netfilter-devel, netdev, fw
On Thu, Jun 18, 2015 at 03:43:26AM -0700, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Mon, 15 Jun 2015 18:10:13 -0700
>
> > 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>
>
> Pablo, I assume you will take this.
Yes, I'll prepare another pull request for you along today.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-18 18:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-16 1:10 [PATCH net-next] x_table: align per cpu xt_counter Eric Dumazet
2015-06-17 17:08 ` Florian Westphal
2015-06-18 19:04 ` Pablo Neira Ayuso
2015-06-18 10:43 ` David Miller
2015-06-18 10:50 ` Pablo Neira Ayuso
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).