2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* net/sched/sch_sfq.c Stochastic Fairness Queueing discipline.
|
|
|
|
*
|
|
|
|
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/skbuff.h>
|
2019-10-22 14:57:46 +00:00
|
|
|
#include <linux/siphash.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2011-01-20 00:14:58 +00:00
|
|
|
#include <linux/vmalloc.h>
|
2007-07-03 05:49:07 +00:00
|
|
|
#include <net/netlink.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <net/pkt_sched.h>
|
2017-02-09 13:38:56 +00:00
|
|
|
#include <net/pkt_cls.h>
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
#include <net/red.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Stochastic Fairness Queuing algorithm.
|
|
|
|
=======================================
|
|
|
|
|
|
|
|
Source:
|
|
|
|
Paul E. McKenney "Stochastic Fairness Queuing",
|
|
|
|
IEEE INFOCOMM'90 Proceedings, San Francisco, 1990.
|
|
|
|
|
|
|
|
Paul E. McKenney "Stochastic Fairness Queuing",
|
|
|
|
"Interworking: Research and Experience", v.2, 1991, p.113-131.
|
|
|
|
|
|
|
|
|
|
|
|
See also:
|
|
|
|
M. Shreedhar and George Varghese "Efficient Fair
|
|
|
|
Queuing using Deficit Round Robin", Proc. SIGCOMM 95.
|
|
|
|
|
|
|
|
|
2007-02-09 14:25:16 +00:00
|
|
|
This is not the thing that is usually called (W)FQ nowadays.
|
2005-04-16 22:20:36 +00:00
|
|
|
It does not use any timestamp mechanism, but instead
|
|
|
|
processes queues in round-robin order.
|
|
|
|
|
|
|
|
ADVANTAGE:
|
|
|
|
|
|
|
|
- It is very cheap. Both CPU and memory requirements are minimal.
|
|
|
|
|
|
|
|
DRAWBACKS:
|
|
|
|
|
2007-02-09 14:25:16 +00:00
|
|
|
- "Stochastic" -> It is not 100% fair.
|
2005-04-16 22:20:36 +00:00
|
|
|
When hash collisions occur, several flows are considered as one.
|
|
|
|
|
|
|
|
- "Round-robin" -> It introduces larger delays than virtual clock
|
|
|
|
based schemes, and should not be used for isolating interactive
|
|
|
|
traffic from non-interactive. It means, that this scheduler
|
|
|
|
should be used as leaf of CBQ or P3, which put interactive traffic
|
|
|
|
to higher priority band.
|
|
|
|
|
|
|
|
We still need true WFQ for top level CSZ, but using WFQ
|
|
|
|
for the best effort traffic is absolutely pointless:
|
|
|
|
SFQ is superior for this purpose.
|
|
|
|
|
|
|
|
IMPLEMENTATION:
|
2012-01-04 14:18:38 +00:00
|
|
|
This implementation limits :
|
|
|
|
- maximal queue length per flow to 127 packets.
|
|
|
|
- max mtu to 2^18-1;
|
|
|
|
- max 65408 flows,
|
|
|
|
- number of hash buckets to 65536.
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
It is easy to increase these values, but not in flight. */
|
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
#define SFQ_MAX_DEPTH 127 /* max number of packets per flow */
|
|
|
|
#define SFQ_DEFAULT_FLOWS 128
|
|
|
|
#define SFQ_MAX_FLOWS (0x10000 - SFQ_MAX_DEPTH - 1) /* max number of flows */
|
|
|
|
#define SFQ_EMPTY_SLOT 0xffff
|
2011-01-20 00:14:58 +00:00
|
|
|
#define SFQ_DEFAULT_HASH_DIVISOR 1024
|
|
|
|
|
2010-12-28 21:53:33 +00:00
|
|
|
/* We use 16 bits to store allot, and want to handle packets up to 64K
|
|
|
|
* Scale allot by 8 (1<<3) so that no overflow occurs.
|
|
|
|
*/
|
|
|
|
#define SFQ_ALLOT_SHIFT 3
|
|
|
|
#define SFQ_ALLOT_SIZE(X) DIV_ROUND_UP(X, 1 << SFQ_ALLOT_SHIFT)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
/* This type should contain at least SFQ_MAX_DEPTH + 1 + SFQ_MAX_FLOWS values */
|
|
|
|
typedef u16 sfq_index;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
/*
|
|
|
|
* We dont use pointers to save space.
|
2012-01-04 14:18:38 +00:00
|
|
|
* Small indexes [0 ... SFQ_MAX_FLOWS - 1] are 'pointers' to slots[] array
|
|
|
|
* while following values [SFQ_MAX_FLOWS ... SFQ_MAX_FLOWS + SFQ_MAX_DEPTH]
|
2010-12-20 12:54:58 +00:00
|
|
|
* are 'pointers' to dep[] array
|
|
|
|
*/
|
2011-01-19 19:26:56 +00:00
|
|
|
struct sfq_head {
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_index next;
|
|
|
|
sfq_index prev;
|
|
|
|
};
|
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
struct sfq_slot {
|
|
|
|
struct sk_buff *skblist_next;
|
|
|
|
struct sk_buff *skblist_prev;
|
|
|
|
sfq_index qlen; /* number of skbs in skblist */
|
2012-01-04 14:18:38 +00:00
|
|
|
sfq_index next; /* next slot in sfq RR chain */
|
2010-12-20 12:54:58 +00:00
|
|
|
struct sfq_head dep; /* anchor in dep[] chains */
|
|
|
|
unsigned short hash; /* hash value (index in ht[]) */
|
|
|
|
short allot; /* credit for this slot */
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
|
|
|
|
unsigned int backlog;
|
|
|
|
struct red_vars vars;
|
2010-12-20 12:54:58 +00:00
|
|
|
};
|
|
|
|
|
2011-01-19 19:26:56 +00:00
|
|
|
struct sfq_sched_data {
|
2012-01-04 14:18:38 +00:00
|
|
|
/* frequently used fields */
|
|
|
|
int limit; /* limit of total number of packets in this qdisc */
|
2011-01-20 00:14:58 +00:00
|
|
|
unsigned int divisor; /* number of slots in hash table */
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
u8 headdrop;
|
|
|
|
u8 maxdepth; /* limit of packets per flow */
|
2012-01-04 14:18:38 +00:00
|
|
|
|
2019-10-22 14:57:46 +00:00
|
|
|
siphash_key_t perturbation;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
u8 cur_depth; /* depth of longest slot */
|
|
|
|
u8 flags;
|
2010-12-28 21:53:33 +00:00
|
|
|
unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */
|
2014-09-13 03:05:27 +00:00
|
|
|
struct tcf_proto __rcu *filter_list;
|
2017-05-17 09:07:55 +00:00
|
|
|
struct tcf_block *block;
|
2012-01-04 14:18:38 +00:00
|
|
|
sfq_index *ht; /* Hash table ('divisor' slots) */
|
|
|
|
struct sfq_slot *slots; /* Flows table ('maxflows' entries) */
|
|
|
|
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
struct red_parms *red_parms;
|
|
|
|
struct tc_sfqred_stats stats;
|
|
|
|
struct sfq_slot *tail; /* current slot in round */
|
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
struct sfq_head dep[SFQ_MAX_DEPTH + 1];
|
|
|
|
/* Linked lists of slots, indexed by depth
|
|
|
|
* dep[0] : list of unused flows
|
|
|
|
* dep[1] : list of flows with 1 packet
|
|
|
|
* dep[X] : list of flows with X packets
|
|
|
|
*/
|
|
|
|
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
unsigned int maxflows; /* number of flows in flows array */
|
2012-01-04 14:18:38 +00:00
|
|
|
int perturb_period;
|
|
|
|
unsigned int quantum; /* Allotment per round: MUST BE >= MTU */
|
|
|
|
struct timer_list perturb_timer;
|
2017-10-17 00:29:17 +00:00
|
|
|
struct Qdisc *sch;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
/*
|
|
|
|
* sfq_head are either in a sfq_slot or in dep[] array
|
|
|
|
*/
|
|
|
|
static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index val)
|
|
|
|
{
|
2012-01-04 14:18:38 +00:00
|
|
|
if (val < SFQ_MAX_FLOWS)
|
2010-12-20 12:54:58 +00:00
|
|
|
return &q->slots[val].dep;
|
2012-01-04 14:18:38 +00:00
|
|
|
return &q->dep[val - SFQ_MAX_FLOWS];
|
2010-12-20 12:54:58 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 03:40:45 +00:00
|
|
|
static unsigned int sfq_hash(const struct sfq_sched_data *q,
|
|
|
|
const struct sk_buff *skb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2019-10-22 14:57:46 +00:00
|
|
|
return skb_get_hash_perturb(skb, &q->perturbation) & (q->divisor - 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-02-01 02:36:52 +00:00
|
|
|
static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,
|
|
|
|
int *qerr)
|
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
|
|
|
struct tcf_result res;
|
2014-09-13 03:05:27 +00:00
|
|
|
struct tcf_proto *fl;
|
2008-02-01 02:36:52 +00:00
|
|
|
int result;
|
|
|
|
|
|
|
|
if (TC_H_MAJ(skb->priority) == sch->handle &&
|
|
|
|
TC_H_MIN(skb->priority) > 0 &&
|
2011-01-20 00:14:58 +00:00
|
|
|
TC_H_MIN(skb->priority) <= q->divisor)
|
2008-02-01 02:36:52 +00:00
|
|
|
return TC_H_MIN(skb->priority);
|
|
|
|
|
2014-09-13 03:05:27 +00:00
|
|
|
fl = rcu_dereference_bh(q->filter_list);
|
2015-05-01 18:30:16 +00:00
|
|
|
if (!fl)
|
2008-02-01 02:36:52 +00:00
|
|
|
return sfq_hash(q, skb) + 1;
|
|
|
|
|
2008-08-05 05:39:11 +00:00
|
|
|
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
|
2021-07-28 18:08:00 +00:00
|
|
|
result = tcf_classify(skb, NULL, fl, &res, false);
|
2008-02-01 02:36:52 +00:00
|
|
|
if (result >= 0) {
|
|
|
|
#ifdef CONFIG_NET_CLS_ACT
|
|
|
|
switch (result) {
|
|
|
|
case TC_ACT_STOLEN:
|
|
|
|
case TC_ACT_QUEUED:
|
2017-06-06 12:12:02 +00:00
|
|
|
case TC_ACT_TRAP:
|
2008-08-05 05:31:03 +00:00
|
|
|
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
|
2020-07-07 17:21:38 +00:00
|
|
|
fallthrough;
|
2008-02-01 02:36:52 +00:00
|
|
|
case TC_ACT_SHOT:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2011-01-20 00:14:58 +00:00
|
|
|
if (TC_H_MIN(res.classid) <= q->divisor)
|
2008-02-01 02:36:52 +00:00
|
|
|
return TC_H_MIN(res.classid);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
/*
|
2012-01-04 14:18:38 +00:00
|
|
|
* x : slot number [0 .. SFQ_MAX_FLOWS - 1]
|
2010-12-20 12:54:58 +00:00
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline void sfq_link(struct sfq_sched_data *q, sfq_index x)
|
|
|
|
{
|
|
|
|
sfq_index p, n;
|
2012-01-04 14:18:38 +00:00
|
|
|
struct sfq_slot *slot = &q->slots[x];
|
|
|
|
int qlen = slot->qlen;
|
2010-12-20 12:54:58 +00:00
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
p = qlen + SFQ_MAX_FLOWS;
|
2010-12-20 12:54:58 +00:00
|
|
|
n = q->dep[qlen].next;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
slot->dep.next = n;
|
|
|
|
slot->dep.prev = p;
|
2010-12-20 12:54:58 +00:00
|
|
|
|
|
|
|
q->dep[qlen].next = x; /* sfq_dep_head(q, p)->next = x */
|
|
|
|
sfq_dep_head(q, n)->prev = x;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
#define sfq_unlink(q, x, n, p) \
|
2013-12-10 12:55:33 +00:00
|
|
|
do { \
|
|
|
|
n = q->slots[x].dep.next; \
|
|
|
|
p = q->slots[x].dep.prev; \
|
|
|
|
sfq_dep_head(q, p)->next = n; \
|
|
|
|
sfq_dep_head(q, n)->prev = p; \
|
|
|
|
} while (0)
|
2010-12-20 12:54:58 +00:00
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline void sfq_dec(struct sfq_sched_data *q, sfq_index x)
|
|
|
|
{
|
|
|
|
sfq_index p, n;
|
2010-12-20 12:54:58 +00:00
|
|
|
int d;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
sfq_unlink(q, x, n, p);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
d = q->slots[x].qlen--;
|
|
|
|
if (n == p && q->cur_depth == d)
|
|
|
|
q->cur_depth--;
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_link(q, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sfq_inc(struct sfq_sched_data *q, sfq_index x)
|
|
|
|
{
|
|
|
|
sfq_index p, n;
|
|
|
|
int d;
|
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
sfq_unlink(q, x, n, p);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
d = ++q->slots[x].qlen;
|
|
|
|
if (q->cur_depth < d)
|
|
|
|
q->cur_depth = d;
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_link(q, x);
|
|
|
|
}
|
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
/* helper functions : might be changed when/if skb use a standard list_head */
|
|
|
|
|
|
|
|
/* remove one skb from tail of slot queue */
|
|
|
|
static inline struct sk_buff *slot_dequeue_tail(struct sfq_slot *slot)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb = slot->skblist_prev;
|
|
|
|
|
|
|
|
slot->skblist_prev = skb->prev;
|
2010-12-22 19:39:59 +00:00
|
|
|
skb->prev->next = (struct sk_buff *)slot;
|
2010-12-20 12:54:58 +00:00
|
|
|
skb->next = skb->prev = NULL;
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove one skb from head of slot queue */
|
|
|
|
static inline struct sk_buff *slot_dequeue_head(struct sfq_slot *slot)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb = slot->skblist_next;
|
|
|
|
|
|
|
|
slot->skblist_next = skb->next;
|
2010-12-31 20:48:55 +00:00
|
|
|
skb->next->prev = (struct sk_buff *)slot;
|
2010-12-20 12:54:58 +00:00
|
|
|
skb->next = skb->prev = NULL;
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void slot_queue_init(struct sfq_slot *slot)
|
|
|
|
{
|
2012-01-04 14:18:38 +00:00
|
|
|
memset(slot, 0, sizeof(*slot));
|
2010-12-20 12:54:58 +00:00
|
|
|
slot->skblist_prev = slot->skblist_next = (struct sk_buff *)slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add skb to slot queue (tail add) */
|
|
|
|
static inline void slot_queue_add(struct sfq_slot *slot, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
skb->prev = slot->skblist_prev;
|
|
|
|
skb->next = (struct sk_buff *)slot;
|
|
|
|
slot->skblist_prev->next = skb;
|
|
|
|
slot->skblist_prev = skb;
|
|
|
|
}
|
|
|
|
|
2017-08-26 14:58:58 +00:00
|
|
|
static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
2010-12-20 12:54:58 +00:00
|
|
|
sfq_index x, d = q->cur_depth;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sk_buff *skb;
|
|
|
|
unsigned int len;
|
2010-12-20 12:54:58 +00:00
|
|
|
struct sfq_slot *slot;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-12-20 12:54:58 +00:00
|
|
|
/* Queue is full! Find the longest slot and drop tail packet from it */
|
2005-04-16 22:20:36 +00:00
|
|
|
if (d > 1) {
|
2010-12-20 12:54:58 +00:00
|
|
|
x = q->dep[d].next;
|
|
|
|
slot = &q->slots[x];
|
|
|
|
drop:
|
2012-01-04 14:18:38 +00:00
|
|
|
skb = q->headdrop ? slot_dequeue_head(slot) : slot_dequeue_tail(slot);
|
2008-07-20 07:08:27 +00:00
|
|
|
len = qdisc_pkt_len(skb);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
slot->backlog -= len;
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_dec(q, x);
|
|
|
|
sch->q.qlen--;
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_backlog_dec(sch, skb);
|
2017-08-26 14:58:58 +00:00
|
|
|
qdisc_drop(skb, sch, to_free);
|
2005-04-16 22:20:36 +00:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d == 1) {
|
|
|
|
/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
|
2010-12-20 12:54:58 +00:00
|
|
|
x = q->tail->next;
|
|
|
|
slot = &q->slots[x];
|
|
|
|
q->tail->next = slot->next;
|
|
|
|
q->ht[slot->hash] = SFQ_EMPTY_SLOT;
|
|
|
|
goto drop;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
/* Is ECN parameter configured */
|
|
|
|
static int sfq_prob_mark(const struct sfq_sched_data *q)
|
|
|
|
{
|
|
|
|
return q->flags & TC_RED_ECN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Should packets over max threshold just be marked */
|
|
|
|
static int sfq_hard_mark(const struct sfq_sched_data *q)
|
|
|
|
{
|
|
|
|
return (q->flags & (TC_RED_ECN | TC_RED_HARDDROP)) == TC_RED_ECN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sfq_headdrop(const struct sfq_sched_data *q)
|
|
|
|
{
|
|
|
|
return q->headdrop;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int
|
2016-06-22 06:16:49 +00:00
|
|
|
sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
2016-02-25 22:55:01 +00:00
|
|
|
unsigned int hash, dropped;
|
2011-05-23 11:02:42 +00:00
|
|
|
sfq_index x, qlen;
|
2010-12-20 12:54:58 +00:00
|
|
|
struct sfq_slot *slot;
|
treewide: Remove uninitialized_var() usage
Using uninitialized_var() is dangerous as it papers over real bugs[1]
(or can in the future), and suppresses unrelated compiler warnings
(e.g. "unused variable"). If the compiler thinks it is uninitialized,
either simply initialize the variable or make compiler changes.
In preparation for removing[2] the[3] macro[4], remove all remaining
needless uses with the following script:
git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
xargs perl -pi -e \
's/\buninitialized_var\(([^\)]+)\)/\1/g;
s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'
drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
pathological white-space.
No outstanding warnings were found building allmodconfig with GCC 9.3.0
for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
alpha, and m68k.
[1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
[2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
[3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
[4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/
Reviewed-by: Leon Romanovsky <leonro@mellanox.com> # drivers/infiniband and mlx4/mlx5
Acked-by: Jason Gunthorpe <jgg@mellanox.com> # IB
Acked-by: Kalle Valo <kvalo@codeaurora.org> # wireless drivers
Reviewed-by: Chao Yu <yuchao0@huawei.com> # erofs
Signed-off-by: Kees Cook <keescook@chromium.org>
2020-06-03 20:09:38 +00:00
|
|
|
int ret;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
struct sk_buff *head;
|
|
|
|
int delta;
|
2008-02-01 02:36:52 +00:00
|
|
|
|
|
|
|
hash = sfq_classify(skb, sch, &ret);
|
|
|
|
if (hash == 0) {
|
2008-08-05 05:39:11 +00:00
|
|
|
if (ret & __NET_XMIT_BYPASS)
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_drop(sch);
|
2017-08-26 14:58:58 +00:00
|
|
|
__qdisc_drop(skb, to_free);
|
2008-02-01 02:36:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
hash--;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
x = q->ht[hash];
|
2010-12-20 12:54:58 +00:00
|
|
|
slot = &q->slots[x];
|
|
|
|
if (x == SFQ_EMPTY_SLOT) {
|
|
|
|
x = q->dep[0].next; /* get a free slot */
|
2012-01-04 14:18:38 +00:00
|
|
|
if (x >= SFQ_MAX_FLOWS)
|
2016-06-22 06:16:49 +00:00
|
|
|
return qdisc_drop(skb, sch, to_free);
|
2010-12-20 12:54:58 +00:00
|
|
|
q->ht[hash] = x;
|
|
|
|
slot = &q->slots[x];
|
|
|
|
slot->hash = hash;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
slot->backlog = 0; /* should already be 0 anyway... */
|
|
|
|
red_set_vars(&slot->vars);
|
|
|
|
goto enqueue;
|
|
|
|
}
|
|
|
|
if (q->red_parms) {
|
|
|
|
slot->vars.qavg = red_calc_qavg_no_idle_time(q->red_parms,
|
|
|
|
&slot->vars,
|
|
|
|
slot->backlog);
|
|
|
|
switch (red_action(q->red_parms,
|
|
|
|
&slot->vars,
|
|
|
|
slot->vars.qavg)) {
|
|
|
|
case RED_DONT_MARK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RED_PROB_MARK:
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_overlimit(sch);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
if (sfq_prob_mark(q)) {
|
|
|
|
/* We know we have at least one packet in queue */
|
|
|
|
if (sfq_headdrop(q) &&
|
|
|
|
INET_ECN_set_ce(slot->skblist_next)) {
|
|
|
|
q->stats.prob_mark_head++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (INET_ECN_set_ce(skb)) {
|
|
|
|
q->stats.prob_mark++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
q->stats.prob_drop++;
|
|
|
|
goto congestion_drop;
|
|
|
|
|
|
|
|
case RED_HARD_MARK:
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_overlimit(sch);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
if (sfq_hard_mark(q)) {
|
|
|
|
/* We know we have at least one packet in queue */
|
|
|
|
if (sfq_headdrop(q) &&
|
|
|
|
INET_ECN_set_ce(slot->skblist_next)) {
|
|
|
|
q->stats.forced_mark_head++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (INET_ECN_set_ce(skb)) {
|
|
|
|
q->stats.forced_mark++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
q->stats.forced_drop++;
|
|
|
|
goto congestion_drop;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-01-21 01:20:56 +00:00
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
if (slot->qlen >= q->maxdepth) {
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
congestion_drop:
|
|
|
|
if (!sfq_headdrop(q))
|
2016-06-22 06:16:49 +00:00
|
|
|
return qdisc_drop(skb, sch, to_free);
|
2012-01-04 14:18:38 +00:00
|
|
|
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
/* We know we have at least one packet in queue */
|
2012-01-04 14:18:38 +00:00
|
|
|
head = slot_dequeue_head(slot);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
delta = qdisc_pkt_len(head) - qdisc_pkt_len(skb);
|
|
|
|
sch->qstats.backlog -= delta;
|
|
|
|
slot->backlog -= delta;
|
2016-06-22 06:16:49 +00:00
|
|
|
qdisc_drop(head, sch, to_free);
|
2012-01-04 14:18:38 +00:00
|
|
|
|
|
|
|
slot_queue_add(slot, skb);
|
2017-08-15 13:37:04 +00:00
|
|
|
qdisc_tree_reduce_backlog(sch, 0, delta);
|
2012-01-04 14:18:38 +00:00
|
|
|
return NET_XMIT_CN;
|
|
|
|
}
|
2007-10-01 00:51:33 +00:00
|
|
|
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
enqueue:
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_backlog_inc(sch, skb);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
slot->backlog += qdisc_pkt_len(skb);
|
2010-12-20 12:54:58 +00:00
|
|
|
slot_queue_add(slot, skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_inc(q, x);
|
2010-12-20 12:54:58 +00:00
|
|
|
if (slot->qlen == 1) { /* The flow is new */
|
|
|
|
if (q->tail == NULL) { /* It is the first flow */
|
|
|
|
slot->next = x;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2010-12-20 12:54:58 +00:00
|
|
|
slot->next = q->tail->next;
|
|
|
|
q->tail->next = x;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-03-13 18:04:25 +00:00
|
|
|
/* We put this flow at the end of our flow list.
|
|
|
|
* This might sound unfair for a new flow to wait after old ones,
|
|
|
|
* but we could endup servicing new flows only, and freeze old ones.
|
|
|
|
*/
|
|
|
|
q->tail = slot;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
/* We could use a bigger initial quantum for new flows */
|
2010-12-28 21:53:33 +00:00
|
|
|
slot->allot = q->scaled_quantum;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2011-01-21 07:31:33 +00:00
|
|
|
if (++sch->q.qlen <= q->limit)
|
2010-08-10 08:45:40 +00:00
|
|
|
return NET_XMIT_SUCCESS;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-05-23 11:02:42 +00:00
|
|
|
qlen = slot->qlen;
|
2017-08-26 14:58:58 +00:00
|
|
|
dropped = sfq_drop(sch, to_free);
|
2011-05-23 11:02:42 +00:00
|
|
|
/* Return Congestion Notification only if we dropped a packet
|
|
|
|
* from this flow.
|
|
|
|
*/
|
2017-08-15 13:37:04 +00:00
|
|
|
if (qlen != slot->qlen) {
|
|
|
|
qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb));
|
2011-07-29 19:22:42 +00:00
|
|
|
return NET_XMIT_CN;
|
2017-08-15 13:37:04 +00:00
|
|
|
}
|
2011-07-29 19:22:42 +00:00
|
|
|
|
|
|
|
/* As we dropped a packet, better let upper stack know this */
|
2016-02-25 22:55:01 +00:00
|
|
|
qdisc_tree_reduce_backlog(sch, 1, dropped);
|
2011-07-29 19:22:42 +00:00
|
|
|
return NET_XMIT_SUCCESS;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct sk_buff *
|
2008-01-21 01:20:56 +00:00
|
|
|
sfq_dequeue(struct Qdisc *sch)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
|
|
|
struct sk_buff *skb;
|
net_sched: sch_sfq: fix allot handling
When deploying SFQ/IFB here at work, I found the allot management was
pretty wrong in sfq, even changing allot from short to int...
We should init allot for each new flow, not using a previous value found
in slot.
Before patch, I saw bursts of several packets per flow, apparently
denying the default "quantum 1514" limit I had on my SFQ class.
class sfq 11:1 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 7p requeues 0
allot 11546
class sfq 11:46 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 1p requeues 0
allot -23873
class sfq 11:78 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 5p requeues 0
allot 11393
After patch, better fairness among each flow, allot limit being
respected, allot is positive :
class sfq 11:e parent 11:
(dropped 0, overlimits 0 requeues 86)
backlog 0b 3p requeues 86
allot 596
class sfq 11:94 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 3p requeues 0
allot 1468
class sfq 11:a4 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 4p requeues 0
allot 650
class sfq 11:bb parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 3p requeues 0
allot 596
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-20 21:18:16 +00:00
|
|
|
sfq_index a, next_a;
|
2010-12-20 12:54:58 +00:00
|
|
|
struct sfq_slot *slot;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* No active slots */
|
2010-12-20 12:54:58 +00:00
|
|
|
if (q->tail == NULL)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
|
2010-12-28 21:53:33 +00:00
|
|
|
next_slot:
|
2010-12-20 12:54:58 +00:00
|
|
|
a = q->tail->next;
|
|
|
|
slot = &q->slots[a];
|
2010-12-28 21:53:33 +00:00
|
|
|
if (slot->allot <= 0) {
|
|
|
|
q->tail = slot;
|
|
|
|
slot->allot += q->scaled_quantum;
|
|
|
|
goto next_slot;
|
|
|
|
}
|
2010-12-20 12:54:58 +00:00
|
|
|
skb = slot_dequeue_head(slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_dec(q, a);
|
2011-01-21 07:31:33 +00:00
|
|
|
qdisc_bstats_update(sch, skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
sch->q.qlen--;
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_backlog_dec(sch, skb);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
slot->backlog -= qdisc_pkt_len(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Is the slot empty? */
|
2010-12-20 12:54:58 +00:00
|
|
|
if (slot->qlen == 0) {
|
|
|
|
q->ht[slot->hash] = SFQ_EMPTY_SLOT;
|
|
|
|
next_a = slot->next;
|
net_sched: sch_sfq: fix allot handling
When deploying SFQ/IFB here at work, I found the allot management was
pretty wrong in sfq, even changing allot from short to int...
We should init allot for each new flow, not using a previous value found
in slot.
Before patch, I saw bursts of several packets per flow, apparently
denying the default "quantum 1514" limit I had on my SFQ class.
class sfq 11:1 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 7p requeues 0
allot 11546
class sfq 11:46 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 1p requeues 0
allot -23873
class sfq 11:78 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 5p requeues 0
allot 11393
After patch, better fairness among each flow, allot limit being
respected, allot is positive :
class sfq 11:e parent 11:
(dropped 0, overlimits 0 requeues 86)
backlog 0b 3p requeues 86
allot 596
class sfq 11:94 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 3p requeues 0
allot 1468
class sfq 11:a4 parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 4p requeues 0
allot 650
class sfq 11:bb parent 11:
(dropped 0, overlimits 0 requeues 0)
backlog 0b 3p requeues 0
allot 596
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-20 21:18:16 +00:00
|
|
|
if (a == next_a) {
|
2010-12-20 12:54:58 +00:00
|
|
|
q->tail = NULL; /* no more active slots */
|
2005-04-16 22:20:36 +00:00
|
|
|
return skb;
|
|
|
|
}
|
2010-12-20 12:54:58 +00:00
|
|
|
q->tail->next = next_a;
|
2010-12-28 21:53:33 +00:00
|
|
|
} else {
|
|
|
|
slot->allot -= SFQ_ALLOT_SIZE(qdisc_pkt_len(skb));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-01-21 01:20:56 +00:00
|
|
|
sfq_reset(struct Qdisc *sch)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
while ((skb = sfq_dequeue(sch)) != NULL)
|
2016-06-14 03:21:59 +00:00
|
|
|
rtnl_kfree_skbs(skb, skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-12-21 03:30:11 +00:00
|
|
|
/*
|
|
|
|
* When q->perturbation is changed, we rehash all queued skbs
|
|
|
|
* to avoid OOO (Out Of Order) effects.
|
|
|
|
* We dont use sfq_dequeue()/sfq_enqueue() because we dont want to change
|
|
|
|
* counters.
|
|
|
|
*/
|
2012-01-04 14:18:38 +00:00
|
|
|
static void sfq_rehash(struct Qdisc *sch)
|
2011-12-21 03:30:11 +00:00
|
|
|
{
|
2012-01-04 14:18:38 +00:00
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
2011-12-21 03:30:11 +00:00
|
|
|
struct sk_buff *skb;
|
|
|
|
int i;
|
|
|
|
struct sfq_slot *slot;
|
|
|
|
struct sk_buff_head list;
|
2012-01-04 14:18:38 +00:00
|
|
|
int dropped = 0;
|
2016-02-25 22:55:01 +00:00
|
|
|
unsigned int drop_len = 0;
|
2011-12-21 03:30:11 +00:00
|
|
|
|
|
|
|
__skb_queue_head_init(&list);
|
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
for (i = 0; i < q->maxflows; i++) {
|
2011-12-21 03:30:11 +00:00
|
|
|
slot = &q->slots[i];
|
|
|
|
if (!slot->qlen)
|
|
|
|
continue;
|
|
|
|
while (slot->qlen) {
|
|
|
|
skb = slot_dequeue_head(slot);
|
|
|
|
sfq_dec(q, i);
|
|
|
|
__skb_queue_tail(&list, skb);
|
|
|
|
}
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
slot->backlog = 0;
|
|
|
|
red_set_vars(&slot->vars);
|
2011-12-21 03:30:11 +00:00
|
|
|
q->ht[slot->hash] = SFQ_EMPTY_SLOT;
|
|
|
|
}
|
|
|
|
q->tail = NULL;
|
|
|
|
|
|
|
|
while ((skb = __skb_dequeue(&list)) != NULL) {
|
|
|
|
unsigned int hash = sfq_hash(q, skb);
|
|
|
|
sfq_index x = q->ht[hash];
|
|
|
|
|
|
|
|
slot = &q->slots[x];
|
|
|
|
if (x == SFQ_EMPTY_SLOT) {
|
|
|
|
x = q->dep[0].next; /* get a free slot */
|
2012-01-04 14:18:38 +00:00
|
|
|
if (x >= SFQ_MAX_FLOWS) {
|
2014-09-28 18:53:29 +00:00
|
|
|
drop:
|
|
|
|
qdisc_qstats_backlog_dec(sch, skb);
|
2016-02-25 22:55:01 +00:00
|
|
|
drop_len += qdisc_pkt_len(skb);
|
2012-01-04 14:18:38 +00:00
|
|
|
kfree_skb(skb);
|
|
|
|
dropped++;
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-21 03:30:11 +00:00
|
|
|
q->ht[hash] = x;
|
|
|
|
slot = &q->slots[x];
|
|
|
|
slot->hash = hash;
|
|
|
|
}
|
2012-01-04 14:18:38 +00:00
|
|
|
if (slot->qlen >= q->maxdepth)
|
|
|
|
goto drop;
|
2011-12-21 03:30:11 +00:00
|
|
|
slot_queue_add(slot, skb);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
if (q->red_parms)
|
|
|
|
slot->vars.qavg = red_calc_qavg(q->red_parms,
|
|
|
|
&slot->vars,
|
|
|
|
slot->backlog);
|
|
|
|
slot->backlog += qdisc_pkt_len(skb);
|
2011-12-21 03:30:11 +00:00
|
|
|
sfq_inc(q, x);
|
|
|
|
if (slot->qlen == 1) { /* The flow is new */
|
|
|
|
if (q->tail == NULL) { /* It is the first flow */
|
|
|
|
slot->next = x;
|
|
|
|
} else {
|
|
|
|
slot->next = q->tail->next;
|
|
|
|
q->tail->next = x;
|
|
|
|
}
|
|
|
|
q->tail = slot;
|
|
|
|
slot->allot = q->scaled_quantum;
|
|
|
|
}
|
|
|
|
}
|
2012-01-04 14:18:38 +00:00
|
|
|
sch->q.qlen -= dropped;
|
2016-02-25 22:55:01 +00:00
|
|
|
qdisc_tree_reduce_backlog(sch, dropped, drop_len);
|
2011-12-21 03:30:11 +00:00
|
|
|
}
|
|
|
|
|
2017-10-17 00:29:17 +00:00
|
|
|
static void sfq_perturbation(struct timer_list *t)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-10-17 00:29:17 +00:00
|
|
|
struct sfq_sched_data *q = from_timer(q, t, perturb_timer);
|
|
|
|
struct Qdisc *sch = q->sch;
|
2011-12-21 03:30:11 +00:00
|
|
|
spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch));
|
2019-10-22 14:57:46 +00:00
|
|
|
siphash_key_t nkey;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-10-22 14:57:46 +00:00
|
|
|
get_random_bytes(&nkey, sizeof(nkey));
|
2011-12-21 03:30:11 +00:00
|
|
|
spin_lock(root_lock);
|
2019-10-22 14:57:46 +00:00
|
|
|
q->perturbation = nkey;
|
2011-12-21 03:30:11 +00:00
|
|
|
if (!q->filter_list && q->tail)
|
2012-01-04 14:18:38 +00:00
|
|
|
sfq_rehash(sch);
|
2011-12-21 03:30:11 +00:00
|
|
|
spin_unlock(root_lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-01 00:51:33 +00:00
|
|
|
if (q->perturb_period)
|
|
|
|
mod_timer(&q->perturb_timer, jiffies + q->perturb_period);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-23 06:11:17 +00:00
|
|
|
static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
2008-01-23 06:11:17 +00:00
|
|
|
struct tc_sfq_qopt *ctl = nla_data(opt);
|
2012-01-04 14:18:38 +00:00
|
|
|
struct tc_sfq_qopt_v1 *ctl_v1 = NULL;
|
2016-02-25 22:55:01 +00:00
|
|
|
unsigned int qlen, dropped = 0;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
struct red_parms *p = NULL;
|
2017-08-26 14:58:58 +00:00
|
|
|
struct sk_buff *to_free = NULL;
|
|
|
|
struct sk_buff *tail = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-01-23 06:11:17 +00:00
|
|
|
if (opt->nla_len < nla_attr_size(sizeof(*ctl)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
2012-01-04 14:18:38 +00:00
|
|
|
if (opt->nla_len >= nla_attr_size(sizeof(*ctl_v1)))
|
|
|
|
ctl_v1 = nla_data(opt);
|
2011-02-02 15:19:51 +00:00
|
|
|
if (ctl->divisor &&
|
|
|
|
(!is_power_of_2(ctl->divisor) || ctl->divisor > 65536))
|
|
|
|
return -EINVAL;
|
2020-04-27 01:19:07 +00:00
|
|
|
|
|
|
|
/* slot->allot is a short, make sure quantum is not too big. */
|
|
|
|
if (ctl->quantum) {
|
|
|
|
unsigned int scaled = SFQ_ALLOT_SIZE(ctl->quantum);
|
|
|
|
|
|
|
|
if (scaled <= 0 || scaled > SHRT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-12-04 11:31:11 +00:00
|
|
|
if (ctl_v1 && !red_check_params(ctl_v1->qth_min, ctl_v1->qth_max,
|
2021-03-10 16:26:41 +00:00
|
|
|
ctl_v1->Wlog, ctl_v1->Scell_log, NULL))
|
2017-12-04 11:31:11 +00:00
|
|
|
return -EINVAL;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
if (ctl_v1 && ctl_v1->qth_min) {
|
|
|
|
p = kmalloc(sizeof(*p), GFP_KERNEL);
|
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
sch_tree_lock(sch);
|
2012-01-04 14:18:38 +00:00
|
|
|
if (ctl->quantum) {
|
|
|
|
q->quantum = ctl->quantum;
|
|
|
|
q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum);
|
|
|
|
}
|
2008-01-21 01:20:56 +00:00
|
|
|
q->perturb_period = ctl->perturb_period * HZ;
|
2012-01-04 14:18:38 +00:00
|
|
|
if (ctl->flows)
|
|
|
|
q->maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS);
|
|
|
|
if (ctl->divisor) {
|
2011-01-20 00:14:58 +00:00
|
|
|
q->divisor = ctl->divisor;
|
2012-01-04 14:18:38 +00:00
|
|
|
q->maxflows = min_t(u32, q->maxflows, q->divisor);
|
|
|
|
}
|
|
|
|
if (ctl_v1) {
|
|
|
|
if (ctl_v1->depth)
|
|
|
|
q->maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
if (p) {
|
|
|
|
swap(q->red_parms, p);
|
|
|
|
red_set_parms(q->red_parms,
|
|
|
|
ctl_v1->qth_min, ctl_v1->qth_max,
|
|
|
|
ctl_v1->Wlog,
|
|
|
|
ctl_v1->Plog, ctl_v1->Scell_log,
|
|
|
|
NULL,
|
|
|
|
ctl_v1->max_P);
|
|
|
|
}
|
|
|
|
q->flags = ctl_v1->flags;
|
2012-01-04 14:18:38 +00:00
|
|
|
q->headdrop = ctl_v1->headdrop;
|
|
|
|
}
|
|
|
|
if (ctl->limit) {
|
|
|
|
q->limit = min_t(u32, ctl->limit, q->maxdepth * q->maxflows);
|
|
|
|
q->maxflows = min_t(u32, q->maxflows, q->limit);
|
|
|
|
}
|
|
|
|
|
2006-11-30 01:36:20 +00:00
|
|
|
qlen = sch->q.qlen;
|
2017-08-26 14:58:58 +00:00
|
|
|
while (sch->q.qlen > q->limit) {
|
|
|
|
dropped += sfq_drop(sch, &to_free);
|
|
|
|
if (!tail)
|
|
|
|
tail = to_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtnl_kfree_skbs(to_free, tail);
|
2016-02-25 22:55:01 +00:00
|
|
|
qdisc_tree_reduce_backlog(sch, qlen - sch->q.qlen, dropped);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
del_timer(&q->perturb_timer);
|
|
|
|
if (q->perturb_period) {
|
2007-10-01 00:51:33 +00:00
|
|
|
mod_timer(&q->perturb_timer, jiffies + q->perturb_period);
|
2019-10-22 14:57:46 +00:00
|
|
|
get_random_bytes(&q->perturbation, sizeof(q->perturbation));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
sch_tree_unlock(sch);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
kfree(p);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-04 06:22:24 +00:00
|
|
|
static void *sfq_alloc(size_t sz)
|
|
|
|
{
|
2017-05-08 22:57:27 +00:00
|
|
|
return kvmalloc(sz, GFP_KERNEL);
|
2012-01-04 06:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sfq_free(void *addr)
|
|
|
|
{
|
2014-06-02 22:55:22 +00:00
|
|
|
kvfree(addr);
|
2012-01-04 06:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sfq_destroy(struct Qdisc *sch)
|
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
|
|
|
|
2017-05-17 09:07:55 +00:00
|
|
|
tcf_block_put(q->block);
|
2012-01-04 06:22:24 +00:00
|
|
|
q->perturb_period = 0;
|
|
|
|
del_timer_sync(&q->perturb_timer);
|
|
|
|
sfq_free(q->ht);
|
2012-01-04 14:18:38 +00:00
|
|
|
sfq_free(q->slots);
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
kfree(q->red_parms);
|
2012-01-04 06:22:24 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 17:35:13 +00:00
|
|
|
static int sfq_init(struct Qdisc *sch, struct nlattr *opt,
|
|
|
|
struct netlink_ext_ack *extack)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
|
|
|
int i;
|
2017-05-17 09:07:55 +00:00
|
|
|
int err;
|
|
|
|
|
2017-11-28 13:28:39 +00:00
|
|
|
q->sch = sch;
|
2017-10-17 00:29:17 +00:00
|
|
|
timer_setup(&q->perturb_timer, sfq_perturbation, TIMER_DEFERRABLE);
|
2017-08-30 09:49:04 +00:00
|
|
|
|
2017-12-20 17:35:19 +00:00
|
|
|
err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
|
2017-05-17 09:07:55 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
for (i = 0; i < SFQ_MAX_DEPTH + 1; i++) {
|
|
|
|
q->dep[i].next = i + SFQ_MAX_FLOWS;
|
|
|
|
q->dep[i].prev = i + SFQ_MAX_FLOWS;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-01-21 01:20:56 +00:00
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
q->limit = SFQ_MAX_DEPTH;
|
|
|
|
q->maxdepth = SFQ_MAX_DEPTH;
|
2010-12-20 12:54:58 +00:00
|
|
|
q->cur_depth = 0;
|
|
|
|
q->tail = NULL;
|
2011-01-20 00:14:58 +00:00
|
|
|
q->divisor = SFQ_DEFAULT_HASH_DIVISOR;
|
2012-01-04 14:18:38 +00:00
|
|
|
q->maxflows = SFQ_DEFAULT_FLOWS;
|
2012-01-04 06:23:01 +00:00
|
|
|
q->quantum = psched_mtu(qdisc_dev(sch));
|
|
|
|
q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum);
|
|
|
|
q->perturb_period = 0;
|
2019-10-22 14:57:46 +00:00
|
|
|
get_random_bytes(&q->perturbation, sizeof(q->perturbation));
|
2012-01-04 06:23:01 +00:00
|
|
|
|
|
|
|
if (opt) {
|
2005-04-16 22:20:36 +00:00
|
|
|
int err = sfq_change(sch, opt);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
2008-01-21 01:20:56 +00:00
|
|
|
|
2012-01-04 06:22:24 +00:00
|
|
|
q->ht = sfq_alloc(sizeof(q->ht[0]) * q->divisor);
|
2012-01-04 14:18:38 +00:00
|
|
|
q->slots = sfq_alloc(sizeof(q->slots[0]) * q->maxflows);
|
|
|
|
if (!q->ht || !q->slots) {
|
2017-02-10 18:31:49 +00:00
|
|
|
/* Note: sfq_destroy() will be called by our caller */
|
2011-01-20 00:14:58 +00:00
|
|
|
return -ENOMEM;
|
2012-01-04 06:22:24 +00:00
|
|
|
}
|
2017-02-10 18:31:49 +00:00
|
|
|
|
2011-01-20 00:14:58 +00:00
|
|
|
for (i = 0; i < q->divisor; i++)
|
|
|
|
q->ht[i] = SFQ_EMPTY_SLOT;
|
|
|
|
|
2012-01-04 14:18:38 +00:00
|
|
|
for (i = 0; i < q->maxflows; i++) {
|
2010-12-31 20:48:55 +00:00
|
|
|
slot_queue_init(&q->slots[i]);
|
2005-04-16 22:20:36 +00:00
|
|
|
sfq_link(q, i);
|
2010-12-31 20:48:55 +00:00
|
|
|
}
|
2011-01-22 00:26:09 +00:00
|
|
|
if (q->limit >= 1)
|
|
|
|
sch->flags |= TCQ_F_CAN_BYPASS;
|
|
|
|
else
|
|
|
|
sch->flags &= ~TCQ_F_CAN_BYPASS;
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
2007-04-20 03:29:13 +00:00
|
|
|
unsigned char *b = skb_tail_pointer(skb);
|
2012-01-04 14:18:38 +00:00
|
|
|
struct tc_sfq_qopt_v1 opt;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
struct red_parms *p = q->red_parms;
|
2012-01-04 14:18:38 +00:00
|
|
|
|
|
|
|
memset(&opt, 0, sizeof(opt));
|
|
|
|
opt.v0.quantum = q->quantum;
|
|
|
|
opt.v0.perturb_period = q->perturb_period / HZ;
|
|
|
|
opt.v0.limit = q->limit;
|
|
|
|
opt.v0.divisor = q->divisor;
|
|
|
|
opt.v0.flows = q->maxflows;
|
|
|
|
opt.depth = q->maxdepth;
|
|
|
|
opt.headdrop = q->headdrop;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
if (p) {
|
|
|
|
opt.qth_min = p->qth_min >> p->Wlog;
|
|
|
|
opt.qth_max = p->qth_max >> p->Wlog;
|
|
|
|
opt.Wlog = p->Wlog;
|
|
|
|
opt.Plog = p->Plog;
|
|
|
|
opt.Scell_log = p->Scell_log;
|
|
|
|
opt.max_P = p->max_P;
|
|
|
|
}
|
|
|
|
memcpy(&opt.stats, &q->stats, sizeof(opt.stats));
|
|
|
|
opt.flags = q->flags;
|
|
|
|
|
2012-03-29 09:11:39 +00:00
|
|
|
if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
|
|
|
|
goto nla_put_failure;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
|
2008-01-23 06:11:17 +00:00
|
|
|
nla_put_failure:
|
2007-03-26 06:06:12 +00:00
|
|
|
nlmsg_trim(skb, b);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-08-10 22:31:02 +00:00
|
|
|
static struct Qdisc *sfq_leaf(struct Qdisc *sch, unsigned long arg)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
static unsigned long sfq_find(struct Qdisc *sch, u32 classid)
|
2008-02-01 02:36:52 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-06 00:22:35 +00:00
|
|
|
static unsigned long sfq_bind(struct Qdisc *sch, unsigned long parent,
|
|
|
|
u32 classid)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
static void sfq_unbind(struct Qdisc *q, unsigned long cl)
|
2010-08-09 12:18:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-12-20 17:35:16 +00:00
|
|
|
static struct tcf_block *sfq_tcf_block(struct Qdisc *sch, unsigned long cl,
|
|
|
|
struct netlink_ext_ack *extack)
|
2008-02-01 02:36:52 +00:00
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
|
|
|
|
|
|
|
if (cl)
|
|
|
|
return NULL;
|
2017-05-17 09:07:55 +00:00
|
|
|
return q->block;
|
2008-02-01 02:36:52 +00:00
|
|
|
}
|
|
|
|
|
2008-02-01 02:37:16 +00:00
|
|
|
static int sfq_dump_class(struct Qdisc *sch, unsigned long cl,
|
|
|
|
struct sk_buff *skb, struct tcmsg *tcm)
|
|
|
|
{
|
|
|
|
tcm->tcm_handle |= TC_H_MIN(cl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sfq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
|
|
|
|
struct gnet_dump *d)
|
|
|
|
{
|
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
2010-12-22 19:39:59 +00:00
|
|
|
sfq_index idx = q->ht[cl - 1];
|
|
|
|
struct gnet_stats_queue qs = { 0 };
|
|
|
|
struct tc_sfq_xstats xstats = { 0 };
|
2010-12-15 08:18:36 +00:00
|
|
|
|
2010-12-22 19:39:59 +00:00
|
|
|
if (idx != SFQ_EMPTY_SLOT) {
|
|
|
|
const struct sfq_slot *slot = &q->slots[idx];
|
2008-02-01 02:37:16 +00:00
|
|
|
|
2010-12-28 21:53:33 +00:00
|
|
|
xstats.allot = slot->allot << SFQ_ALLOT_SHIFT;
|
2010-12-22 19:39:59 +00:00
|
|
|
qs.qlen = slot->qlen;
|
net_sched: sfq: add optional RED on top of SFQ
Adds an optional Random Early Detection on each SFQ flow queue.
Traditional SFQ limits count of packets, while RED permits to also
control number of bytes per flow, and adds ECN capability as well.
1) We dont handle the idle time management in this RED implementation,
since each 'new flow' begins with a null qavg. We really want to address
backlogged flows.
2) if headdrop is selected, we try to ecn mark first packet instead of
currently enqueued packet. This gives faster feedback for tcp flows
compared to traditional RED [ marking the last packet in queue ]
Example of use :
tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 4sec sfq \
limit 3000 headdrop flows 512 divisor 16384 \
redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
ewma 6 min 8000b max 60000b probability 0.2 ecn
prob_mark 0 prob_mark_head 4876 prob_drop 6131
forced_mark 0 forced_mark_head 0 forced_drop 0
Sent 1175211782 bytes 777537 pkt (dropped 6131, overlimits 11007
requeues 0)
rate 99483Kbit 8219pps backlog 689392b 456p requeues 0
In this test, with 64 netperf TCP_STREAM sessions, 50% using ECN enabled
flows, we can see number of packets CE marked is smaller than number of
drops (for non ECN flows)
If same test is run, without RED, we can check backlog is much bigger.
qdisc sfq 10: parent 1:1 limit 3000p quantum 1514b depth 127 headdrop
flows 512/16384 divisor 16384
Sent 1148683617 bytes 795006 pkt (dropped 0, overlimits 0 requeues 0)
rate 98429Kbit 8521pps backlog 1221290b 841p requeues 0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Dave Taht <dave.taht@gmail.com>
Tested-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-06 06:31:44 +00:00
|
|
|
qs.backlog = slot->backlog;
|
2010-12-22 19:39:59 +00:00
|
|
|
}
|
2014-09-28 18:54:24 +00:00
|
|
|
if (gnet_stats_copy_queue(d, NULL, &qs, qs.qlen) < 0)
|
2008-02-01 02:37:16 +00:00
|
|
|
return -1;
|
|
|
|
return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
|
|
|
|
}
|
|
|
|
|
2008-02-01 02:36:52 +00:00
|
|
|
static void sfq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
|
|
|
|
{
|
2008-02-01 02:37:16 +00:00
|
|
|
struct sfq_sched_data *q = qdisc_priv(sch);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (arg->stop)
|
|
|
|
return;
|
|
|
|
|
2011-01-20 00:14:58 +00:00
|
|
|
for (i = 0; i < q->divisor; i++) {
|
2022-09-21 02:41:18 +00:00
|
|
|
if (q->ht[i] == SFQ_EMPTY_SLOT) {
|
2008-02-01 02:37:16 +00:00
|
|
|
arg->count++;
|
|
|
|
continue;
|
|
|
|
}
|
2022-09-21 02:41:18 +00:00
|
|
|
if (!tc_qdisc_stats_dump(sch, i + 1, arg))
|
2008-02-01 02:37:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-02-01 02:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct Qdisc_class_ops sfq_class_ops = {
|
2010-08-10 22:31:02 +00:00
|
|
|
.leaf = sfq_leaf,
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
.find = sfq_find,
|
2017-05-17 09:07:55 +00:00
|
|
|
.tcf_block = sfq_tcf_block,
|
2010-08-06 00:22:35 +00:00
|
|
|
.bind_tcf = sfq_bind,
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
.unbind_tcf = sfq_unbind,
|
2008-02-01 02:37:16 +00:00
|
|
|
.dump = sfq_dump_class,
|
|
|
|
.dump_stats = sfq_dump_class_stats,
|
2008-02-01 02:36:52 +00:00
|
|
|
.walk = sfq_walk,
|
|
|
|
};
|
|
|
|
|
2007-11-14 09:44:41 +00:00
|
|
|
static struct Qdisc_ops sfq_qdisc_ops __read_mostly = {
|
2008-02-01 02:36:52 +00:00
|
|
|
.cl_ops = &sfq_class_ops,
|
2005-04-16 22:20:36 +00:00
|
|
|
.id = "sfq",
|
|
|
|
.priv_size = sizeof(struct sfq_sched_data),
|
|
|
|
.enqueue = sfq_enqueue,
|
|
|
|
.dequeue = sfq_dequeue,
|
2011-05-25 04:40:11 +00:00
|
|
|
.peek = qdisc_peek_dequeued,
|
2005-04-16 22:20:36 +00:00
|
|
|
.init = sfq_init,
|
|
|
|
.reset = sfq_reset,
|
|
|
|
.destroy = sfq_destroy,
|
|
|
|
.change = NULL,
|
|
|
|
.dump = sfq_dump,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init sfq_module_init(void)
|
|
|
|
{
|
|
|
|
return register_qdisc(&sfq_qdisc_ops);
|
|
|
|
}
|
2007-02-09 14:25:16 +00:00
|
|
|
static void __exit sfq_module_exit(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unregister_qdisc(&sfq_qdisc_ops);
|
|
|
|
}
|
|
|
|
module_init(sfq_module_init)
|
|
|
|
module_exit(sfq_module_exit)
|
|
|
|
MODULE_LICENSE("GPL");
|