From: Stephen Hemminger <shemminger@vyatta.com>
To: Patrick McHardy <kaber@trash.net>
Cc: Eric Dumazet <dada1@cosmosbay.com>,
David Miller <davem@davemloft.net>,
Rick Jones <rick.jones2@hp.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: Re: [RFT 3/3] iptables: lock free counters
Date: Mon, 9 Feb 2009 09:14:37 -0800 [thread overview]
Message-ID: <20090209091437.5d5cbf48@extreme> (raw)
In-Reply-To: <4990515B.3070409@trash.net>
On Mon, 09 Feb 2009 16:52:59 +0100
Patrick McHardy <kaber@trash.net> wrote:
> Eric Dumazet wrote:
> > Stephen Hemminger a écrit :
> >> @@ -939,14 +973,30 @@ static struct xt_counters * alloc_counte
> >> counters = vmalloc_node(countersize, numa_node_id());
> >>
> >> if (counters == NULL)
> >> - return ERR_PTR(-ENOMEM);
> >> + goto nomem;
> >> +
> >> + tmp = xt_alloc_table_info(private->size);
> >> + if (!tmp)
> >> + goto free_counters;
> >> +
> >
> >> + xt_zero_table_entries(tmp);
> > This is not correct. We must copy rules and zero counters on the copied stuff.
>
> Indeed.
It is in next version.
> >> static int
> >> do_add_counters(struct net *net, void __user *user, unsigned int len, int compat)
> >> @@ -1393,13 +1422,14 @@ do_add_counters(struct net *net, void __
> >> goto free;
> >> }
> >>
> >> - write_lock_bh(&t->lock);
> >> + mutex_lock(&t->lock);
> >> private = t->private;
> >> if (private->number != num_counters) {
> >> ret = -EINVAL;
> >> goto unlock_up_free;
> >> }
> >>
> >> + preempt_disable();
> >> i = 0;
> >> /* Choose the copy that is on our node */
>
> This isn't actually necessary, its merely an optimization. Since this
> can take quite a while, it might be nicer not to disable preempt.
Need to stay on same cpu, to avoid race of preempt and two cpu's updating
same counter entry (and 64 bit counter update is not atomic)
next prev parent reply other threads:[~2009-02-09 17:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090204001202.724266235@vyatta.com>
2009-02-04 1:40 ` [RFT 0/3] netfilter: lock free tables Rick Jones
[not found] ` <20090204001755.808036408@vyatta.com>
2009-02-04 3:10 ` [RFT 3/3] iptables: lock free counters Eric Dumazet
2009-02-09 15:52 ` Patrick McHardy
2009-02-09 17:14 ` Stephen Hemminger [this message]
2009-02-10 17:52 ` [RFC] iptables: lock free counters (v0.6) Stephen Hemminger
2009-02-10 22:14 ` Ranjit Manomohan
2009-02-10 22:20 ` Rick Jones
2009-02-09 15:58 ` [RFT 3/3] iptables: lock free counters Patrick McHardy
[not found] ` <20090204001755.685385465@vyatta.com>
2009-02-09 15:37 ` [RFT 2/3] netfilter: remove unneeded initializations Patrick McHardy
2009-02-09 16:23 ` Stephen Hemminger
2009-02-09 16:25 ` Patrick McHardy
2009-02-09 16:24 ` [PATCH] ebtables: " Stephen Hemminger
2009-02-09 16:30 ` Patrick McHardy
2009-02-09 16:28 ` [RFT 2/3] netfilter: " Patrick McHardy
[not found] ` <20090204001755.549902016@vyatta.com>
2009-02-09 16:27 ` [RFT 1/3] netfilter: change elements in x_tables Patrick McHardy
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=20090209091437.5d5cbf48@extreme \
--to=shemminger@vyatta.com \
--cc=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rick.jones2@hp.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).