netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>,
	Patrick McHardy <kaber@trash.net>,
	netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 5/6] netfilter: use sequence number synchronization for counters
Date: Fri, 30 Jan 2009 09:03:50 +0100	[thread overview]
Message-ID: <4982B466.5000700@cosmosbay.com> (raw)
In-Reply-To: <20090129191520.531815152@vyatta.com>

Stephen Hemminger a écrit :
> Change how synchronization is done on the iptables counters. Use seqcount
> wrapper instead of depending on reader/writer lock.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 

> --- a/net/netfilter/x_tables.c	2009-01-29 11:08:38.747070716 -0800
> +++ b/net/netfilter/x_tables.c	2009-01-29 11:10:03.595571234 -0800
> @@ -577,6 +577,34 @@ int xt_compat_target_to_user(struct xt_e
>  EXPORT_SYMBOL_GPL(xt_compat_target_to_user);
>  #endif
>  
> +static DEFINE_PER_CPU(seqcount_t, xt_counter_sequence);
> +
> +void xt_fetch_counter(struct xt_counters *v, int cpu,
> +		      const struct xt_counters *c)
> +{
> +	seqcount_t *seq = &per_cpu(xt_counter_sequence, cpu);
> +	unsigned start;
> +
> +	do {
> +		start = read_seqcount_begin(seq);
> +		*v = *c;
> +	} while (read_seqcount_retry(seq, start));
> +}
> +EXPORT_SYMBOL_GPL(xt_fetch_counter);
> +
> +void xt_incr_counter(struct xt_counters *c, unsigned b, unsigned p)

You really want an inline xt_incr_counter() function here to speedup ipt_do_table()

I agree xt_fetch_counter() is not time critical and can be outlined.



> +{
> +	seqcount_t *seq = &__get_cpu_var(xt_counter_sequence);
> +
> +	write_seqcount_begin(seq);
> +	c->pcnt += p;
> +	c->bcnt += b;
> +	write_seqcount_end(seq);
> +
> +}
> +EXPORT_SYMBOL_GPL(xt_incr_counter);
> +
> +


  reply	other threads:[~2009-01-30  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-29 19:12 [PATCH 0/6] iptables: read/write lock elimination (v0.4) Stephen Hemminger
2009-01-29 19:12 ` [PATCH 1/6] netfilter: change elements in x_tables Stephen Hemminger
2009-01-29 19:12 ` [PATCH 2/6] netfilter: remove unneeded initializations Stephen Hemminger
2009-01-29 19:12 ` [PATCH 3/6] ebtables: " Stephen Hemminger
2009-01-29 19:12 ` [PATCH 4/6] netfilter: abstract xt_counters Stephen Hemminger
2009-01-29 19:12 ` [PATCH 5/6] netfilter: use sequence number synchronization for counters Stephen Hemminger
2009-01-30  8:03   ` Eric Dumazet [this message]
2009-01-29 19:12 ` [PATCH 6/6] netfilter: convert x_tables to use RCU Stephen Hemminger
2009-01-29 23:39 ` [PATCH 0/6] iptables: read/write lock elimination (v0.4) Rick Jones

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=4982B466.5000700@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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).