Skip to content

Commit 82a0aa5

Browse files
edumazetdavem330
authored andcommitted
net_sched: sch_fq: use bulk freeing in fq_gc()
fq_gc() already builds a small array of pointers, so using kmem_cache_free_bulk() needs very little change. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7ba0537 commit 82a0aa5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

net/sched/sch_fq.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ static void fq_gc(struct fq_sched_data *q,
214214
struct rb_root *root,
215215
struct sock *sk)
216216
{
217-
struct fq_flow *f, *tofree[FQ_GC_MAX];
218217
struct rb_node **p, *parent;
219-
int fcnt = 0;
218+
void *tofree[FQ_GC_MAX];
219+
struct fq_flow *f;
220+
int i, fcnt = 0;
220221

221222
p = &root->rb_node;
222223
parent = NULL;
@@ -239,15 +240,18 @@ static void fq_gc(struct fq_sched_data *q,
239240
p = &parent->rb_left;
240241
}
241242

243+
if (!fcnt)
244+
return;
245+
246+
for (i = fcnt; i > 0; ) {
247+
f = tofree[--i];
248+
rb_erase(&f->fq_node, root);
249+
}
242250
q->flows -= fcnt;
243251
q->inactive_flows -= fcnt;
244252
q->stat_gc_flows += fcnt;
245-
while (fcnt) {
246-
struct fq_flow *f = tofree[--fcnt];
247253

248-
rb_erase(&f->fq_node, root);
249-
kmem_cache_free(fq_flow_cachep, f);
250-
}
254+
kmem_cache_free_bulk(fq_flow_cachep, fcnt, tofree);
251255
}
252256

253257
static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)

0 commit comments

Comments
 (0)