From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-03-ewr.dyndns.com (mxout-108-ewr.mailhop.org [216.146.33.108]) by lists.bufferbloat.net (Postfix) with ESMTP id 60EA72E0322 for ; Thu, 24 Mar 2011 06:32:42 -0700 (PDT) Received: from scan-01-ewr.mailhop.org (scanner [10.0.141.223]) by mail-03-ewr.dyndns.com (Postfix) with ESMTP id BDD13788CA4 for ; Thu, 24 Mar 2011 13:32:41 +0000 (UTC) X-Spam-Score: -1.0 (-) X-Mail-Handler: MailHop by DynDNS X-Originating-IP: 209.85.161.43 Received: from mail-fx0-f43.google.com (mail-fx0-f43.google.com [209.85.161.43]) by mail-03-ewr.dyndns.com (Postfix) with ESMTP id 40D26788B63 for ; Thu, 24 Mar 2011 13:32:41 +0000 (UTC) Received: by fxm3 with SMTP id 3so57401fxm.16 for ; Thu, 24 Mar 2011 06:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:cc:in-reply-to:references :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=3DWGGEeWV7pXwN1zUZVsaPigD2BU5moYe1svNNDGXRE=; b=aVp7XutJ4c6BSD8hANbqYTWZHCrc21Zq3Vlm3cI3Jw0XRZOtrgwVGmqm9WlufQLK8l S4rksIadDtum2NEXZm3C9eW9wwdQf9sARUPzSOwl2kgXFiWFW2Qpf8uAU4fTRaydZ3qb IVibZ4E7ZPeJ8/qVn+y1vGyHGqR9llLJqp3k0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=GU6t9kvoq3dU3lUixmAy18gLXIa51qjhRFzczarW5Si2dhfUE+nPmZEMFqh4yjqOHS yILAz6flTdGMxlZYO0mZdClI5IbRK8hdaDZY6UGniydtq8BqifsSXfNG6c0Hxlj4Ck8A 48xBvcb0tHfzOIpjXgfGkw76U3gxoDRfByAig= Received: by 10.223.73.194 with SMTP id r2mr354571faj.108.1300973560582; Thu, 24 Mar 2011 06:32:40 -0700 (PDT) Received: from [10.150.51.210] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id l2sm481653fam.5.2011.03.24.06.32.38 (version=SSLv3 cipher=OTHER); Thu, 24 Mar 2011 06:32:39 -0700 (PDT) From: Eric Dumazet To: Jonathan Morton In-Reply-To: <160809C8-284C-4463-97FE-0E2F03C08589@gmail.com> References: <7imxklz5vu.fsf@lanthane.pps.jussieu.fr> <160809C8-284C-4463-97FE-0E2F03C08589@gmail.com> Content-Type: text/plain; charset="UTF-8" Date: Thu, 24 Mar 2011 14:32:36 +0100 Message-ID: <1300973556.3747.9.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 8bit Cc: bloat@lists.bufferbloat.net Subject: Re: [Bloat] Thoughts on Stochastic Fair Blue X-BeenThere: bloat@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: General list for discussing Bufferbloat List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2011 13:32:42 -0000 Le jeudi 24 mars 2011 à 14:40 +0200, Jonathan Morton a écrit : > Finally, it might also be interesting and useful to add bare-bones ECN > support to the existing "dumb" qdiscs, such as SFQ and the FIFO > family. Simply start marking (and dropping non-supporting flows) when > the queue is more than half full. Three months ago, I played with a SFQ patch to add ECN support, based on delay of packet in queue. http://www.spinics.net/lists/netdev/msg151594.html This patch is a hack of course (units are jiffies ticks, not ms) -------------------------------------- Here is the POC patch I am currently testing, with a probability to "early drop" a packet of one percent per ms (HZ=1000 here), only if packet stayed at least 4 ms on queue. Of course, this only apply where SFQ is used, with known SFQ limits :) The term "early drop" is a lie. RED really early mark/drop a packet at enqueue() time, while I do it at dequeue() time [since I need to compute the delay]. But effect is the same on sent packets. This might use a bit more memory, but no more than current SFQ [and only if flows dont react to mark/drops] insmod net/sched/sch_sfq.ko red_delay=4 By the way, I do think we should lower SFQ_DEPTH a bit and increase SFQ_SLOTS by same amount. Allowing 127 packets per flow seems not necessary in most situations SFQ might be used. net/sched/sch_sfq.c | 37 +++++++++++++++++++++++++++++++++---- 1 files changed, 33 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index d54ac94..4f958e3 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include /* 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 red_delay; /* default : no RED handling */ +module_param(red_delay, int, 0); +MODULE_PARM_DESC(red_delay, "mark/drop packets if they stay in queue longer than red_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 */ @@ -402,11 +409,8 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) q->tail = slot; slot->allot = q->scaled_quantum; } - if (++sch->q.qlen <= q->limit) { - sch->bstats.bytes += qdisc_pkt_len(skb); - sch->bstats.packets++; + if (++sch->q.qlen <= q->limit) return NET_XMIT_SUCCESS; - } sfq_drop(sch); return NET_XMIT_CN; @@ -432,6 +436,7 @@ sfq_dequeue(struct Qdisc *sch) sfq_index a, next_a; struct sfq_slot *slot; +restart: /* No active slots */ if (q->tail == NULL) return NULL; @@ -455,12 +460,36 @@ next_slot: next_a = slot->next; if (a == next_a) { q->tail = NULL; /* no more active slots */ + /* last packet queued, dont even try to apply RED */ return skb; } q->tail->next = next_a; } else { slot->allot -= SFQ_ALLOT_SIZE(qdisc_pkt_len(skb)); } + if (red_delay) { + long delay = jiffies - qdisc_skb_cb(skb)->timestamp; + + if (delay >= red_delay) { + long Px = delay * (0xFFFFFF / 100); /* 1 percent per jiffy */ + if ((net_random() & 0xFFFFFF) < Px) { + if (INET_ECN_set_ce(skb)) { + /* no ecnmark counter yet :) */ + sch->qstats.overlimits++; + } else { + /* penalize this flow : we drop the + * packet while we changed slot->allot + */ + kfree_skb(skb); + /* no early_drop counter yet :) */ + sch->qstats.drops++; + goto restart; + } + } + } + } + sch->bstats.bytes += qdisc_pkt_len(skb); + sch->bstats.packets++; return skb; }