aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <brouer@redhat.com>2013-01-28 18:45:51 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-29 13:36:24 -0500
commit3ef0eb0db4bf92c6d2510fe5c4dc51852746f206 (patch)
tree3f0d424f598a82eb17a5199d27fec9964513e16e /net
parent6d7b857d541ecd1d9bd997c97242d4ef94b19de2 (diff)
net: frag, move LRU list maintenance outside of rwlock
Updating the fragmentation queues LRU (Least-Recently-Used) list, required taking the hash writer lock. However, the LRU list isn't tied to the hash at all, so we can use a separate lock for it. Original-idea-by: Florian Westphal <fw@strlen.de> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/inet_fragment.c12
-rw-r--r--net/ipv4/ip_fragment.c4
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c5
-rw-r--r--net/ipv6/reassembly.c4
4 files changed, 11 insertions, 14 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index b82520565098..2e453bde6992 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -75,6 +75,7 @@ void inet_frags_init_net(struct netns_frags *nf)
75 nf->nqueues = 0; 75 nf->nqueues = 0;
76 init_frag_mem_limit(nf); 76 init_frag_mem_limit(nf);
77 INIT_LIST_HEAD(&nf->lru_list); 77 INIT_LIST_HEAD(&nf->lru_list);
78 spin_lock_init(&nf->lru_lock);
78} 79}
79EXPORT_SYMBOL(inet_frags_init_net); 80EXPORT_SYMBOL(inet_frags_init_net);
80 81
@@ -100,9 +101,9 @@ static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
100{ 101{
101 write_lock(&f->lock); 102 write_lock(&f->lock);
102 hlist_del(&fq->list); 103 hlist_del(&fq->list);
103 list_del(&fq->lru_list);
104 fq->net->nqueues--; 104 fq->net->nqueues--;
105 write_unlock(&f->lock); 105 write_unlock(&f->lock);
106 inet_frag_lru_del(fq);
106} 107}
107 108
108void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f) 109void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f)
@@ -170,16 +171,17 @@ int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force)
170 171
171 work = frag_mem_limit(nf) - nf->low_thresh; 172 work = frag_mem_limit(nf) - nf->low_thresh;
172 while (work > 0) { 173 while (work > 0) {
173 read_lock(&f->lock); 174 spin_lock(&nf->lru_lock);
175
174 if (list_empty(&nf->lru_list)) { 176 if (list_empty(&nf->lru_list)) {
175 read_unlock(&f->lock); 177 spin_unlock(&nf->lru_lock);
176 break; 178 break;
177 } 179 }
178 180
179 q = list_first_entry(&nf->lru_list, 181 q = list_first_entry(&nf->lru_list,
180 struct inet_frag_queue, lru_list); 182 struct inet_frag_queue, lru_list);
181 atomic_inc(&q->refcnt); 183 atomic_inc(&q->refcnt);
182 read_unlock(&f->lock); 184 spin_unlock(&nf->lru_lock);
183 185
184 spin_lock(&q->lock); 186 spin_lock(&q->lock);
185 if (!(q->last_in & INET_FRAG_COMPLETE)) 187 if (!(q->last_in & INET_FRAG_COMPLETE))
@@ -233,9 +235,9 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
233 235
234 atomic_inc(&qp->refcnt); 236 atomic_inc(&qp->refcnt);
235 hlist_add_head(&qp->list, &f->hash[hash]); 237 hlist_add_head(&qp->list, &f->hash[hash]);
236 list_add_tail(&qp->lru_list, &nf->lru_list);
237 nf->nqueues++; 238 nf->nqueues++;
238 write_unlock(&f->lock); 239 write_unlock(&f->lock);
240 inet_frag_lru_add(nf, qp);
239 return qp; 241 return qp;
240} 242}
241 243
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 927fe58caf46..1211613c6c34 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -529,9 +529,7 @@ found:
529 qp->q.meat == qp->q.len) 529 qp->q.meat == qp->q.len)
530 return ip_frag_reasm(qp, prev, dev); 530 return ip_frag_reasm(qp, prev, dev);
531 531
532 write_lock(&ip4_frags.lock); 532 inet_frag_lru_move(&qp->q);
533 list_move_tail(&qp->q.lru_list, &qp->q.net->lru_list);
534 write_unlock(&ip4_frags.lock);
535 return -EINPROGRESS; 533 return -EINPROGRESS;
536 534
537err: 535err:
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 07ef2949c946..c674f158efa8 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -328,9 +328,8 @@ found:
328 fq->nhoffset = nhoff; 328 fq->nhoffset = nhoff;
329 fq->q.last_in |= INET_FRAG_FIRST_IN; 329 fq->q.last_in |= INET_FRAG_FIRST_IN;
330 } 330 }
331 write_lock(&nf_frags.lock); 331
332 list_move_tail(&fq->q.lru_list, &fq->q.net->lru_list); 332 inet_frag_lru_move(&fq->q);
333 write_unlock(&nf_frags.lock);
334 return 0; 333 return 0;
335 334
336discard_fq: 335discard_fq:
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 18cb8defcdb2..bab2c270f292 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -341,9 +341,7 @@ found:
341 fq->q.meat == fq->q.len) 341 fq->q.meat == fq->q.len)
342 return ip6_frag_reasm(fq, prev, dev); 342 return ip6_frag_reasm(fq, prev, dev);
343 343
344 write_lock(&ip6_frags.lock); 344 inet_frag_lru_move(&fq->q);
345 list_move_tail(&fq->q.lru_list, &fq->q.net->lru_list);
346 write_unlock(&ip6_frags.lock);
347 return -1; 345 return -1;
348 346
349discard_fq: 347discard_fq: