From: Yang Yingliang <yangyingliang@huawei.com>
To: <netdev@vger.kernel.org>
Cc: <eric.dumazet@gmail.com>, <davem@davemloft.net>
Subject: [PATCH net-next 1/3] sch_fq: add skb_is_too_big() helper
Date: Tue, 25 Nov 2014 21:24:50 +0800 [thread overview]
Message-ID: <1416921892-4756-2-git-send-email-yangyingliang@huawei.com> (raw)
In-Reply-To: <1416921892-4756-1-git-send-email-yangyingliang@huawei.com>
Add skb_is_too_big() helper to get the cost time of sending packets
and check if it is more than 125ms.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
net/sched/sch_fq.c | 57 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index cbd7e1f..36a22e0 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -304,6 +304,37 @@ static bool skb_is_retransmit(struct sk_buff *skb)
return false;
}
+static bool skb_is_too_big(struct sk_buff *skb, struct fq_sched_data *q, u64 *cost_time)
+{
+ u32 rate = q->flow_max_rate;
+
+ if (skb->sk && skb->sk->sk_state != TCP_TIME_WAIT)
+ rate = min(skb->sk->sk_pacing_rate, q->flow_max_rate);
+
+ if (cost_time)
+ *cost_time = 0;
+
+ if (rate != ~0U) {
+ u32 plen = max(qdisc_pkt_len(skb), q->quantum);
+ u64 len = (u64)plen * NSEC_PER_SEC;
+
+ if (likely(rate))
+ do_div(len, rate);
+ if (cost_time)
+ *cost_time = len;
+ /* Since socket rate can change later,
+ * clamp the delay to 125 ms.
+ */
+ if (unlikely(len > 125 * NSEC_PER_MSEC)) {
+ if (cost_time)
+ *cost_time = 125 * NSEC_PER_MSEC;
+ return true;
+ }
+ }
+
+ return false;
+}
+
/* add skb to flow queue
* flow queue is a linked list, kind of FIFO, except for TCP retransmits
* We special case tcp retransmits to be transmitted before other packets.
@@ -418,7 +449,7 @@ static struct sk_buff *fq_dequeue(struct Qdisc *sch)
struct fq_flow_head *head;
struct sk_buff *skb;
struct fq_flow *f;
- u32 rate;
+ u64 cost_time;
skb = fq_dequeue_head(sch, &q->internal);
if (skb)
@@ -470,28 +501,10 @@ begin:
if (f->credit > 0 || !q->rate_enable)
goto out;
- rate = q->flow_max_rate;
- if (skb->sk && skb->sk->sk_state != TCP_TIME_WAIT)
- rate = min(skb->sk->sk_pacing_rate, rate);
+ if (skb_is_too_big(skb, q, &cost_time))
+ q->stat_pkts_too_long++;
+ f->time_next_packet = now + cost_time;
- if (rate != ~0U) {
- u32 plen = max(qdisc_pkt_len(skb), q->quantum);
- u64 len = (u64)plen * NSEC_PER_SEC;
-
- if (likely(rate))
- do_div(len, rate);
- /* Since socket rate can change later,
- * clamp the delay to 125 ms.
- * TODO: maybe segment the too big skb, as in commit
- * e43ac79a4bc ("sch_tbf: segment too big GSO packets")
- */
- if (unlikely(len > 125 * NSEC_PER_MSEC)) {
- len = 125 * NSEC_PER_MSEC;
- q->stat_pkts_too_long++;
- }
-
- f->time_next_packet = now + len;
- }
out:
qdisc_bstats_update(sch, skb);
return skb;
--
1.8.0
next prev parent reply other threads:[~2014-11-25 13:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 13:24 [PATCH net-next 0/3] sch_fq: segment too big GSO packets Yang Yingliang
2014-11-25 13:24 ` Yang Yingliang [this message]
2014-11-25 13:24 ` [PATCH net-next 2/3] sch_fq: add __fq_enqueue() helper Yang Yingliang
2014-11-25 13:24 ` [PATCH net-next 3/3] sch_fq: segment too big GSO packets Yang Yingliang
2014-11-25 14:53 ` Eric Dumazet
2014-11-25 16:31 ` [PATCH net-next 0/3] " Eric Dumazet
2014-11-25 16:57 ` [PATCH net-next] pkt_sched: fq: increase max delay from 125 ms to one second Eric Dumazet
2014-11-26 17:08 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416921892-4756-2-git-send-email-yangyingliang@huawei.com \
--to=yangyingliang@huawei.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).