public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: hadi@cyberus.ca, Jarek Poplawski <jarkao2@gmail.com>,
	David Miller <davem@davemloft.net>,
	Jesper Dangaard Brouer <hawk@diku.dk>,
	Patrick McHardy <kaber@trash.net>
Cc: netdev <netdev@vger.kernel.org>
Subject: [RFC] net_sched: mark packet staying on queue too long
Date: Sun, 02 Jan 2011 22:27:11 +0100	[thread overview]
Message-ID: <1294003631.2535.253.camel@edumazet-laptop> (raw)
In-Reply-To: <1293111333.11306.170.camel@mojatatu>

While playing with SFQ and other AQM, I was bothered to see how easy it
was for a single tcp flow to 'fill the pipe' and consume lot of memory
buffers in queues. I know Jesper use more than 50.000 SFQ on his
routers, and with GRO packets this can consume a lot of memory.

I played a bit adding ECN in SFQ, first by marking packets for a
particular flow if this flow qlen was above a given threshold, and later
using another trick : ECN mark packet if it stayed longer than a given
delay in the queue. This of course could be done on other modules, what
do you think ?

The idea is to take into account the time packet stayed in the queue,
regardless of other class parameters.

Following quick and dirty patch to show the idea. Of course, the delay
should be configured on each SFQ/RED/XXXX class, so it would need an
iproute2 patch, and the delay unit should be "ms" (or even "us"), not
ticks, but as I said this is a quick and dirty patch (net-next-2.6
based)

Using jiffies allows only delays above 3 or 4 ticks...

Or maybe ECN is just a dream :(

 include/net/sch_generic.h |    1 +
 net/sched/sch_sfq.c       |   11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 0af57eb..1a7ac68 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -198,6 +198,7 @@ struct tcf_proto {
 };
 
 struct qdisc_skb_cb {
+	unsigned long		timestamp;
 	unsigned int		pkt_len;
 	char			data[];
 };
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index d54ac94..baf9465 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -24,6 +24,8 @@
 #include <net/ip.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
+#include <net/inet_ecn.h>
+#include <linux/moduleparam.h>
 
 
 /*	Stochastic Fairness Queuing algorithm.
@@ -86,6 +88,10 @@
 /* This type should contain at least SFQ_DEPTH + SFQ_SLOTS values */
 typedef unsigned char sfq_index;
 
+static int ecn_delay; /* default : no ECN handling */
+module_param(ecn_delay, int, 0);
+MODULE_PARM_DESC(ecn_delay, "mark packets if they stay in queue longer than ecn_delay ticks");
+
 /*
  * We dont use pointers to save space.
  * Small indexes [0 ... SFQ_SLOTS - 1] are 'pointers' to slots[] array
@@ -391,6 +397,7 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 
 	sch->qstats.backlog += qdisc_pkt_len(skb);
 	slot_queue_add(slot, skb);
+	qdisc_skb_cb(skb)->timestamp = jiffies;
 	sfq_inc(q, x);
 	if (slot->qlen == 1) {		/* The flow is new */
 		if (q->tail == NULL) {	/* It is the first flow */
@@ -460,6 +467,10 @@ next_slot:
 		q->tail->next = next_a;
 	} else {
 		slot->allot -= SFQ_ALLOT_SIZE(qdisc_pkt_len(skb));
+		if (ecn_delay &&
+		    time_after(jiffies, qdisc_skb_cb(skb)->timestamp + ecn_delay) &&
+		    INET_ECN_set_ce(skb))
+			sch->qstats.overlimits++;
 	}
 	return skb;
 }



  parent reply	other threads:[~2011-01-02 21:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 14:35 [PATCH net-2.6] net_sched: always clone skbs Changli Gao
2010-12-20 14:37 ` Eric Dumazet
2010-12-20 18:27   ` David Miller
2010-12-20 23:20 ` Jarek Poplawski
2010-12-20 23:28   ` Eric Dumazet
2010-12-20 23:52     ` Jarek Poplawski
2010-12-21 13:52       ` jamal
2010-12-21 14:17         ` Changli Gao
2010-12-21 22:37           ` Jarek Poplawski
2010-12-23 13:35             ` jamal
2010-12-23 23:04               ` Jarek Poplawski
2011-01-02 21:27               ` Eric Dumazet [this message]
2011-01-03 13:52                 ` [RFC] net_sched: mark packet staying on queue too long jamal
2011-01-03 14:02                   ` Eric Dumazet
2011-01-03 15:02                     ` jamal
2011-01-03 18:11                     ` [PATCH] sch_red: report backlog information Eric Dumazet
2011-01-03 20:13                       ` David Miller
2011-01-03 17:58                 ` [RFC] net_sched: mark packet staying on queue too long Stephen Hemminger
2011-01-04 14:19                   ` Jesper Dangaard Brouer
2011-01-04 15:02                     ` Eric Dumazet
2011-01-04 16:05                       ` Stephen Hemminger
2011-01-04 18:20                       ` Eric Dumazet
2011-01-04 18:29                         ` Eric Dumazet
2011-01-13 11:50                     ` Patrick McHardy
2011-01-13 15:54                       ` Eric Dumazet
2011-01-13 16:04                       ` sch_sfb [was: net_sched: mark packet staying on queue too long] Juliusz Chroboczek
2011-01-13 18:59                         ` Patrick McHardy
2011-01-14  0:59                           ` sch_sfb Juliusz Chroboczek
2011-01-14  1:39                             ` sch_sfb Patrick McHardy
2011-01-14 13:34                               ` sch_sfb Juliusz Chroboczek
2011-01-14 13:37                                 ` sch_sfb Patrick McHardy
2011-01-14 15:09                                 ` sch_sfb Eric Dumazet
2011-01-14 21:06                                 ` sch_sfb Jarek Poplawski
2010-12-21  0:21     ` [PATCH net-2.6] net_sched: always clone skbs Changli Gao
2010-12-21  3:55       ` 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=1294003631.2535.253.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hadi@cyberus.ca \
    --cc=hawk@diku.dk \
    --cc=jarkao2@gmail.com \
    --cc=kaber@trash.net \
    --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