ip_frag: Remove some atomic ops
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 13 Jun 2010 23:02:24 +0000 (23:02 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Jun 2010 01:12:44 +0000 (18:12 -0700)
Instead of doing one atomic operation per frag, we can factorize them.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_fragment.c
net/ipv6/reassembly.c

index 75347ea70ea071d6fef5223535b6bb83973b602b..963c3689d0afafa0aa59f181c99de9f2f38a5c57 100644 (file)
@@ -556,7 +556,6 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
 
        skb_shinfo(head)->frag_list = head->next;
        skb_push(head, head->data - skb_network_header(head));
-       atomic_sub(head->truesize, &qp->q.net->mem);
 
        for (fp=head->next; fp; fp = fp->next) {
                head->data_len += fp->len;
@@ -566,8 +565,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
                else if (head->ip_summed == CHECKSUM_COMPLETE)
                        head->csum = csum_add(head->csum, fp->csum);
                head->truesize += fp->truesize;
-               atomic_sub(fp->truesize, &qp->q.net->mem);
        }
+       atomic_sub(head->truesize, &qp->q.net->mem);
 
        head->next = NULL;
        head->dev = dev;
index 6d4292ff585463178885153cdd2fe6e044b962a9..a630506151c3123671ed420d6c05f93376aec80a 100644 (file)
@@ -524,7 +524,6 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
        skb_shinfo(head)->frag_list = head->next;
        skb_reset_transport_header(head);
        skb_push(head, head->data - skb_network_header(head));
-       atomic_sub(head->truesize, &fq->q.net->mem);
 
        for (fp=head->next; fp; fp = fp->next) {
                head->data_len += fp->len;
@@ -534,8 +533,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
                else if (head->ip_summed == CHECKSUM_COMPLETE)
                        head->csum = csum_add(head->csum, fp->csum);
                head->truesize += fp->truesize;
-               atomic_sub(fp->truesize, &fq->q.net->mem);
        }
+       atomic_sub(head->truesize, &fq->q.net->mem);
 
        head->next = NULL;
        head->dev = dev;