Skip to contentSkip to conversation

conntrack: one less atomic op in nf_ct_expect_insert()

PATCH Applied Eric Dumazet 2 participants 2 messages Nov 15, 2010 – Nov 16, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 conntrack: one less atomic op in nf_ct_expect_insert()

Instead of doing atomic_inc(&exp->use) twice,
call atomic_add(2, &exp->use);

---
 net/netfilter/nf_conntrack_expect.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_expect.c +2 -2
index bbb2140..774f32b 100644
@@ -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);
 }
 
#1 lore raw
Quoted 2 lines · Eric Dumazet

Instead of doing atomic_inc(&exp->use) twice,
call atomic_add(2, &exp->use);

Applied, thanks Eric.