Skip to contentSkip to conversation

net: sched: pie: align PIE implementation with RFC 8033

PATCH Superseded Leslie Monis 3 participants 14 messages Nov 1, 2018

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover net: sched: pie: align PIE implementation with RFC 8033

The current implementation of PIE queueing discipline is according to an IETF draft [http://tools.ietf.org/html/draft-pan-aqm-pie-00] and the paper [PIE: A Lightweight Control Scheme to Address the Bufferbloat Problem]. However, a lot of necessary modifications and enhancements have been proposed in RFC 8033, which have not yet been incorporated in the source code of Linux kernel. The following series of patches helps in achieving the same.

This patch series includes:

1. Change the value of QUEUE_THRESHOLD
2. Change the default value of pie_params->target
3. Change the default value of pie_params->tupdate
4. Change the initial value of pie_vars->burst_time
5. Add more conditions to auto-tune alpha and beta
6. Add mechanism to set PIE active/inactive
7. Add a derandomization mechanism
8. Update references

Mohit P. Tahiliani (8):
net: sched: pie: change value of QUEUE_THRESHOLD
net: sched: pie: change default value of pie_params->target
net: sched: pie: change default value of pie_params->tupdate
net: sched: pie: change initial value of pie_vars->burst_time
net: sched: pie: add more conditions to auto-tune alpha and beta
net: sched: pie: add mechanism to set PIE active/inactive
net: sched: pie: add derandomization mechanism
net: sched: pie: update references

 net/sched/sch_pie.c | 77 +++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 63 insertions(+), 14 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/8 net: sched: pie: change value of QUEUE_THRESHOLD

From: "Mohit P. Tahiliani" <[email protected]>

RFC 8033 recommends a value of 16384 bytes for the queue threshold instead of 10000 bytes.

---
 net/sched/sch_pie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_pie.c +1 -1
index d142937..56c9e4d 100644
@@ -31,7 +31,7 @@
 #include <net/pkt_sched.h>
 #include <net/inet_ecn.h>
 
-#define QUEUE_THRESHOLD 10000
+#define QUEUE_THRESHOLD 16384	/* 16KB i.e. 2^14 bytes */
 #define DQCOUNT_INVALID -1
 #define MAX_PROB  0xffffffff
 #define PIE_SCALE 8
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/8 net: sched: pie: change default value of pie_params->target

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

RFC 8033 suggests a default value of 15 milliseconds for the target queue delay instead of 20 milliseconds.

---
 net/sched/sch_pie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_pie.c +1 -1
index 56c9e4d..c5d6d6b 100644
@@ -83,7 +83,7 @@ static void pie_params_init(struct pie_params *params)
 	params->beta = 20;
 	params->tupdate = usecs_to_jiffies(30 * USEC_PER_MSEC);	/* 30 ms */
 	params->limit = 1000;	/* default of 1000 packets */
-	params->target = PSCHED_NS2TICKS(20 * NSEC_PER_MSEC);	/* 20 ms */
+	params->target = PSCHED_NS2TICKS(15 * NSEC_PER_MSEC);	/* 15 ms */
 	params->ecn = false;
 	params->bytemode = false;
 }
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/8 net: sched: pie: change default value of pie_params->tupdate

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

RFC 8033 suggests a default value of 15 milliseconds for the update interval instead of 30 milliseconds.

---
 net/sched/sch_pie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_pie.c +1 -1
index c5d6d6b..9912d9cc 100644
@@ -81,7 +81,7 @@ static void pie_params_init(struct pie_params *params)
 {
 	params->alpha = 2;
 	params->beta = 20;
-	params->tupdate = usecs_to_jiffies(30 * USEC_PER_MSEC);	/* 30 ms */
+	params->tupdate = usecs_to_jiffies(15 * USEC_PER_MSEC);	/* 15 ms */
 	params->limit = 1000;	/* default of 1000 packets */
 	params->target = PSCHED_NS2TICKS(15 * NSEC_PER_MSEC);	/* 15 ms */
 	params->ecn = false;
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/8 net: sched: pie: change initial value of pie_vars->burst_time

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

RFC 8033 suggests an initial value of 150 milliseconds for the maximum time allowed for a burst of packets instead of 100 milliseconds.

---
 net/sched/sch_pie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_pie.c +2 -2
index 9912d9cc..f4e189a 100644
@@ -92,8 +92,8 @@ static void pie_vars_init(struct pie_vars *vars)
 {
 	vars->dq_count = DQCOUNT_INVALID;
 	vars->avg_dq_rate = 0;
-	/* default of 100 ms in pschedtime */
-	vars->burst_time = PSCHED_NS2TICKS(100 * NSEC_PER_MSEC);
+	/* default of 150 ms in pschedtime */
+	vars->burst_time = PSCHED_NS2TICKS(150 * NSEC_PER_MSEC);
 }
 
 static bool drop_early(struct Qdisc *sch, u32 packet_size)
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/8 net: sched: pie: add more conditions to auto-tune alpha and beta

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

The update in drop probability depends on the parameters alpha and beta, which in turn reflect the current congestion level. However, the previous if-else cases were recommended when the supported bandwidth was up to 12 Mbps but, current data links support a much higher bandwidth, and the requirement for more bandwidth is in never-ending demand. Hence, RFC 8033 suggests using more if-else cases for better fine-tuning of parameters alpha and beta in order to control the congestion as much as possible.

---
 net/sched/sch_pie.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
net/sched/sch_pie.c +23 -3
index f4e189a..c84e91e 100644
@@ -343,10 +343,30 @@ static void calculate_probability(struct Qdisc *sch)
 	 * appropriately 2) scaling down by 16 to come to 0-2 range.
 	 * Please see paper for details.
 	 *
-	 * We scale alpha and beta differently depending on whether we are in
-	 * light, medium or high dropping mode.
+	 * We scale alpha and beta differently depending on how heavy the
+	 * congestion is.
 	 */
-	if (q->vars.prob < MAX_PROB / 100) {
+	if (q->vars.prob < MAX_PROB / 1000000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 15;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 15;
+	} else if (q->vars.prob < MAX_PROB / 100000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 13;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 13;
+	} else if (q->vars.prob < MAX_PROB / 10000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 11;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 11;
+	} else if (q->vars.prob < MAX_PROB / 1000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 9;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 9;
+	} else if (q->vars.prob < MAX_PROB / 100) {
 		alpha =
 		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 7;
 		beta =
Signature · 1 line
2.7.4
#6 lore raw

Re: [PATCH net-next 5/8] net: sched: pie: add more conditions to auto-tune alpha and beta

Quoted 50 lines · On Wed, 31 Oct 2018 21:49:29 +0530 Leslie Monis <[email protected]> wrote:

From: "Mohit P. Tahiliani" <[email protected]>

The update in drop probability depends on the parameters alpha and beta, which in turn reflect the current congestion level. However, the previous if-else cases were recommended when the supported bandwidth was up to 12 Mbps but, current data links support a much higher bandwidth, and the requirement for more bandwidth is in never-ending demand. Hence, RFC 8033 suggests using more if-else cases for better fine-tuning of parameters alpha and beta in order to control the congestion as much as possible.

---
 net/sched/sch_pie.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
net/sched/sch_pie.c +16 -3
index f4e189a..c84e91e 100644
@@ -343,10 +343,30 @@ static void calculate_probability(struct Qdisc *sch)
 	 * appropriately 2) scaling down by 16 to come to 0-2 range.
 	 * Please see paper for details.
 	 *
-	 * We scale alpha and beta differently depending on whether we are in
-	 * light, medium or high dropping mode.
+	 * We scale alpha and beta differently depending on how heavy the
+	 * congestion is.
 	 */
-	if (q->vars.prob < MAX_PROB / 100) {
+	if (q->vars.prob < MAX_PROB / 1000000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 15;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 15;
+	} else if (q->vars.prob < MAX_PROB / 100000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 13;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 13;
+	} else if (q->vars.prob < MAX_PROB / 10000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 11;
+		beta =

net/sched/sch_pie.c static void calculate_probability(struct Qdisc *sch) · line 372

Quoted 10 lines
net/sched/sch_pie.c +7 -0
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 11;
+	} else if (q->vars.prob < MAX_PROB / 1000) {
+		alpha =
+		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 9;
+		beta =
+		    (q->params.beta * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 9;
+	} else if (q->vars.prob < MAX_PROB / 100) {
 		alpha =
 		    (q->params.alpha * (MAX_PROB / PSCHED_TICKS_PER_SEC)) >> 7;
 		beta =

Seems like the if/else chain is getting long in the tail. Maybe a loop or table driven approach would be clearer.

#7 lore raw

PATCH 6/8 net: sched: pie: add mechanism to set PIE active/inactive

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

To overcome unnecessary packet drops due to a spurious uptick in queuing latency caused by fluctuations in a network, PIE can choose to be active only when the queue occupancy is over a certain threshold. RFC 8033 suggests the value of this threshold be 1/3 of the tail drop threshold. PIE becomes inactive when the congestion ends i.e., when the drop probability reaches 0, and the current and previous latency samples are all below half of the target queue delay.

---
 net/sched/sch_pie.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
net/sched/sch_pie.c +18 -4
index c84e91e..b68b367 100644
@@ -57,6 +57,7 @@ struct pie_vars {
 	psched_time_t dq_tstamp;	/* drain rate */
 	u32 avg_dq_rate;	/* bytes per pschedtime tick,scaled */
 	u32 qlen_old;		/* in bytes */
+	bool active;		/* inactive/active */
 };
 
 /* statistics gathering */
@@ -94,6 +95,7 @@ static void pie_vars_init(struct pie_vars *vars)
 	vars->avg_dq_rate = 0;
 	/* default of 150 ms in pschedtime */
 	vars->burst_time = PSCHED_NS2TICKS(150 * NSEC_PER_MSEC);
+	vars->active = true;
 }
 
 static bool drop_early(struct Qdisc *sch, u32 packet_size)
@@ -141,12 +143,23 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	struct pie_sched_data *q = qdisc_priv(sch);
 	bool enqueue = false;
 
+	if (!q->vars.active && qdisc_qlen(sch) >= sch->limit / 3) {
+		/* If the queue occupancy is over 1/3 of the tail drop
+		 * threshold, turn on PIE.
+		 */
+		pie_vars_init(&q->vars);
+		q->vars.prob = 0;
+		q->vars.qdelay_old = 0;
+		q->vars.dq_count = 0;
+		q->vars.dq_tstamp = psched_get_time();
+	}
+
 	if (unlikely(qdisc_qlen(sch) >= sch->limit)) {
 		q->stats.overlimit++;
 		goto out;
 	}
 
-	if (!drop_early(sch, skb->len)) {
+	if (!q->vars.active || !drop_early(sch, skb->len)) {
 		enqueue = true;
 	} else if (q->params.ecn && (q->vars.prob <= MAX_PROB / 10) &&
 		   INET_ECN_set_ce(skb)) {
@@ -431,7 +444,7 @@ static void calculate_probability(struct Qdisc *sch)
 	q->vars.qdelay = qdelay;
 	q->vars.qlen_old = qlen;
 
-	/* We restart the measurement cycle if the following conditions are met
+	/* We turn off PIE if the following conditions are met
 	 * 1. If the delay has been low for 2 consecutive Tupdate periods
 	 * 2. Calculated drop probability is zero
 	 * 3. We have atleast one estimate for the avg_dq_rate ie.,
@@ -441,7 +454,7 @@ static void calculate_probability(struct Qdisc *sch)
 	    (q->vars.qdelay_old < q->params.target / 2) &&
 	    q->vars.prob == 0 &&
 	    q->vars.avg_dq_rate > 0)
-		pie_vars_init(&q->vars);
+		q->vars.active = false;
 }
 
 static void pie_timer(struct timer_list *t)
@@ -451,7 +464,8 @@ static void pie_timer(struct timer_list *t)
 	spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch));
 
 	spin_lock(root_lock);
-	calculate_probability(sch);
+	if (q->vars.active)
+		calculate_probability(sch);
 
 	/* reset the timer to fire after 'tupdate'. tupdate is in jiffies. */
 	if (q->params.tupdate)
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH net-next 6/8] net: sched: pie: add mechanism to set PIE active/inactive

net/sched/sch_pie.c struct pie_vars { · line 61

Quoted 10 lines · On Wed, 31 Oct 2018 21:49:30 +0530 Leslie Monis <[email protected]> wrote:
net/sched/sch_pie.c +1 -0
index c84e91e..b68b367 100644
@@ -57,6 +57,7 @@ struct pie_vars {
 	psched_time_t dq_tstamp;	/* drain rate */
 	u32 avg_dq_rate;	/* bytes per pschedtime tick,scaled */
 	u32 qlen_old;		/* in bytes */
+	bool active;		/* inactive/active */
 };

Current Linux best practice is to not use bool for true/false values in a structure. This is because the size of bool is not obvious and can cause padding.

Recommend using u8 instead.

#9 lore raw

PATCH 7/8 net: sched: pie: add derandomization mechanism

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

Random dropping of packets to achieve latency control may introduce outlier situations where packets are dropped too close to each other or too far from each other. This can cause the real drop percentage to temporarily deviate from the intended drop probability. In certain scenarios, such as a small number of simultaneous TCP flows, these deviations can cause significant deviations in link utilization and queuing latency. RFC 8033 suggests using a derandomization mechanism to avoid these deviations.

---
 net/sched/sch_pie.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
net/sched/sch_pie.c +16 -1
index b68b367..88e605c 100644
@@ -58,6 +58,7 @@ struct pie_vars {
 	u32 avg_dq_rate;	/* bytes per pschedtime tick,scaled */
 	u32 qlen_old;		/* in bytes */
 	bool active;		/* inactive/active */
+	u64 accu_prob;		/* accumulated drop probability */
 };
 
 /* statistics gathering */
@@ -96,6 +97,7 @@ static void pie_vars_init(struct pie_vars *vars)
 	/* default of 150 ms in pschedtime */
 	vars->burst_time = PSCHED_NS2TICKS(150 * NSEC_PER_MSEC);
 	vars->active = true;
+	vars->accu_prob = 0;
 }
 
 static bool drop_early(struct Qdisc *sch, u32 packet_size)
@@ -130,9 +132,21 @@ static bool drop_early(struct Qdisc *sch, u32 packet_size)
 	else
 		local_prob = q->vars.prob;
 
+	if (local_prob == 0)
+		q->vars.accu_prob = 0;
+
+	q->vars.accu_prob += local_prob;
+
+	if (q->vars.accu_prob < (MAX_PROB / 100) * 85)
+		return false;
+	if (q->vars.accu_prob >= ((u64)MAX_PROB * 17) / 2)
+		return true;
+
 	rnd = prandom_u32();
-	if (rnd < local_prob)
+	if (rnd < local_prob) {
+		q->vars.accu_prob = 0;
 		return true;
+	}
 
 	return false;
 }
@@ -181,6 +195,7 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 
 out:
 	q->stats.dropped++;
+	q->vars.accu_prob = 0;
 	return qdisc_drop(skb, sch, to_free);
 }
 
Signature · 1 line
2.7.4
#10 lore raw

Re: [PATCH net-next 7/8] net: sched: pie: add derandomization mechanism

net/sched/sch_pie.c struct pie_vars { · line 63

Quoted 11 lines · On Wed, 31 Oct 2018 21:49:31 +0530 Leslie Monis <[email protected]> wrote:
net/sched/sch_pie.c +1 -0
index b68b367..88e605c 100644
@@ -58,6 +58,7 @@ struct pie_vars {
 	u32 avg_dq_rate;	/* bytes per pschedtime tick,scaled */
 	u32 qlen_old;		/* in bytes */
 	bool active;		/* inactive/active */
+	u64 accu_prob;		/* accumulated drop probability */
 };
 

Although putting it at the end seems like a natural place, it creates holes in the c structure. My recommendation would be to put the new field after dq_tsstamp.

#11 lore raw

PATCH 8/8 net: sched: pie: update references

In reply to Leslie Monis

From: "Mohit P. Tahiliani" <[email protected]>

RFC 8033 replaces the IETF draft for PIE

---
 net/sched/sch_pie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_pie.c +1 -1
index 88e605c..708e8ad 100644
@@ -17,7 +17,7 @@
  * University of Oslo, Norway.
  *
  * References:
- * IETF draft submission: http://tools.ietf.org/html/draft-pan-aqm-pie-00
+ * RFC 8033: https://tools.ietf.org/html/rfc8033
  * IEEE  Conference on High Performance Switching and Routing 2013 :
  * "PIE: A * Lightweight Control Scheme to Address the Bufferbloat Problem"
  */
Signature · 1 line
2.7.4
#12 lore raw
In reply to Leslie Monis
Quoted 28 lines · On Wed, 31 Oct 2018 21:49:24 +0530 Leslie Monis <[email protected]> wrote:

The current implementation of PIE queueing discipline is according to an IETF draft [http://tools.ietf.org/html/draft-pan-aqm-pie-00] and the paper [PIE: A Lightweight Control Scheme to Address the Bufferbloat Problem]. However, a lot of necessary modifications and enhancements have been proposed in RFC 8033, which have not yet been incorporated in the source code of Linux kernel. The following series of patches helps in achieving the same.

This patch series includes:

1. Change the value of QUEUE_THRESHOLD
2. Change the default value of pie_params->target
3. Change the default value of pie_params->tupdate
4. Change the initial value of pie_vars->burst_time
5. Add more conditions to auto-tune alpha and beta
6. Add mechanism to set PIE active/inactive
7. Add a derandomization mechanism
8. Update references

Mohit P. Tahiliani (8):
net: sched: pie: change value of QUEUE_THRESHOLD
net: sched: pie: change default value of pie_params->target
net: sched: pie: change default value of pie_params->tupdate
net: sched: pie: change initial value of pie_vars->burst_time
net: sched: pie: add more conditions to auto-tune alpha and beta
net: sched: pie: add mechanism to set PIE active/inactive
net: sched: pie: add derandomization mechanism
net: sched: pie: update references

Quoted 3 lines
 net/sched/sch_pie.c | 77 +++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 63 insertions(+), 14 deletions(-)

Did you do performance tests? Often the RFC is out of date and the actual values are better than those in the standard.