Skip to content

Commit c288b0c

Browse files
edumazetdavem330
authored andcommitted
net_sched: sch_fq: do not call fq_peek() twice per packet
This refactors the code to not call fq_peek() from fq_dequeue_head() since the caller can provide the skb. Also rename fq_dequeue_head() to fq_dequeue_skb() because 'head' is a bit vague, given the skb could come from t_root rb-tree. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 82a0aa5 commit c288b0c

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

net/sched/sch_fq.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -384,19 +384,17 @@ static void fq_erase_head(struct Qdisc *sch, struct fq_flow *flow,
384384
}
385385
}
386386

387-
/* remove one skb from head of flow queue */
388-
static struct sk_buff *fq_dequeue_head(struct Qdisc *sch, struct fq_flow *flow)
387+
/* Remove one skb from flow queue.
388+
* This skb must be the return value of prior fq_peek().
389+
*/
390+
static void fq_dequeue_skb(struct Qdisc *sch, struct fq_flow *flow,
391+
struct sk_buff *skb)
389392
{
390-
struct sk_buff *skb = fq_peek(flow);
391-
392-
if (skb) {
393-
fq_erase_head(sch, flow, skb);
394-
skb_mark_not_on_list(skb);
395-
flow->qlen--;
396-
qdisc_qstats_backlog_dec(sch, skb);
397-
sch->q.qlen--;
398-
}
399-
return skb;
393+
fq_erase_head(sch, flow, skb);
394+
skb_mark_not_on_list(skb);
395+
flow->qlen--;
396+
qdisc_qstats_backlog_dec(sch, skb);
397+
sch->q.qlen--;
400398
}
401399

402400
static void flow_queue_add(struct fq_flow *flow, struct sk_buff *skb)
@@ -508,9 +506,11 @@ static struct sk_buff *fq_dequeue(struct Qdisc *sch)
508506
if (!sch->q.qlen)
509507
return NULL;
510508

511-
skb = fq_dequeue_head(sch, &q->internal);
512-
if (skb)
509+
skb = fq_peek(&q->internal);
510+
if (unlikely(skb)) {
511+
fq_dequeue_skb(sch, &q->internal, skb);
513512
goto out;
513+
}
514514

515515
now = ktime_get_ns();
516516
fq_check_throttled(q, now);
@@ -550,10 +550,8 @@ static struct sk_buff *fq_dequeue(struct Qdisc *sch)
550550
INET_ECN_set_ce(skb);
551551
q->stat_ce_mark++;
552552
}
553-
}
554-
555-
skb = fq_dequeue_head(sch, f);
556-
if (!skb) {
553+
fq_dequeue_skb(sch, f, skb);
554+
} else {
557555
head->first = f->next;
558556
/* force a pass through old_flows to prevent starvation */
559557
if ((head == &q->new_flows) && q->old_flows.first) {

0 commit comments

Comments
 (0)