From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Krzysztof Piotr Oledzki <ole@ans.pl>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: add locking for counters zeroing
Date: Wed, 24 Sep 2008 18:42:41 +0200 [thread overview]
Message-ID: <48DA6E01.2020101@trash.net> (raw)
In-Reply-To: <alpine.LNX.1.10.0809241226020.16193@fbirervta.pbzchgretzou.qr>
Jan Engelhardt wrote:
> On Wednesday 2008-09-24 12:11, Patrick McHardy wrote:
>
>>> On Wednesday 2008-09-24 12:01, Patrick McHardy wrote:
>>>
>>>>> @@ -545,6 +545,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct
>>>>> netlink_callback *cb)
>>>>> u_int8_t l3proto = nfmsg->nfgen_family;
>>>>>
>>>>> rcu_read_lock();
>>>>> + spin_lock_bh(&nf_conntrack_lock);
>>>>>
>>>> We only need the spinlock. I'm not so happy about taking it
>>>> unconditionally even though we might not be zeroing the
>>>> counters. Moving it in the inner loop will greatly increase
>>>> the amount of locks/unlocks on the other hand.
>>>>
>>>> How about moving the inner loop to a new function and adding
>>>> back the ctnetlink_dump_counterzero (or whatever it was called)
>>>> function? It would take the spinlock, while normal dumping
>>>> would only use rcu_read_lock().
>>>>
>>> Perhaps this might work?
>>>
>>> + if (cb->args[0] >= nf_conntrack_htable_size) {
>>> + nf_ct_put(cb->args[1]);
>>> + return skb->len;
>>> + }
>>>
>> I'm not sure what you're trying to fix here.
>>
>
> If the for() loop never runs because cb->args<nf_conntrack_htable_size is not
> fulfilled, no counter changes, and no locking is needed, hence the early
> return.
>
Thats a very rare condition and not something worth optimizing for.
>> Any patch that doesn't include a spin_lock
>> can't really fix the problem :)
>>
>
> Of course. You still have to add the spin_lock, preferably outside of the loop
> so it does not get necessarily dropped/re-picked-up.
Yes, but even more preferrably is don't huring normal dumps for counter
zeroing.
So I think we should split the operations.
next prev parent reply other threads:[~2008-09-24 16:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-21 16:46 [PATCH] netfilter: add locking for counters zeroing Krzysztof Piotr Oledzki
2008-09-24 16:01 ` Patrick McHardy
2008-09-24 16:08 ` Jan Engelhardt
2008-09-24 16:11 ` Patrick McHardy
2008-09-24 16:27 ` Jan Engelhardt
2008-09-24 16:42 ` Patrick McHardy [this message]
2008-09-24 16:57 ` 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=48DA6E01.2020101@trash.net \
--to=kaber@trash.net \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=ole@ans.pl \
/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