diff options
author | Patrick McHardy <kaber@trash.net> | 2007-12-05 04:28:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:56:17 -0500 |
commit | e48b9b2fb383879a5d758d526b5eb8de4509f467 (patch) | |
tree | abc6a3b47e6e283c6cc5358b0566b1a76cb4548a /net/netfilter | |
parent | f9c639905018967e57ea24b07e82de9bcd76339f (diff) |
[NETFILTER]: nfnetlink_queue: avoid unnecessary atomic operation
The sequence counter doesn't need to be an atomic_t, just move the increment
inside the locked section.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nfnetlink_queue.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index d9ce3942af2..bd18de72e3c 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c | |||
@@ -56,7 +56,7 @@ struct nfqnl_instance { | |||
56 | unsigned int queue_dropped; | 56 | unsigned int queue_dropped; |
57 | unsigned int queue_user_dropped; | 57 | unsigned int queue_user_dropped; |
58 | 58 | ||
59 | atomic_t id_sequence; /* 'sequence' of pkt ids */ | 59 | unsigned int id_sequence; /* 'sequence' of pkt ids */ |
60 | 60 | ||
61 | u_int16_t queue_num; /* number of this queue */ | 61 | u_int16_t queue_num; /* number of this queue */ |
62 | u_int8_t copy_mode; | 62 | u_int8_t copy_mode; |
@@ -139,7 +139,6 @@ instance_create(u_int16_t queue_num, int pid) | |||
139 | inst->queue_maxlen = NFQNL_QMAX_DEFAULT; | 139 | inst->queue_maxlen = NFQNL_QMAX_DEFAULT; |
140 | inst->copy_range = 0xfffff; | 140 | inst->copy_range = 0xfffff; |
141 | inst->copy_mode = NFQNL_COPY_NONE; | 141 | inst->copy_mode = NFQNL_COPY_NONE; |
142 | atomic_set(&inst->id_sequence, 0); | ||
143 | /* needs to be two, since we _put() after creation */ | 142 | /* needs to be two, since we _put() after creation */ |
144 | atomic_set(&inst->use, 2); | 143 | atomic_set(&inst->use, 2); |
145 | spin_lock_init(&inst->lock); | 144 | spin_lock_init(&inst->lock); |
@@ -340,6 +339,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, | |||
340 | return NULL; | 339 | return NULL; |
341 | } | 340 | } |
342 | 341 | ||
342 | entry->id = queue->id_sequence++; | ||
343 | |||
343 | spin_unlock_bh(&queue->lock); | 344 | spin_unlock_bh(&queue->lock); |
344 | 345 | ||
345 | skb = alloc_skb(size, GFP_ATOMIC); | 346 | skb = alloc_skb(size, GFP_ATOMIC); |
@@ -496,8 +497,6 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum) | |||
496 | goto err_out_put; | 497 | goto err_out_put; |
497 | } | 498 | } |
498 | 499 | ||
499 | entry->id = atomic_inc_return(&queue->id_sequence); | ||
500 | |||
501 | nskb = nfqnl_build_packet_message(queue, entry, &status); | 500 | nskb = nfqnl_build_packet_message(queue, entry, &status); |
502 | if (nskb == NULL) | 501 | if (nskb == NULL) |
503 | goto err_out_put; | 502 | goto err_out_put; |
@@ -948,7 +947,7 @@ static int seq_show(struct seq_file *s, void *v) | |||
948 | inst->peer_pid, inst->queue_total, | 947 | inst->peer_pid, inst->queue_total, |
949 | inst->copy_mode, inst->copy_range, | 948 | inst->copy_mode, inst->copy_range, |
950 | inst->queue_dropped, inst->queue_user_dropped, | 949 | inst->queue_dropped, inst->queue_user_dropped, |
951 | atomic_read(&inst->id_sequence), | 950 | inst->id_sequence, |
952 | atomic_read(&inst->use)); | 951 | atomic_read(&inst->use)); |
953 | } | 952 | } |
954 | 953 | ||