Skip to contentSkip to conversation

net_sched: sch_fq: avoid calling ktime_get_ns() if not needed

PATCH Applied Eric Dumazet 2 participants 3 messages Nov 20, 2018 – Nov 21, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net_sched: sch_fq: avoid calling ktime_get_ns() if not needed

There are two cases were we can avoid calling ktime_get_ns() :

1) Queue is empty.
2) Internal queue is not empty.

---
 net/sched/sch_fq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/sched/sch_fq.c +6 -1
index 1da8864502d448cfa93a9c02da504af61a1093e5..1a662f2bb7bb7bb5507107f61657d44fa28ca991 100644
@@ -414,16 +414,21 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 now)
 static struct sk_buff *fq_dequeue(struct Qdisc *sch)
 {
 	struct fq_sched_data *q = qdisc_priv(sch);
-	u64 now = ktime_get_ns();
 	struct fq_flow_head *head;
 	struct sk_buff *skb;
 	struct fq_flow *f;
 	unsigned long rate;
 	u32 plen;
+	u64 now;
+
+	if (!sch->q.qlen)
+		return NULL;
 
 	skb = fq_dequeue_head(sch, &q->internal);
 	if (skb)
 		goto out;
+
+	now = ktime_get_ns();
 	fq_check_throttled(q, now);
 begin:
 	head = &q->new_flows;
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
maintainer Applied
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Mon, 19 Nov 2018 17:30:19 -0800

Quoted 6 lines

There are two cases were we can avoid calling ktime_get_ns() :

1) Queue is empty.
2) Internal queue is not empty.

Applied.

But just to be clear, if the qdisc is empty we do not need to update flow credits etc.?

#2 lore raw
Quoted 9 lines · David Miller

From: Eric Dumazet <[email protected]>
Date: Mon, 19 Nov 2018 17:30:19 -0800

Quoted 5 lines

There are two cases were we can avoid calling ktime_get_ns() :

1) Queue is empty.
2) Internal queue is not empty.

Quoted 6 lines
Quoted 1 line

Applied.

But just to be clear, if the qdisc is empty we do not need to update flow credits etc.?

That is right, nothing needs to be done.