Re: [PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-11 Thread Arnd Bergmann
On Sunday, December 11, 2016 11:43:59 AM CET Pablo Neira Ayuso wrote: > Dump and reset doesn't work unless cmpxchg64() is used both from packet > and control plane paths. This approach is going to be slow though. > Instead, use a percpu seqcount to fetch counters consistently, then > subtract

[PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-11 Thread Pablo Neira Ayuso
Dump and reset doesn't work unless cmpxchg64() is used both from packet and control plane paths. This approach is going to be slow though. Instead, use a percpu seqcount to fetch counters consistently, then subtract bytes and packets in case a reset was requested. The cpu that running over the

Re: [PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-11 Thread Pablo Neira Ayuso
On Sat, Dec 10, 2016 at 07:40:08AM -0800, Eric Dumazet wrote: > On Sat, 2016-12-10 at 15:25 +0100, Pablo Neira Ayuso wrote: > > On Sat, Dec 10, 2016 at 03:16:55PM +0100, Pablo Neira Ayuso wrote: > = > > > > - nft_counter_fetch(priv, , reset); > > + nft_counter_fetch(priv, ); > > +

Re: [PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-10 Thread Eric Dumazet
On Sat, 2016-12-10 at 15:25 +0100, Pablo Neira Ayuso wrote: > On Sat, Dec 10, 2016 at 03:16:55PM +0100, Pablo Neira Ayuso wrote: = > > - nft_counter_fetch(priv, , reset); > + nft_counter_fetch(priv, ); > + if (reset) > + nft_counter_reset(priv, ); > > if

Re: [PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-10 Thread Pablo Neira Ayuso
On Sat, Dec 10, 2016 at 03:16:55PM +0100, Pablo Neira Ayuso wrote: > On Sat, Dec 10, 2016 at 03:05:41PM +0100, Pablo Neira Ayuso wrote: > [...] > > -static void nft_counter_reset(struct nft_counter_percpu __percpu *counter, > > - struct nft_counter *total) > > -{ > > -

Re: [PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-10 Thread Pablo Neira Ayuso
On Sat, Dec 10, 2016 at 03:05:41PM +0100, Pablo Neira Ayuso wrote: [...] > -static void nft_counter_reset(struct nft_counter_percpu __percpu *counter, > - struct nft_counter *total) > -{ > - struct nft_counter_percpu *cpu_stats; > - u64 bytes, packets; > -

[PATCH net-next] netfilter: nft_counter: rework atomic dump and reset

2016-12-10 Thread Pablo Neira Ayuso
Dump and reset doesn't work unless cmpxchg64() is used both from both packet and control plane paths. This approach is going to be slow though. Instead, use a percpu seqcount to fetch counters consistently, then subtract bytes and packets in case a reset was requested. This patch is based on