Skip to contentSkip to conversation

net: pkt_sched: PIE AQM scheme

PATCH Superseded Vijay Subramanian 3 participants 4 messages Sep 28, 2013 – Sep 30, 2013

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: pkt_sched: PIE AQM scheme

From: Vijay Subramanian <[email protected]>

Proportional Integral controller Enhanced (PIE) is a scheduler to address the bufferbloat problem.

Quoted 1 line

From the IETF draft below:

" Bufferbloat is a phenomenon where excess buffers in the network cause high latency and jitter. As more and more interactive applications (e.g. voice over IP, real time video streaming and financial transactions) run in the Internet, high latency and jitter degrade application performance. There is a pressing need to design intelligent queue management schemes that can control latency and jitter; and hence provide desirable quality of service to users.

We present here a lightweight design, PIE(Proportional Integral controller Enhanced) that can effectively control the average queueing latency to a target value. Simulation results, theoretical analysis and Linux testbed results have shown that PIE can ensure low latency and achieve high link utilization under various congestion situations. The design does not require per-packet timestamp, so it incurs very small overhead and is simple enough to implement in both hardware and software. "

Many thanks to Dave Taht for extensive feedback, reviews, testing and suggestions. Thanks also to Stephen Hemminger for initial review and suggestion
to use psched and friends. Naeem Khademi and Dave Taht independently
contributed to ECN support.

For more information, please see technical paper about PIE in the IEEE Conference on High Performance Switching and Routing 2013. A copy of the paper can be found at ftp://ftpeng.cisco.com/pie/.

Please also refer to the IETF draft submission at
http://tools.ietf.org/html/draft-pan-tsvwg-pie-00

All relevant code, documents and test scripts and results can be found at ftp://ftpeng.cisco.com/pie/.

For problems with the iproute2/tc or Linux kernel code, please contact Vijay Subramanian ([email protected] or [email protected]) Mythili Prabhu ([email protected])

---
 include/uapi/linux/pkt_sched.h |   26 ++
 net/sched/Kconfig              |   11 +
 net/sched/Makefile             |    1 +
 net/sched/sch_pie.c            |  623 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 661 insertions(+)
 create mode 100644 net/sched/sch_pie.c
include/uapi/linux/pkt_sched.h +26 -0
index f2624b5..2fb6e6d 100644
@@ -787,4 +787,30 @@ struct tc_fq_qd_stats {
 	__u32	throttled_flows;
 	__u32	pad;
 };
+
+/*PIE*/
+enum {
+	TCA_PIE_UNSPEC,
+	TCA_PIE_TARGET,
+	TCA_PIE_LIMIT,
+	TCA_PIE_TUPDATE,
+	TCA_PIE_ALPHA,
+	TCA_PIE_BETA,
+	TCA_PIE_ECN,
+	TCA_PIE_BYTEMODE,
+	__TCA_PIE_MAX
+};
+#define TCA_PIE_MAX   (__TCA_PIE_MAX - 1)
+
+struct tc_pie_xstats {
+	__u32 prob;             /* current probability */
+	__u32 delay;            /* current delay in ms */
+	__u32 avg_dq_rate;      /* current average dq_rate in bits/pie_time */
+	__u32 packets_in;       /* total number of packets enqueued */
+	__u32 dropped;          /* packets dropped due to pie_action */
+	__u32 overlimit;        /* dropped due to lack of space in queue */
+	__u32 maxq;             /* maximum queue size */
+	__u32 ecn_mark;         /* packets marked with ecn*/
+};
+
 #endif
net/sched/Kconfig +11 -0
index c03a32a..7b32e58 100644
@@ -286,6 +286,17 @@ config NET_SCH_FQ
 
 	  If unsure, say N.
 
+config NET_SCH_PIE
+        tristate "Proportianal Enhanced Controller AQM (PIE)"
+        help
+          Say Y here if you want to use the Proportianal and Enhanced Controller AQM (PIE)
+          packet scheduling algorithm.
+
+          To compile this driver as a module, choose M here: the module
+          will be called sch_pie.
+
+          If unsure, say N.
+
 config NET_SCH_INGRESS
 	tristate "Ingress Qdisc"
 	depends on NET_CLS_ACT
net/sched/Makefile +1 -0
index e5f9abe..5b4ece9 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_NET_SCH_QFQ)	+= sch_qfq.o
 obj-$(CONFIG_NET_SCH_CODEL)	+= sch_codel.o
 obj-$(CONFIG_NET_SCH_FQ_CODEL)	+= sch_fq_codel.o
 obj-$(CONFIG_NET_SCH_FQ)	+= sch_fq.o
+obj-$(CONFIG_NET_SCH_PIE)	+= sch_pie.o
 
 obj-$(CONFIG_NET_CLS_U32)	+= cls_u32.o
 obj-$(CONFIG_NET_CLS_ROUTE4)	+= cls_route.o
net/sched/sch_pie.c new file +623 -0

623 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 7 lines · Vijay Subramanian
net/sched/sch_pie.c new file +7 -0
+static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
+{
+	struct pie_sched_data *q = qdisc_priv(sch);
+
+	if (unlikely(qdisc_qlen(sch) >= sch->limit))
+		goto out;
+

...

net/sched/sch_pie.c line 203

Quoted 5 lines
net/sched/sch_pie.c new file +5 -0
+out:
+	q->stats.overlimit++;
+	qdisc_drop(skb, sch);
+	return NET_XMIT_CN;  /*indicate congestion*/
+}

If a Qdisc drops a packet because sch->limit is hit, you must :

return qdisc_drop(skb, sch);

So that NET_XMIT_DROP is returned, not NET_XMIT_CN.

This packet was dropped for sure.

vi +96 net/sched/sch_api.c

---enqueue

enqueue returns 0, if packet was enqueued successfully. If packet (this one or another one) was dropped, it returns not zero error code.
NET_XMIT_DROP - this packet dropped
Expected action: do not backoff, but wait until queue will clear.
NET_XMIT_CN - probably this packet enqueued, but another one dropped.
Expected action: backoff or ignore
NET_XMIT_POLICED - dropped by police.
Expected action: backoff or error to real-time apps.

#2 lore raw
In reply to Vijay Subramanian

net/sched/sch_pie.c line 620

Quoted 3 lines
net/sched/sch_pie.c new file +2 -0
+MODULE_DESCRIPTION
+	("PIE (Proportional Intergal controller Enhanced) scheduler");

Intergal -> Integral

#3 lore raw
In reply to Vijay Subramanian

net/sched/sch_pie.c line 39

Quoted 6 lines
net/sched/sch_pie.c new file +6 -0
+#define PIE_DEFAULT_QUEUE_LIMIT 200	/* in packets */
+#define QUEUE_THRESHOLD (5000)
+#define DQCOUNT_INVALID -1
+#define THRESHOLD_PKT_SIZE	1500
+#define MAX_INT_VALUE  0xffffffff
+#define MAX_INT_VALUE_CAP  (0xffffffff >> 8)

The above 2 constants are both unsigned (unless 'int' is larger than 32 bits). If nothing else this means that they are very badly named.

Quoted 10 lines
net/sched/sch_pie.c new file +10 -0
+
+typedef u32 pie_time_t;
+typedef s32 pie_tdiff_t;
+#define PIE_SHIFT 10
+#define MS2PIETIME(a) ((a * NSEC_PER_MSEC) >> PIE_SHIFT)
+#define PIE_TIME_PER_SEC  ((NSEC_PER_SEC >> PIE_SHIFT))
+
+static inline pie_time_t pie_get_time(void)
+{
+	u64 ns = ktime_to_ns(ktime_get());

net/sched/sch_pie.c line 59

Quoted 10 lines
net/sched/sch_pie.c new file +10 -0
+	return ns >> PIE_SHIFT;
+}
+
+static inline u32 pie_time_to_ms(pie_time_t val)
+{
+	u64 valms = ((u64) val << PIE_SHIFT);
+
+	do_div(valms, NSEC_PER_MSEC);
+	return (u32) valms;
+}

There seems to be a lot of conversions between 1/1000 ms and 1/1024 ms. On 32 bit systems they are horrid.
Not only that the conversions are open coded a lot of times as well. It might also be better replacing '(val * 1000u) >> 10' with '(val * (u64)(1000 << (32 - 10))) >> 32' since I'm not sure the compiler will perform that substitution.

What happens if pie_time_to_ms() overflows 32 bits?
If it is only ever called for small values, there may be no need for 64bit maths at all.

...

net/sched/sch_pie.c line 414

Quoted 3 lines
net/sched/sch_pie.c new file +3 -0
+	if (delta > (s32) (MAX_INT_VALUE * 2 / 100)
+	    && q->vars.prob >= MAX_INT_VALUE / 10) {
+		delta = MAX_INT_VALUE * 2 / 100;

Calculating 'MAX_INT_VALUE * 2' isn't a good idea! Whatever value it is supposed to be, it should be a named constant.

David