* RFC: conntrack: use mod_timer_pending()
@ 2009-06-10 13:05 Patrick McHardy
2009-06-10 13:07 ` Patrick McHardy
2009-06-11 6:43 ` Martin Josefsson
0 siblings, 2 replies; 6+ messages in thread
From: Patrick McHardy @ 2009-06-10 13:05 UTC (permalink / raw)
To: Netfilter Development Mailinglist, Martin Josefsson
[-- Attachment #1: Type: text/plain, Size: 249 bytes --]
This patch changes conntrack to use the new mod_timer_pending()
function, which only rearms the timer if it was still active.
This allows to only grab the lock in __nf_ct_refresh_acct when
accounting is used.
Anyone seing anything wrong with this?
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1349 bytes --]
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index edf9569..2737f5d 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -807,8 +807,6 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
NF_CT_ASSERT(ct->timeout.data == (unsigned long)ct);
NF_CT_ASSERT(skb);
- spin_lock_bh(&nf_conntrack_lock);
-
/* Only update if this is not a fixed timeout */
if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status))
goto acct;
@@ -822,11 +820,8 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
/* Only update the timeout if the new timeout is at least
HZ jiffies from the old timeout. Need del_timer for race
avoidance (may already be dying). */
- if (newtime - ct->timeout.expires >= HZ
- && del_timer(&ct->timeout)) {
- ct->timeout.expires = newtime;
- add_timer(&ct->timeout);
- }
+ if (newtime - ct->timeout.expires >= HZ)
+ mod_timer_pending(&ct->timeout, newtime);
}
acct:
@@ -835,13 +830,13 @@ acct:
acct = nf_conn_acct_find(ct);
if (acct) {
+ spin_lock_bh(&nf_conntrack_lock);
acct[CTINFO2DIR(ctinfo)].packets++;
acct[CTINFO2DIR(ctinfo)].bytes +=
skb->len - skb_network_offset(skb);
+ spin_unlock_bh(&nf_conntrack_lock);
}
}
-
- spin_unlock_bh(&nf_conntrack_lock);
}
EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: RFC: conntrack: use mod_timer_pending()
2009-06-10 13:05 RFC: conntrack: use mod_timer_pending() Patrick McHardy
@ 2009-06-10 13:07 ` Patrick McHardy
2009-06-10 14:51 ` Stephen Hemminger
2009-06-11 6:43 ` Martin Josefsson
1 sibling, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2009-06-10 13:07 UTC (permalink / raw)
To: Netfilter Development Mailinglist, Martin Josefsson
Patrick McHardy wrote:
> This patch changes conntrack to use the new mod_timer_pending()
> function, which only rearms the timer if it was still active.
> This allows to only grab the lock in __nf_ct_refresh_acct when
> accounting is used.
>
> Anyone seing anything wrong with this?
> if (acct) {
> + spin_lock_bh(&nf_conntrack_lock);
> acct[CTINFO2DIR(ctinfo)].packets++;
> acct[CTINFO2DIR(ctinfo)].bytes +=
> skb->len - skb_network_offset(skb);
> + spin_unlock_bh(&nf_conntrack_lock);
> }
In fact, we could additionally change it to use the per-conntrack lock.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: RFC: conntrack: use mod_timer_pending()
2009-06-10 13:07 ` Patrick McHardy
@ 2009-06-10 14:51 ` Stephen Hemminger
2009-06-10 14:53 ` Patrick McHardy
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2009-06-10 14:51 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Netfilter Development Mailinglist, Martin Josefsson
On Wed, 10 Jun 2009 15:07:02 +0200
Patrick McHardy <kaber@trash.net> wrote:
> Patrick McHardy wrote:
> > This patch changes conntrack to use the new mod_timer_pending()
> > function, which only rearms the timer if it was still active.
> > This allows to only grab the lock in __nf_ct_refresh_acct when
> > accounting is used.
> >
> > Anyone seing anything wrong with this?
>
> > if (acct) {
> > + spin_lock_bh(&nf_conntrack_lock);
> > acct[CTINFO2DIR(ctinfo)].packets++;
> > acct[CTINFO2DIR(ctinfo)].bytes +=
> > skb->len - skb_network_offset(skb);
> > + spin_unlock_bh(&nf_conntrack_lock);
> > }
>
> In fact, we could additionally change it to use the per-conntrack lock.
That is what the conntrack RCU patch did.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: RFC: conntrack: use mod_timer_pending()
2009-06-10 14:51 ` Stephen Hemminger
@ 2009-06-10 14:53 ` Patrick McHardy
2009-06-10 15:07 ` Stephen Hemminger
0 siblings, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2009-06-10 14:53 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Netfilter Development Mailinglist, Martin Josefsson
Stephen Hemminger wrote:
> On Wed, 10 Jun 2009 15:07:02 +0200
> Patrick McHardy <kaber@trash.net> wrote:
>
>> Patrick McHardy wrote:
>>> This patch changes conntrack to use the new mod_timer_pending()
>>> function, which only rearms the timer if it was still active.
>>> This allows to only grab the lock in __nf_ct_refresh_acct when
>>> accounting is used.
>>>
>>> Anyone seing anything wrong with this?
>>> if (acct) {
>>> + spin_lock_bh(&nf_conntrack_lock);
>>> acct[CTINFO2DIR(ctinfo)].packets++;
>>> acct[CTINFO2DIR(ctinfo)].bytes +=
>>> skb->len - skb_network_offset(skb);
>>> + spin_unlock_bh(&nf_conntrack_lock);
>>> }
>> In fact, we could additionally change it to use the per-conntrack lock.
>
> That is what the conntrack RCU patch did.
Could you remind me which one exactly? There have been a lot of
patches passed around :)
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: RFC: conntrack: use mod_timer_pending()
2009-06-10 14:53 ` Patrick McHardy
@ 2009-06-10 15:07 ` Stephen Hemminger
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2009-06-10 15:07 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Netfilter Development Mailinglist, Martin Josefsson
On Wed, 10 Jun 2009 16:53:14 +0200
Patrick McHardy <kaber@trash.net> wrote:
> Stephen Hemminger wrote:
> > On Wed, 10 Jun 2009 15:07:02 +0200
> > Patrick McHardy <kaber@trash.net> wrote:
> >
> >> Patrick McHardy wrote:
> >>> This patch changes conntrack to use the new mod_timer_pending()
> >>> function, which only rearms the timer if it was still active.
> >>> This allows to only grab the lock in __nf_ct_refresh_acct when
> >>> accounting is used.
> >>>
> >>> Anyone seing anything wrong with this?
> >>> if (acct) {
> >>> + spin_lock_bh(&nf_conntrack_lock);
> >>> acct[CTINFO2DIR(ctinfo)].packets++;
> >>> acct[CTINFO2DIR(ctinfo)].bytes +=
> >>> skb->len - skb_network_offset(skb);
> >>> + spin_unlock_bh(&nf_conntrack_lock);
> >>> }
> >> In fact, we could additionally change it to use the per-conntrack lock.
> >
> > That is what the conntrack RCU patch did.
>
> Could you remind me which one exactly? There have been a lot of
> patches passed around :)
>
>
Sorry, got confused, the patch I was thinking of was for the
TCP conntrack lock.
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: RFC: conntrack: use mod_timer_pending()
2009-06-10 13:05 RFC: conntrack: use mod_timer_pending() Patrick McHardy
2009-06-10 13:07 ` Patrick McHardy
@ 2009-06-11 6:43 ` Martin Josefsson
1 sibling, 0 replies; 6+ messages in thread
From: Martin Josefsson @ 2009-06-11 6:43 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Netfilter Development Mailinglist, Martin Josefsson
On Wed, 10 Jun 2009, Patrick McHardy wrote:
> This patch changes conntrack to use the new mod_timer_pending()
> function, which only rearms the timer if it was still active.
> This allows to only grab the lock in __nf_ct_refresh_acct when
> accounting is used.
>
> Anyone seing anything wrong with this?
I don't see any problem with it.
Looks good, thanks.
/Martin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-06-11 7:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-10 13:05 RFC: conntrack: use mod_timer_pending() Patrick McHardy
2009-06-10 13:07 ` Patrick McHardy
2009-06-10 14:51 ` Stephen Hemminger
2009-06-10 14:53 ` Patrick McHardy
2009-06-10 15:07 ` Stephen Hemminger
2009-06-11 6:43 ` Martin Josefsson
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).