From: Eric Dumazet <dada1@cosmosbay.com>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: Harald Welte <laforge@netfilter.org>,
Netfilter Development Mailinglist
<netfilter-devel@lists.netfilter.org>,
Patrick McHardy <kaber@trash.net>
Subject: Re: [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
Date: Fri, 27 Jan 2006 22:51:42 +0100 [thread overview]
Message-ID: <43DA95EE.6040909@cosmosbay.com> (raw)
In-Reply-To: <20060127095300.57fdd7e7@localhost.localdomain>
Stephen Hemminger a écrit :
> On Fri, 27 Jan 2006 16:46:05 +0100
> Eric Dumazet <dada1@cosmosbay.com> wrote:
>
>> Stephen Hemminger a écrit :
>>> On Fri, 27 Jan 2006 16:16:15 +0100
>>> Eric Dumazet <dada1@cosmosbay.com> wrote:
>>>
>>>> This patch helps scalability of x_tables on SMP, especially NUMA machines.
>>>>
>>>> Instead of using a single rwlock_t to protect x_tables, use an array of
>>>> rwlock_t, one for each possible cpu in the machine.
>
> It makes no sense to have a per-cpu lock. Why not just use per-cpu counters
> and bh_disable()?
>
If you examin the x_tables code, you'll discover :
A CPU A might enters the code (ipt_do_table()) because a packet is processed :
it follows the rules, increment 64 bits packet counts and 64 bits bytes
counters of matched rules... Then it leaves the code.
For this stage a read_lock_bh() was used to let this cpu does its job
(including recursive calls apparently)
Then a CPU B wants to either :
[1] - replace the rules by a new set, atomically keeping all counters values
(example : iptables -A INPUT -p tcp)
[2] - Read all the rules and associated counters atomically.
(example : iptables -nvL INPUT)
[...] - Other interesting things like resetting al counters
(example : iptables -Z)
This kind of task uses a write_lock_bh() to be sure CPU A will block in
read_lock_bh()
Then a CPU C wants to to a task similar to B (imagine you have a periodic
fetch of counters to feed a RRD database) : you want that CPU C doesnt read
garbage values when CPU B adds a new rule in a chain, and while CPU A feed
more network packets...
You need some kind of exclusion so that CPU B reads sane values, not values
currently modified by CPU A. You need some kind of exclusion to let CPU B
doing some table exchange (and keeps counters).
counters are already 'per-cpu' (ie each CPU only reads its own copy of rules
and change its own counters), and bh_disable() wont permit exclusion between CPUS.
And finally you want to keep compatibility with user programs and existing API...
So using a per-cpu rwlock does make sense...
Eric
next prev parent reply other threads:[~2006-01-27 21:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-08 21:26 [PATCH] x_tables, take 5 (Final Review) Harald Welte
2006-01-08 22:08 ` Patrick McHardy
2006-01-08 22:12 ` Patrick McHardy
2006-01-08 23:01 ` Patrick McHardy
2006-01-09 9:19 ` Harald Welte
2006-01-09 6:46 ` Patrick McHardy
2006-01-09 8:59 ` Harald Welte
2006-01-09 8:52 ` Yasuyuki KOZAKAI
[not found] ` <200601090852.k098qjeO004027@toshiba.co.jp>
2006-01-09 10:35 ` Harald Welte
2006-01-10 4:18 ` Yasuyuki KOZAKAI
[not found] ` <200601100418.k0A4IxhL008706@toshiba.co.jp>
2006-01-12 16:58 ` Harald Welte
2006-01-09 11:23 ` Eric Dumazet
2006-01-09 13:15 ` Harald Welte
2006-01-27 15:16 ` [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables Eric Dumazet
2006-01-27 15:37 ` Stephen Hemminger
2006-01-27 15:46 ` Eric Dumazet
2006-01-27 17:53 ` Stephen Hemminger
2006-01-27 21:51 ` Eric Dumazet [this message]
2006-01-27 16:06 ` Eric Dumazet
2006-01-09 17:44 ` [PATCH] x_tables, take 5 (Final Review) Yasuyuki KOZAKAI
[not found] ` <200601091744.k09HiVP2022456@toshiba.co.jp>
2006-01-12 16:02 ` Harald Welte
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=43DA95EE.6040909@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=kaber@trash.net \
--cc=laforge@netfilter.org \
--cc=netfilter-devel@lists.netfilter.org \
--cc=shemminger@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.