]> git.karo-electronics.de Git - linux-beck.git/commitdiff
netfilter: nf_conntrack: one less atomic op in nf_ct_expect_insert()
authorEric Dumazet <eric.dumazet@gmail.com>
Tue, 16 Nov 2010 09:19:18 +0000 (10:19 +0100)
committerPatrick McHardy <kaber@trash.net>
Tue, 16 Nov 2010 09:19:18 +0000 (10:19 +0100)
Instead of doing atomic_inc(&exp->use) twice,
call atomic_add(2, &exp->use);

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
net/netfilter/nf_conntrack_expect.c

index bbb21402596d995eb27adcef109c63cd85fd4def..774f32ba2ac97db629997caa6bef063434a1c9ba 100644 (file)
@@ -323,7 +323,8 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp)
        const struct nf_conntrack_expect_policy *p;
        unsigned int h = nf_ct_expect_dst_hash(&exp->tuple);
 
-       atomic_inc(&exp->use);
+       /* two references : one for hash insert, one for the timer */
+       atomic_add(2, &exp->use);
 
        if (master_help) {
                hlist_add_head(&exp->lnode, &master_help->expectations);
@@ -345,7 +346,6 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp)
        }
        add_timer(&exp->timeout);
 
-       atomic_inc(&exp->use);
        NF_CT_STAT_INC(net, expect_create);
 }