diff mbox series

[iproute2] tc: pie: add dq_rate_estimator option

Message ID 20191126115807.27843-1-gautamramk@gmail.com
State Accepted
Delegated to: stephen hemminger
Headers show
Series [iproute2] tc: pie: add dq_rate_estimator option | expand

Commit Message

Gautam Ramakrishnan Nov. 26, 2019, 11:58 a.m. UTC
PIE now uses per packet timestamps to calculate queuing
delay. The average dequeue rate based queue delay
calculation is now made optional. This patch adds the option
to enable or disable the use of Little's law to calculate
queuing delay.

Signed-off-by: Gautam Ramakrishnan <gautamramk@gmail.com>
Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>
---
 bash-completion/tc |  1 +
 man/man8/tc-pie.8  | 31 ++++++++++++++++++++++++++-----
 tc/q_pie.c         | 35 +++++++++++++++++++++++++++++------
 3 files changed, 56 insertions(+), 11 deletions(-)

Comments

Stephen Hemminger Dec. 4, 2019, 6:59 p.m. UTC | #1
On Tue, 26 Nov 2019 17:28:07 +0530
Gautam Ramakrishnan <gautamramk@gmail.com> wrote:

> PIE now uses per packet timestamps to calculate queuing
> delay. The average dequeue rate based queue delay
> calculation is now made optional. This patch adds the option
> to enable or disable the use of Little's law to calculate
> queuing delay.
> 
> Signed-off-by: Gautam Ramakrishnan <gautamramk@gmail.com>
> Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
> Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>

Applied.

Note: pie and several other qdisc need to be fixed to support
JSON and oneline output format.
Leslie Monis Dec. 5, 2019, 4:52 a.m. UTC | #2
Hi Stephen,

On Thu, Dec 5, 2019 at 12:29 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
> Note: pie and several other qdisc need to be fixed to support
> JSON and oneline output format.

Thanks for the feedback. We'll work on this right away.

Leslie
diff mbox series

Patch

diff --git a/bash-completion/tc b/bash-completion/tc
index 007e1c2e..fe0d51ec 100644
--- a/bash-completion/tc
+++ b/bash-completion/tc
@@ -323,6 +323,7 @@  _tc_qdisc_options()
             _tc_once_attr 'limit target tupdate alpha beta'
             _tc_one_of_list 'bytemode nobytemode'
             _tc_one_of_list 'ecn noecn'
+            _tc_one_of_list 'dq_rate_estimator no_dq_rate_estimator'
             return 0
             ;;
         red)
diff --git a/man/man8/tc-pie.8 b/man/man8/tc-pie.8
index a302132f..bdcfba51 100644
--- a/man/man8/tc-pie.8
+++ b/man/man8/tc-pie.8
@@ -21,6 +21,10 @@  int ] [
 .B bytemode
 |
 .B nobytemode
+] [
+.B dq_rate_estimator
+|
+.B no_dq_rate_estimator
 ]
 
 .SH DESCRIPTION
@@ -71,7 +75,7 @@  alpha and beta are parameters chosen to control the drop probability. These
 should be in the range between 0 and 32.
 
 .SS ecn | noecn
-is used to mark packets instead of dropping
+is used to mark packets instead of dropping.
 .B ecn
 to turn on ecn mode,
 .B noecn
@@ -80,7 +84,7 @@  to turn off ecn mode. By default,
 is turned off.
 
 .SS bytemode | nobytemode
-is used to scale drop probability proportional to packet size
+is used to scale drop probability proportional to packet size.
 .B bytemode
 to turn on bytemode,
 .B nobytemode
@@ -88,21 +92,38 @@  to turn off bytemode. By default,
 .B bytemode
 is turned off.
 
+.SS dq_rate_estimator | no_dq_rate_estimator
+is used to calculate delay using Little's law.
+.B dq_rate_estimator
+to turn on dq_rate_estimator,
+.B no_dq_rate_estimator
+to turn off no_dq_rate_estimator. By default,
+.B dq_rate_estimator
+is turned off.
+
 .SH EXAMPLES
  # tc qdisc add dev eth0 root pie
  # tc -s qdisc show
    qdisc pie 8036: dev eth0 root refcnt 2 limit 1000p target 15.0ms tupdate 16.0ms alpha 2 beta 20
     Sent 31216108 bytes 20800 pkt (dropped 80, overlimits 0 requeues 0)
     backlog 16654b 11p requeues 0
-   prob 0.006161 delay 15666us avg_dq_rate 1159667
+   prob 0.006161 delay 15666us
    pkts_in 20811 overlimit 0 dropped 80 maxq 50 ecn_mark 0
 
+ # tc qdisc add dev eth0 root pie dq_rate_estimator
+ # tc -s qdisc show
+   qdisc pie 8036: dev eth0 root refcnt 2 limit 1000p target 15.0ms tupdate 16.0ms alpha 2 beta 20
+    Sent 63947420 bytes 42414 pkt (dropped 41, overlimits 0 requeues 0)
+    backlog 271006b 179p requeues 0
+   prob 0.000092 delay 22200us avg_dq_rate 12145996
+   pkts_in 41 overlimit 343 dropped 0 maxq 50 ecn_mark 0
+
  # tc qdisc add dev eth0 root pie limit 100 target 20ms tupdate 30ms ecn
  # tc -s qdisc show
    qdisc pie 8036: dev eth0 root refcnt 2 limit 100p target 20.0ms tupdate 32.0ms alpha 2 beta 20 ecn
     Sent 6591724 bytes 4442 pkt (dropped 27, overlimits 0 requeues 0)
     backlog 18168b 12p requeues 0
-   prob 0.008845 delay 11348us avg_dq_rate 1342773
+   prob 0.008845 delay 11348us
    pkts_in 4454 overlimit 0 dropped 27 maxq 65 ecn_mark 0
 
  # tc qdisc add dev eth0 root pie limit 100 target 50ms tupdate 30ms bytemode
@@ -110,7 +131,7 @@  is turned off.
    qdisc pie 8036: dev eth0 root refcnt 2 limit 100p target 50.0ms tupdate 32.0ms alpha 2 beta 20 bytemode
     Sent 1616274 bytes 1137 pkt (dropped 0, overlimits 0 requeues 0)
     backlog 13626b 9p requeues 0
-   prob 0.000000 delay 0us avg_dq_rate 0
+   prob 0.000000 delay 0us
    pkts_in 1146 overlimit 0 dropped 0 maxq 23 ecn_mark 0
 
 .SH SEE ALSO
diff --git a/tc/q_pie.c b/tc/q_pie.c
index 40982f96..935548a2 100644
--- a/tc/q_pie.c
+++ b/tc/q_pie.c
@@ -31,9 +31,10 @@ 
 static void explain(void)
 {
 	fprintf(stderr,
-		"Usage: ... pie	[ limit PACKETS ][ target TIME us]\n"
-		"		[ tupdate TIME us][ alpha ALPHA ]"
-		"[beta BETA ][bytemode | nobytemode][ecn | noecn ]\n");
+		"Usage: ... pie [ limit PACKETS ] [ target TIME ]\n"
+		"               [ tupdate TIME ] [ alpha ALPHA ] [ beta BETA ]\n"
+		"               [ bytemode | nobytemode ] [ ecn | noecn ]\n"
+		"               [ dq_rate_estimator | no_dq_rate_estimator ]\n");
 }
 
 #define ALPHA_MAX 32
@@ -49,6 +50,7 @@  static int pie_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 	unsigned int beta    = 0;
 	int ecn = -1;
 	int bytemode = -1;
+	int dq_rate_estimator = -1;
 	struct rtattr *tail;
 
 	while (argc > 0) {
@@ -92,6 +94,10 @@  static int pie_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 			bytemode = 1;
 		} else if (strcmp(*argv, "nobytemode") == 0) {
 			bytemode = 0;
+		} else if (strcmp(*argv, "dq_rate_estimator") == 0) {
+			dq_rate_estimator = 1;
+		} else if (strcmp(*argv, "no_dq_rate_estimator") == 0) {
+			dq_rate_estimator = 0;
 		} else if (strcmp(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -120,6 +126,9 @@  static int pie_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 	if (bytemode != -1)
 		addattr_l(n, 1024, TCA_PIE_BYTEMODE, &bytemode,
 			  sizeof(bytemode));
+	if (dq_rate_estimator != -1)
+		addattr_l(n, 1024, TCA_PIE_DQ_RATE_ESTIMATOR,
+			  &dq_rate_estimator, sizeof(dq_rate_estimator));
 
 	addattr_nest_end(n, tail);
 	return 0;
@@ -135,6 +144,7 @@  static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	unsigned int beta;
 	unsigned int ecn;
 	unsigned int bytemode;
+	unsigned int dq_rate_estimator;
 
 	SPRINT_BUF(b1);
 
@@ -182,6 +192,14 @@  static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 			fprintf(f, "bytemode ");
 	}
 
+	if (tb[TCA_PIE_DQ_RATE_ESTIMATOR] &&
+	    RTA_PAYLOAD(tb[TCA_PIE_DQ_RATE_ESTIMATOR]) >= sizeof(__u32)) {
+		dq_rate_estimator =
+				rta_getattr_u32(tb[TCA_PIE_DQ_RATE_ESTIMATOR]);
+		if (dq_rate_estimator)
+			fprintf(f, "dq_rate_estimator ");
+	}
+
 	return 0;
 }
 
@@ -198,9 +216,14 @@  static int pie_print_xstats(struct qdisc_util *qu, FILE *f,
 
 	st = RTA_DATA(xstats);
 	/*prob is returned as a fracion of maximum integer value */
-	fprintf(f, "prob %f delay %uus avg_dq_rate %u\n",
-		(double)st->prob / UINT64_MAX, st->delay,
-		st->avg_dq_rate);
+	fprintf(f, "prob %f delay %uus",
+		(double)st->prob / UINT64_MAX, st->delay);
+
+	if (st->dq_rate_estimating)
+		fprintf(f, " avg_dq_rate %u\n", st->avg_dq_rate);
+	else
+		fprintf(f, "\n");
+
 	fprintf(f, "pkts_in %u overlimit %u dropped %u maxq %u ecn_mark %u\n",
 		st->packets_in, st->overlimit, st->dropped, st->maxq,
 		st->ecn_mark);