diff mbox series

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

Message ID 1541002772-28040-7-git-send-email-lesliemonis@gmail.com
State Deferred, archived
Delegated to: David Miller
Headers show
Series net: sched: pie: align PIE implementation with RFC 8033 | expand

Commit Message

Leslie Monis Oct. 31, 2018, 4:19 p.m. UTC
From: "Mohit P. Tahiliani" <tahiliani@nitk.edu.in>

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.

Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>
Signed-off-by: Dhaval Khandla <dhavaljkhandla26@gmail.com>
Signed-off-by: Hrishikesh Hiraskar <hrishihiraskar@gmail.com>
Signed-off-by: Manish Kumar B <bmanish15597@gmail.com>
Signed-off-by: Sachin D. Patil <sdp.sachin@gmail.com>
Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
---
 net/sched/sch_pie.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

Stephen Hemminger Oct. 31, 2018, 4:41 p.m. UTC | #1
On Wed, 31 Oct 2018 21:49:30 +0530
Leslie Monis <lesliemonis@gmail.com> wrote:

> diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c
> index c84e91e..b68b367 100644
> --- a/net/sched/sch_pie.c
> +++ b/net/sched/sch_pie.c
> @@ -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.
diff mbox series

Patch

diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c
index c84e91e..b68b367 100644
--- a/net/sched/sch_pie.c
+++ b/net/sched/sch_pie.c
@@ -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)