aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
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/ipv4
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/ipv4')
-rw-r--r--net/ipv4/inet_fragment.c12
-rw-r--r--net/ipv4/ip_fragment.c4
2 files changed, 8 insertions, 8 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: