This is a note to let you know that I've just added the patch titled pkt_sched: fq: fix pacing for small frames to the 3.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: pkt_sched-fq-fix-pacing-for-small-frames.patch and it can be found in the queue-3.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Thu Dec 5 16:16:39 PST 2013 From: Eric Dumazet <edumazet@xxxxxxxxxx> Date: Fri, 15 Nov 2013 08:58:14 -0800 Subject: pkt_sched: fq: fix pacing for small frames From: Eric Dumazet <edumazet@xxxxxxxxxx> [ Upstream commit f52ed89971adbe79b6438c459814034707b8ab91 ] For performance reasons, sch_fq tried hard to not setup timers for every sent packet, using a quantum based heuristic : A delay is setup only if the flow exhausted its credit. Problem is that application limited flows can refill their credit for every queued packet, and they can evade pacing. This problem can also be triggered when TCP flows use small MSS values, as TSO auto sizing builds packets that are smaller than the default fq quantum (3028 bytes) This patch adds a 40 ms delay to guard flow credit refill. Fixes: afe4fd062416 ("pkt_sched: fq: Fair Queue packet scheduler") Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx> Cc: Maciej Żenczykowski <maze@xxxxxxxxxx> Cc: Willem de Bruijn <willemb@xxxxxxxxxx> Cc: Yuchung Cheng <ycheng@xxxxxxxxxx> Cc: Neal Cardwell <ncardwell@xxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- include/uapi/linux/pkt_sched.h | 3 +++ net/sched/sch_fq.c | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -764,6 +764,9 @@ enum { TCA_FQ_FLOW_MAX_RATE, /* per flow max rate */ TCA_FQ_BUCKETS_LOG, /* log2(number of buckets) */ + + TCA_FQ_FLOW_REFILL_DELAY, /* flow credit refill delay in usec */ + __TCA_FQ_MAX }; --- a/net/sched/sch_fq.c +++ b/net/sched/sch_fq.c @@ -88,6 +88,7 @@ struct fq_sched_data { struct fq_flow internal; /* for non classified or high prio packets */ u32 quantum; u32 initial_quantum; + u32 flow_refill_delay; u32 flow_max_rate; /* optional max rate per flow */ u32 flow_plimit; /* max packets per flow */ struct rb_root *fq_root; @@ -114,6 +115,7 @@ static struct fq_flow detached, throttle static void fq_flow_set_detached(struct fq_flow *f) { f->next = &detached; + f->age = jiffies; } static bool fq_flow_is_detached(const struct fq_flow *f) @@ -365,17 +367,20 @@ static int fq_enqueue(struct sk_buff *sk } f->qlen++; - flow_queue_add(f, skb); if (skb_is_retransmit(skb)) q->stat_tcp_retrans++; sch->qstats.backlog += qdisc_pkt_len(skb); if (fq_flow_is_detached(f)) { fq_flow_add_tail(&q->new_flows, f); - if (q->quantum > f->credit) - f->credit = q->quantum; + if (time_after(jiffies, f->age + q->flow_refill_delay)) + f->credit = max_t(u32, f->credit, q->quantum); q->inactive_flows--; qdisc_unthrottled(sch); } + + /* Note: this overwrites f->age */ + flow_queue_add(f, skb); + if (unlikely(f == &q->internal)) { q->stat_internal_packets++; qdisc_unthrottled(sch); @@ -453,7 +458,6 @@ begin: fq_flow_add_tail(&q->old_flows, f); } else { fq_flow_set_detached(f); - f->age = jiffies; q->inactive_flows++; } goto begin; @@ -607,6 +611,7 @@ static const struct nla_policy fq_policy [TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NLA_U32 }, [TCA_FQ_FLOW_MAX_RATE] = { .type = NLA_U32 }, [TCA_FQ_BUCKETS_LOG] = { .type = NLA_U32 }, + [TCA_FQ_FLOW_REFILL_DELAY] = { .type = NLA_U32 }, }; static int fq_change(struct Qdisc *sch, struct nlattr *opt) @@ -663,6 +668,12 @@ static int fq_change(struct Qdisc *sch, err = -EINVAL; } + if (tb[TCA_FQ_FLOW_REFILL_DELAY]) { + u32 usecs_delay = nla_get_u32(tb[TCA_FQ_FLOW_REFILL_DELAY]) ; + + q->flow_refill_delay = usecs_to_jiffies(usecs_delay); + } + if (!err) err = fq_resize(q, fq_log); @@ -698,6 +709,7 @@ static int fq_init(struct Qdisc *sch, st q->flow_plimit = 100; q->quantum = 2 * psched_mtu(qdisc_dev(sch)); q->initial_quantum = 10 * psched_mtu(qdisc_dev(sch)); + q->flow_refill_delay = msecs_to_jiffies(40); q->flow_max_rate = ~0U; q->rate_enable = 1; q->new_flows.first = NULL; @@ -732,6 +744,8 @@ static int fq_dump(struct Qdisc *sch, st nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) || nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) || nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, q->flow_max_rate) || + nla_put_u32(skb, TCA_FQ_FLOW_REFILL_DELAY, + jiffies_to_usecs(q->flow_refill_delay)) || nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log)) goto nla_put_failure; Patches currently in stable-queue which might be from edumazet@xxxxxxxxxx are queue-3.12/net-8139cp-fix-a-bug_on-triggered-by-wrong-bytes_compl.patch queue-3.12/sch_tbf-handle-too-small-burst.patch queue-3.12/gro-only-verify-tcp-checksums-for-candidates.patch queue-3.12/net-tcp-fix-panic-in-tcp_fastopen_cache_set.patch queue-3.12/tcp-tsq-restore-minimal-amount-of-queueing.patch queue-3.12/pkt_sched-fq-fix-pacing-for-small-frames.patch queue-3.12/ipv6-fix-possible-seqlock-deadlock-in-ip6_finish_output2.patch queue-3.12/tcp-don-t-update-snd_nxt-when-a-socket-is-switched-from-repair-mode.patch queue-3.12/inet-fix-possible-seqlock-deadlocks.patch queue-3.12/net-x86-bpf-don-t-forget-to-free-sk_filter-v2.patch queue-3.12/sit-fix-use-after-free-of-fb_tunnel_dev.patch queue-3.12/net-clamp-msg_namelen-instead-of-returning-an-error.patch queue-3.12/af_packet-block-bh-in-prb_shutdown_retire_blk_timer.patch queue-3.12/pkt_sched-fq-change-classification-of-control.patch queue-3.12/pkt_sched-fq-warn-users-using-defrate.patch queue-3.12/gro-clean-up-tcpx_gro_receive-checksum-verification.patch queue-3.12/ipv4-fix-possible-seqlock-deadlock.patch queue-3.12/gso-handle-new-frag_list-of-frags-gro-packets.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html