mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
[INET]: Consolidate the xxx_evictor
The evictors collect some statistics for ipv4 and ipv6, so make it return the number of evicted queues and account them all at once in the caller. The XXX_ADD_STATS_BH() macros are just for this case, but maybe there are places in code, that can make use of them as well. Signed-off-by: Pavel Emelyanov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
1e4b82873a
commit
8e7999c44e
7 changed files with 52 additions and 80 deletions
|
|
@ -140,3 +140,35 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f,
|
|||
|
||||
}
|
||||
EXPORT_SYMBOL(inet_frag_destroy);
|
||||
|
||||
int inet_frag_evictor(struct inet_frags *f)
|
||||
{
|
||||
struct inet_frag_queue *q;
|
||||
int work, evicted = 0;
|
||||
|
||||
work = atomic_read(&f->mem) - f->ctl->low_thresh;
|
||||
while (work > 0) {
|
||||
read_lock(&f->lock);
|
||||
if (list_empty(&f->lru_list)) {
|
||||
read_unlock(&f->lock);
|
||||
break;
|
||||
}
|
||||
|
||||
q = list_first_entry(&f->lru_list,
|
||||
struct inet_frag_queue, lru_list);
|
||||
atomic_inc(&q->refcnt);
|
||||
read_unlock(&f->lock);
|
||||
|
||||
spin_lock(&q->lock);
|
||||
if (!(q->last_in & COMPLETE))
|
||||
inet_frag_kill(q, f);
|
||||
spin_unlock(&q->lock);
|
||||
|
||||
if (atomic_dec_and_test(&q->refcnt))
|
||||
inet_frag_destroy(q, f, &work);
|
||||
evicted++;
|
||||
}
|
||||
|
||||
return evicted;
|
||||
}
|
||||
EXPORT_SYMBOL(inet_frag_evictor);
|
||||
|
|
|
|||
|
|
@ -174,33 +174,11 @@ static void ipq_kill(struct ipq *ipq)
|
|||
*/
|
||||
static void ip_evictor(void)
|
||||
{
|
||||
struct ipq *qp;
|
||||
struct list_head *tmp;
|
||||
int work;
|
||||
int evicted;
|
||||
|
||||
work = atomic_read(&ip4_frags.mem) - ip4_frags_ctl.low_thresh;
|
||||
if (work <= 0)
|
||||
return;
|
||||
|
||||
while (work > 0) {
|
||||
read_lock(&ip4_frags.lock);
|
||||
if (list_empty(&ip4_frags.lru_list)) {
|
||||
read_unlock(&ip4_frags.lock);
|
||||
return;
|
||||
}
|
||||
tmp = ip4_frags.lru_list.next;
|
||||
qp = list_entry(tmp, struct ipq, q.lru_list);
|
||||
atomic_inc(&qp->q.refcnt);
|
||||
read_unlock(&ip4_frags.lock);
|
||||
|
||||
spin_lock(&qp->q.lock);
|
||||
if (!(qp->q.last_in&COMPLETE))
|
||||
ipq_kill(qp);
|
||||
spin_unlock(&qp->q.lock);
|
||||
|
||||
ipq_put(qp, &work);
|
||||
IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
|
||||
}
|
||||
evicted = inet_frag_evictor(&ip4_frags);
|
||||
if (evicted)
|
||||
IP_ADD_STATS_BH(IPSTATS_MIB_REASMFAILS, evicted);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue