[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190827141938.23483-1-gautamramk@gmail.com>
Date: Tue, 27 Aug 2019 19:49:38 +0530
From: Gautam Ramakrishnan <gautamramk@...il.com>
To: netdev@...r.kernel.org
Cc: jhs@...atatu.com, davem@...emloft.net, xiyou.wangcong@...il.com,
Gautam Ramakrishnan <gautamramk@...il.com>,
Leslie Monis <lesliemonis@...il.com>,
"Mohit P . Tahiliani" <tahiliani@...k.edu.in>,
Dave Taht <dave.taht@...il.com>
Subject: [net-next] net: sched: pie: enable timestamp based delay calculation
RFC 8033 suggests an alternative approach to calculate the queue
delay in PIE by using per packet timestamps. This patch enables the
PIE implementation to do this.
The calculation of queue delay is as follows:
qdelay = now - packet_enqueue_time
To enable the use of timestamps:
modprobe sch_pie use_timestamps=1
Signed-off-by: Gautam Ramakrishnan <gautamramk@...il.com>
Signed-off-by: Leslie Monis <lesliemonis@...il.com>
Signed-off-by: Mohit P. Tahiliani <tahiliani@...k.edu.in>
Cc: Dave Taht <dave.taht@...il.com>
---
net/sched/sch_pie.c | 55 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 49 insertions(+), 6 deletions(-)
diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c
index df98a887eb89..1a19c77e6e42 100644
--- a/net/sched/sch_pie.c
+++ b/net/sched/sch_pie.c
@@ -19,12 +19,18 @@
#include <linux/skbuff.h>
#include <net/pkt_sched.h>
#include <net/inet_ecn.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
#define QUEUE_THRESHOLD 16384
#define DQCOUNT_INVALID -1
#define MAX_PROB 0xffffffffffffffff
#define PIE_SCALE 8
+static unsigned int use_timestamps; /* to calculate delay */
+module_param(use_timestamps, int, 0644);
+MODULE_PARM_DESC(use_timestamps, "enables timestamp based delay calculation.");
+
/* parameters used */
struct pie_params {
psched_time_t target; /* user specified target delay in pschedtime */
@@ -79,6 +85,27 @@ static void pie_params_init(struct pie_params *params)
params->bytemode = false;
}
+/* private skb vars */
+struct pie_skb_cb {
+ psched_time_t enqueue_time;
+};
+
+static struct pie_skb_cb *get_pie_cb(const struct sk_buff *skb)
+{
+ qdisc_cb_private_validate(skb, sizeof(struct pie_skb_cb));
+ return (struct pie_skb_cb *)qdisc_skb_cb(skb)->data;
+}
+
+static psched_time_t pie_get_enqueue_time(const struct sk_buff *skb)
+{
+ return get_pie_cb(skb)->enqueue_time;
+}
+
+static void pie_set_enqueue_time(struct sk_buff *skb)
+{
+ get_pie_cb(skb)->enqueue_time = psched_get_time();
+}
+
static void pie_vars_init(struct pie_vars *vars)
{
vars->dq_count = DQCOUNT_INVALID;
@@ -172,6 +199,9 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
/* we can enqueue the packet */
if (enqueue) {
+ if (use_timestamps)
+ pie_set_enqueue_time(skb);
+
q->stats.packets_in++;
if (qdisc_qlen(sch) > q->stats.maxq)
q->stats.maxq = qdisc_qlen(sch);
@@ -323,6 +353,10 @@ static void pie_process_dequeue(struct Qdisc *sch, struct sk_buff *skb)
else
q->vars.burst_time = 0;
}
+
+ if (use_timestamps)
+ q->vars.qdelay = now -
+ pie_get_enqueue_time(skb);
}
}
}
@@ -332,19 +366,25 @@ static void calculate_probability(struct Qdisc *sch)
struct pie_sched_data *q = qdisc_priv(sch);
u32 qlen = sch->qstats.backlog; /* queue size in bytes */
psched_time_t qdelay = 0; /* in pschedtime */
- psched_time_t qdelay_old = q->vars.qdelay; /* in pschedtime */
+ psched_time_t qdelay_old = 0; /* in pschedtime */
s64 delta = 0; /* determines the change in probability */
u64 oldprob;
u64 alpha, beta;
u32 power;
bool update_prob = true;
- q->vars.qdelay_old = q->vars.qdelay;
+ if (use_timestamps) {
+ qdelay = q->vars.qdelay;
+ qdelay_old = q->vars.qdelay_old;
+ } else {
+ qdelay_old = q->vars.qdelay;
+ q->vars.qdelay_old = q->vars.qdelay;
- if (q->vars.avg_dq_rate > 0)
- qdelay = (qlen << PIE_SCALE) / q->vars.avg_dq_rate;
- else
- qdelay = 0;
+ if (q->vars.avg_dq_rate > 0)
+ qdelay = (qlen << PIE_SCALE) / q->vars.avg_dq_rate;
+ else
+ qdelay = 0;
+ }
/* If qdelay is zero and qlen is not, it means qlen is very small, less
* than dequeue_rate, so we do not update probabilty in this round
@@ -438,6 +478,9 @@ static void calculate_probability(struct Qdisc *sch)
q->vars.prob == 0 &&
q->vars.avg_dq_rate > 0)
pie_vars_init(&q->vars);
+
+ if (use_timestamps)
+ q->vars.qdelay_old = qdelay;
}
static void pie_timer(struct timer_list *t)
--
2.17.1
Powered by blists - more mailing lists