All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next 0/7] couple of net/sched fixes+improvements
@ 2013-02-08 12:58 Jiri Pirko
  2013-02-08 12:58 ` [patch net-next 1/7] htb: use PSCHED_TICKS2NS() Jiri Pirko
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

Jiri Pirko (7):
  htb: use PSCHED_TICKS2NS()
  htb: fix values in opt dump
  htb: remove pointless first initialization of buffer and cbuffer
  htb: initialize cl->tokens and cl->ctokens correctly
  sch: make htb_rate_cfg and functions around that generic
  tbf: improved accuracy at high rates
  tbf: ignore max_size check for gso skbs

 include/net/sch_generic.h | 18 +++++++++++
 net/sched/sch_generic.c   | 37 ++++++++++++++++++++++
 net/sched/sch_htb.c       | 80 +++++++++--------------------------------------
 net/sched/sch_tbf.c       | 62 ++++++++++++++++++------------------
 4 files changed, 100 insertions(+), 97 deletions(-)

-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch net-next 1/7] htb: use PSCHED_TICKS2NS()
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 15:51   ` Eric Dumazet
  2013-02-08 12:58 ` [patch net-next 2/7] htb: fix values in opt dump Jiri Pirko
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/sched/sch_htb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 51561ea..476992c 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1512,8 +1512,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
 	htb_precompute_ratedata(&cl->rate);
 	htb_precompute_ratedata(&cl->ceil);
 
-	cl->buffer = hopt->buffer << PSCHED_SHIFT;
-	cl->cbuffer = hopt->buffer << PSCHED_SHIFT;
+	cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
+	cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer);
 
 	sch_tree_unlock(sch);
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [patch net-next 2/7] htb: fix values in opt dump
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
  2013-02-08 12:58 ` [patch net-next 1/7] htb: use PSCHED_TICKS2NS() Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 15:54   ` Eric Dumazet
  2013-02-08 12:58 ` [patch net-next 3/7] htb: remove pointless first initialization of buffer and cbuffer Jiri Pirko
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

in htb_change_class() cl->buffer and cl->buffer are stored in ns.
So in dump, convert them back to psched ticks.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/sched/sch_htb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 476992c..14a83dc 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1135,9 +1135,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
 	memset(&opt, 0, sizeof(opt));
 
 	opt.rate.rate = cl->rate.rate_bps >> 3;
-	opt.buffer = cl->buffer;
+	opt.buffer = PSCHED_NS2TICKS(cl->buffer);
 	opt.ceil.rate = cl->ceil.rate_bps >> 3;
-	opt.cbuffer = cl->cbuffer;
+	opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
 	opt.quantum = cl->quantum;
 	opt.prio = cl->prio;
 	opt.level = cl->level;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [patch net-next 3/7] htb: remove pointless first initialization of buffer and cbuffer
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
  2013-02-08 12:58 ` [patch net-next 1/7] htb: use PSCHED_TICKS2NS() Jiri Pirko
  2013-02-08 12:58 ` [patch net-next 2/7] htb: fix values in opt dump Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 16:35   ` Eric Dumazet
  2013-02-08 12:58 ` [patch net-next 4/7] htb: initialize cl->tokens and cl->ctokens correctly Jiri Pirko
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

these are initialized correctly couple of lines later in the function.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/sched/sch_htb.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 14a83dc..547912e9 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1503,9 +1503,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
 			cl->prio = TC_HTB_NUMPRIO - 1;
 	}
 
-	cl->buffer = hopt->buffer;
-	cl->cbuffer = hopt->cbuffer;
-
 	cl->rate.rate_bps = (u64)hopt->rate.rate << 3;
 	cl->ceil.rate_bps = (u64)hopt->ceil.rate << 3;
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [patch net-next 4/7] htb: initialize cl->tokens and cl->ctokens correctly
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
                   ` (2 preceding siblings ...)
  2013-02-08 12:58 ` [patch net-next 3/7] htb: remove pointless first initialization of buffer and cbuffer Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 16:36   ` Eric Dumazet
  2013-02-08 12:58 ` [patch net-next 5/7] sch: make htb_rate_cfg and functions around that generic Jiri Pirko
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

These are in ns so convert from ticks to ns.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/sched/sch_htb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 547912e9..2b22544 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1459,8 +1459,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
 		cl->parent = parent;
 
 		/* set class to be in HTB_CAN_SEND state */
-		cl->tokens = hopt->buffer;
-		cl->ctokens = hopt->cbuffer;
+		cl->tokens = PSCHED_TICKS2NS(hopt->buffer);
+		cl->ctokens = PSCHED_TICKS2NS(hopt->cbuffer);
 		cl->mbuffer = 60 * PSCHED_TICKS_PER_SEC;	/* 1min */
 		cl->t_c = psched_get_time();
 		cl->cmode = HTB_CAN_SEND;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [patch net-next 5/7] sch: make htb_rate_cfg and functions around that generic
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
                   ` (3 preceding siblings ...)
  2013-02-08 12:58 ` [patch net-next 4/7] htb: initialize cl->tokens and cl->ctokens correctly Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 16:39   ` Eric Dumazet
  2013-02-08 12:58 ` [patch net-next 6/7] tbf: improved accuracy at high rates Jiri Pirko
  2013-02-08 12:58 ` [patch net-next 7/7] tbf: ignore max_size check for gso skbs Jiri Pirko
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

As it is going to be used in tbf as well, push these to generic code.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 include/net/sch_generic.h | 18 +++++++++++++
 net/sched/sch_generic.c   | 37 +++++++++++++++++++++++++++
 net/sched/sch_htb.c       | 65 +++++++----------------------------------------
 3 files changed, 64 insertions(+), 56 deletions(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 2d06c2a..c7e5512 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -679,4 +679,22 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask,
 }
 #endif
 
+struct psched_ratecfg {
+	u64 rate_bps;
+	u32 mult;
+	u32 shift;
+};
+
+static inline u64 psched_l2t_ns(struct psched_ratecfg *r, unsigned int len)
+{
+	return ((u64)len * r->mult) >> r->shift;
+}
+
+extern void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate);
+
+static inline u32 psched_ratecfg_getrate(struct psched_ratecfg *r)
+{
+	return r->rate_bps >> 3;
+}
+
 #endif
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 5d81a44..ffad481 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -25,6 +25,7 @@
 #include <linux/rcupdate.h>
 #include <linux/list.h>
 #include <linux/slab.h>
+#include <net/sch_generic.h>
 #include <net/pkt_sched.h>
 #include <net/dst.h>
 
@@ -896,3 +897,39 @@ void dev_shutdown(struct net_device *dev)
 
 	WARN_ON(timer_pending(&dev->watchdog_timer));
 }
+
+void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate)
+{
+	u64 factor;
+	u64 mult;
+	int shift;
+
+	r->rate_bps = rate << 3;
+	r->shift = 0;
+	r->mult = 1;
+	/*
+	 * Calibrate mult, shift so that token counting is accurate
+	 * for smallest packet size (64 bytes).  Token (time in ns) is
+	 * computed as (bytes * 8) * NSEC_PER_SEC / rate_bps.  It will
+	 * work as long as the smallest packet transfer time can be
+	 * accurately represented in nanosec.
+	 */
+	if (r->rate_bps > 0) {
+		/*
+		 * Higher shift gives better accuracy.  Find the largest
+		 * shift such that mult fits in 32 bits.
+		 */
+		for (shift = 0; shift < 16; shift++) {
+			r->shift = shift;
+			factor = 8LLU * NSEC_PER_SEC * (1 << r->shift);
+			mult = div64_u64(factor, r->rate_bps);
+			if (mult > UINT_MAX)
+				break;
+		}
+
+		r->shift = shift - 1;
+		factor = 8LLU * NSEC_PER_SEC * (1 << r->shift);
+		r->mult = div64_u64(factor, r->rate_bps);
+	}
+}
+EXPORT_SYMBOL(psched_ratecfg_precompute);
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 2b22544..03c2692 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -38,6 +38,7 @@
 #include <linux/workqueue.h>
 #include <linux/slab.h>
 #include <net/netlink.h>
+#include <net/sch_generic.h>
 #include <net/pkt_sched.h>
 
 /* HTB algorithm.
@@ -71,12 +72,6 @@ enum htb_cmode {
 	HTB_CAN_SEND		/* class can send */
 };
 
-struct htb_rate_cfg {
-	u64 rate_bps;
-	u32 mult;
-	u32 shift;
-};
-
 /* interior & leaf nodes; props specific to leaves are marked L: */
 struct htb_class {
 	struct Qdisc_class_common common;
@@ -124,8 +119,8 @@ struct htb_class {
 	int filter_cnt;
 
 	/* token bucket parameters */
-	struct htb_rate_cfg rate;
-	struct htb_rate_cfg ceil;
+	struct psched_ratecfg rate;
+	struct psched_ratecfg ceil;
 	s64 buffer, cbuffer;	/* token bucket depth/rate */
 	psched_tdiff_t mbuffer;	/* max wait time */
 	s64 tokens, ctokens;	/* current number of tokens */
@@ -168,45 +163,6 @@ struct htb_sched {
 	struct work_struct work;
 };
 
-static u64 l2t_ns(struct htb_rate_cfg *r, unsigned int len)
-{
-	return ((u64)len * r->mult) >> r->shift;
-}
-
-static void htb_precompute_ratedata(struct htb_rate_cfg *r)
-{
-	u64 factor;
-	u64 mult;
-	int shift;
-
-	r->shift = 0;
-	r->mult = 1;
-	/*
-	 * Calibrate mult, shift so that token counting is accurate
-	 * for smallest packet size (64 bytes).  Token (time in ns) is
-	 * computed as (bytes * 8) * NSEC_PER_SEC / rate_bps.  It will
-	 * work as long as the smallest packet transfer time can be
-	 * accurately represented in nanosec.
-	 */
-	if (r->rate_bps > 0) {
-		/*
-		 * Higher shift gives better accuracy.  Find the largest
-		 * shift such that mult fits in 32 bits.
-		 */
-		for (shift = 0; shift < 16; shift++) {
-			r->shift = shift;
-			factor = 8LLU * NSEC_PER_SEC * (1 << r->shift);
-			mult = div64_u64(factor, r->rate_bps);
-			if (mult > UINT_MAX)
-				break;
-		}
-
-		r->shift = shift - 1;
-		factor = 8LLU * NSEC_PER_SEC * (1 << r->shift);
-		r->mult = div64_u64(factor, r->rate_bps);
-	}
-}
-
 /* find class in global hash table using given handle */
 static inline struct htb_class *htb_find(u32 handle, struct Qdisc *sch)
 {
@@ -632,7 +588,7 @@ static inline void htb_accnt_tokens(struct htb_class *cl, int bytes, s64 diff)
 
 	if (toks > cl->buffer)
 		toks = cl->buffer;
-	toks -= (s64) l2t_ns(&cl->rate, bytes);
+	toks -= (s64) psched_l2t_ns(&cl->rate, bytes);
 	if (toks <= -cl->mbuffer)
 		toks = 1 - cl->mbuffer;
 
@@ -645,7 +601,7 @@ static inline void htb_accnt_ctokens(struct htb_class *cl, int bytes, s64 diff)
 
 	if (toks > cl->cbuffer)
 		toks = cl->cbuffer;
-	toks -= (s64) l2t_ns(&cl->ceil, bytes);
+	toks -= (s64) psched_l2t_ns(&cl->ceil, bytes);
 	if (toks <= -cl->mbuffer)
 		toks = 1 - cl->mbuffer;
 
@@ -1134,9 +1090,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
 
 	memset(&opt, 0, sizeof(opt));
 
-	opt.rate.rate = cl->rate.rate_bps >> 3;
+	opt.rate.rate = psched_ratecfg_getrate(&cl->rate);
 	opt.buffer = PSCHED_NS2TICKS(cl->buffer);
-	opt.ceil.rate = cl->ceil.rate_bps >> 3;
+	opt.ceil.rate = psched_ratecfg_getrate(&cl->ceil);
 	opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
 	opt.quantum = cl->quantum;
 	opt.prio = cl->prio;
@@ -1503,11 +1459,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
 			cl->prio = TC_HTB_NUMPRIO - 1;
 	}
 
-	cl->rate.rate_bps = (u64)hopt->rate.rate << 3;
-	cl->ceil.rate_bps = (u64)hopt->ceil.rate << 3;
-
-	htb_precompute_ratedata(&cl->rate);
-	htb_precompute_ratedata(&cl->ceil);
+	psched_ratecfg_precompute(&cl->rate, hopt->rate.rate);
+	psched_ratecfg_precompute(&cl->ceil, hopt->ceil.rate);
 
 	cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
 	cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer);
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [patch net-next 6/7] tbf: improved accuracy at high rates
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
                   ` (4 preceding siblings ...)
  2013-02-08 12:58 ` [patch net-next 5/7] sch: make htb_rate_cfg and functions around that generic Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 16:42   ` Eric Dumazet
  2013-02-08 12:58 ` [patch net-next 7/7] tbf: ignore max_size check for gso skbs Jiri Pirko
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

Current TBF uses rate table computed by the "tc" userspace program,
which has the following issue:

The rate table has 256 entries to map packet lengths to
token (time units).  With TSO sized packets, the 256 entry granularity
leads to loss/gain of rate, making the token bucket inaccurate.

Thus, instead of relying on rate table, this patch explicitly computes
the time and accounts for packet transmission times with nanosecond
granularity.

This is a followup to 56b765b79e9a78dc7d3f8850ba5e5567205a3ecd

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/sched/sch_tbf.c | 60 ++++++++++++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 4b056c15..35bfd49 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/skbuff.h>
 #include <net/netlink.h>
+#include <net/sch_generic.h>
 #include <net/pkt_sched.h>
 
 
@@ -100,23 +101,21 @@
 struct tbf_sched_data {
 /* Parameters */
 	u32		limit;		/* Maximal length of backlog: bytes */
-	u32		buffer;		/* Token bucket depth/rate: MUST BE >= MTU/B */
+	s64		buffer;		/* Token bucket depth/rate: MUST BE >= MTU/B */
 	u32		mtu;
 	u32		max_size;
-	struct qdisc_rate_table	*R_tab;
-	struct qdisc_rate_table	*P_tab;
+	struct psched_ratecfg rate;
+	struct psched_ratecfg peek;
+	bool peek_present;
 
 /* Variables */
-	long	tokens;			/* Current number of B tokens */
-	long	ptokens;		/* Current number of P tokens */
+	s64	tokens;			/* Current number of B tokens */
+	s64	ptokens;		/* Current number of P tokens */
 	psched_time_t	t_c;		/* Time check-point */
 	struct Qdisc	*qdisc;		/* Inner qdisc, default - bfifo queue */
 	struct qdisc_watchdog watchdog;	/* Watchdog timer */
 };
 
-#define L2T(q, L)   qdisc_l2t((q)->R_tab, L)
-#define L2T_P(q, L) qdisc_l2t((q)->P_tab, L)
-
 static int tbf_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 {
 	struct tbf_sched_data *q = qdisc_priv(sch);
@@ -157,23 +156,23 @@ static struct sk_buff *tbf_dequeue(struct Qdisc *sch)
 
 	if (skb) {
 		psched_time_t now;
-		long toks;
-		long ptoks = 0;
+		s64 toks;
+		s64 ptoks = 0;
 		unsigned int len = qdisc_pkt_len(skb);
 
-		now = psched_get_time();
-		toks = psched_tdiff_bounded(now, q->t_c, q->buffer);
+		now = ktime_to_ns(ktime_get());
+		toks = min_t(s64, now - q->t_c, q->buffer);
 
-		if (q->P_tab) {
+		if (q->peek_present) {
 			ptoks = toks + q->ptokens;
 			if (ptoks > (long)q->mtu)
 				ptoks = q->mtu;
-			ptoks -= L2T_P(q, len);
+			ptoks -= (s64) psched_l2t_ns(&q->peek, len);
 		}
 		toks += q->tokens;
-		if (toks > (long)q->buffer)
+		if (toks > q->buffer)
 			toks = q->buffer;
-		toks -= L2T(q, len);
+		toks -= (s64) psched_l2t_ns(&q->rate, len);
 
 		if ((toks|ptoks) >= 0) {
 			skb = qdisc_dequeue_peeked(q->qdisc);
@@ -214,7 +213,7 @@ static void tbf_reset(struct Qdisc *sch)
 
 	qdisc_reset(q->qdisc);
 	sch->q.qlen = 0;
-	q->t_c = psched_get_time();
+	q->t_c = ktime_to_ns(ktime_get());
 	q->tokens = q->buffer;
 	q->ptokens = q->mtu;
 	qdisc_watchdog_cancel(&q->watchdog);
@@ -295,12 +294,17 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
 	q->limit = qopt->limit;
 	q->mtu = qopt->mtu;
 	q->max_size = max_size;
-	q->buffer = qopt->buffer;
+	q->buffer = PSCHED_TICKS2NS(qopt->buffer);
 	q->tokens = q->buffer;
 	q->ptokens = q->mtu;
 
-	swap(q->R_tab, rtab);
-	swap(q->P_tab, ptab);
+	psched_ratecfg_precompute(&q->rate, rtab->rate.rate);
+	if (ptab) {
+		psched_ratecfg_precompute(&q->peek, ptab->rate.rate);
+		q->peek_present = true;
+	} else {
+		q->peek_present = false;
+	}
 
 	sch_tree_unlock(sch);
 	err = 0;
@@ -319,7 +323,7 @@ static int tbf_init(struct Qdisc *sch, struct nlattr *opt)
 	if (opt == NULL)
 		return -EINVAL;
 
-	q->t_c = psched_get_time();
+	q->t_c = ktime_to_ns(ktime_get());
 	qdisc_watchdog_init(&q->watchdog, sch);
 	q->qdisc = &noop_qdisc;
 
@@ -331,12 +335,6 @@ static void tbf_destroy(struct Qdisc *sch)
 	struct tbf_sched_data *q = qdisc_priv(sch);
 
 	qdisc_watchdog_cancel(&q->watchdog);
-
-	if (q->P_tab)
-		qdisc_put_rtab(q->P_tab);
-	if (q->R_tab)
-		qdisc_put_rtab(q->R_tab);
-
 	qdisc_destroy(q->qdisc);
 }
 
@@ -352,13 +350,13 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
 		goto nla_put_failure;
 
 	opt.limit = q->limit;
-	opt.rate = q->R_tab->rate;
-	if (q->P_tab)
-		opt.peakrate = q->P_tab->rate;
+	opt.rate.rate = psched_ratecfg_getrate(&q->rate);
+	if (q->peek_present)
+		opt.peakrate.rate = psched_ratecfg_getrate(&q->peek);
 	else
 		memset(&opt.peakrate, 0, sizeof(opt.peakrate));
 	opt.mtu = q->mtu;
-	opt.buffer = q->buffer;
+	opt.buffer = PSCHED_NS2TICKS(q->buffer);
 	if (nla_put(skb, TCA_TBF_PARMS, sizeof(opt), &opt))
 		goto nla_put_failure;
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [patch net-next 7/7] tbf: ignore max_size check for gso skbs
  2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
                   ` (5 preceding siblings ...)
  2013-02-08 12:58 ` [patch net-next 6/7] tbf: improved accuracy at high rates Jiri Pirko
@ 2013-02-08 12:58 ` Jiri Pirko
  2013-02-08 16:43   ` Eric Dumazet
  6 siblings, 1 reply; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 12:58 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, jhs, kuznet

This check made bigger packets incorrectly dropped. Remove this
limitation for gso skbs.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/sched/sch_tbf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 35bfd49..7ee5bff 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -121,7 +121,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	struct tbf_sched_data *q = qdisc_priv(sch);
 	int ret;
 
-	if (qdisc_pkt_len(skb) > q->max_size)
+	if (qdisc_pkt_len(skb) > q->max_size && !skb_is_gso(skb))
 		return qdisc_reshape_fail(skb, sch);
 
 	ret = qdisc_enqueue(skb, q->qdisc);
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [patch net-next 1/7] htb: use PSCHED_TICKS2NS()
  2013-02-08 12:58 ` [patch net-next 1/7] htb: use PSCHED_TICKS2NS() Jiri Pirko
@ 2013-02-08 15:51   ` Eric Dumazet
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 15:51 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/sched/sch_htb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 51561ea..476992c 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -1512,8 +1512,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
>  	htb_precompute_ratedata(&cl->rate);
>  	htb_precompute_ratedata(&cl->ceil);
>  
> -	cl->buffer = hopt->buffer << PSCHED_SHIFT;
> -	cl->cbuffer = hopt->buffer << PSCHED_SHIFT;
> +	cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
> +	cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer);
>  
>  	sch_tree_unlock(sch);
>  

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 2/7] htb: fix values in opt dump
  2013-02-08 12:58 ` [patch net-next 2/7] htb: fix values in opt dump Jiri Pirko
@ 2013-02-08 15:54   ` Eric Dumazet
  2013-02-08 16:02     ` Jiri Pirko
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 15:54 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> in htb_change_class() cl->buffer and cl->buffer are stored in ns.
> So in dump, convert them back to psched ticks.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/sched/sch_htb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 476992c..14a83dc 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -1135,9 +1135,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
>  	memset(&opt, 0, sizeof(opt));
>  
>  	opt.rate.rate = cl->rate.rate_bps >> 3;
> -	opt.buffer = cl->buffer;
> +	opt.buffer = PSCHED_NS2TICKS(cl->buffer);
>  	opt.ceil.rate = cl->ceil.rate_bps >> 3;
> -	opt.cbuffer = cl->cbuffer;
> +	opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
>  	opt.quantum = cl->quantum;
>  	opt.prio = cl->prio;
>  	opt.level = cl->level;

Acked-by: Eric Dumazet <edumazet@google.com>

Isnt it a patch for net tree (and stable) ?

A bug origin (commit id/title) is welcomed to ease stable team work.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 2/7] htb: fix values in opt dump
  2013-02-08 15:54   ` Eric Dumazet
@ 2013-02-08 16:02     ` Jiri Pirko
  0 siblings, 0 replies; 16+ messages in thread
From: Jiri Pirko @ 2013-02-08 16:02 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem, edumazet, jhs, kuznet

Fri, Feb 08, 2013 at 04:54:09PM CET, eric.dumazet@gmail.com wrote:
>On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
>> in htb_change_class() cl->buffer and cl->buffer are stored in ns.
>> So in dump, convert them back to psched ticks.
>> 
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> ---
>>  net/sched/sch_htb.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
>> index 476992c..14a83dc 100644
>> --- a/net/sched/sch_htb.c
>> +++ b/net/sched/sch_htb.c
>> @@ -1135,9 +1135,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
>>  	memset(&opt, 0, sizeof(opt));
>>  
>>  	opt.rate.rate = cl->rate.rate_bps >> 3;
>> -	opt.buffer = cl->buffer;
>> +	opt.buffer = PSCHED_NS2TICKS(cl->buffer);
>>  	opt.ceil.rate = cl->ceil.rate_bps >> 3;
>> -	opt.cbuffer = cl->cbuffer;
>> +	opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
>>  	opt.quantum = cl->quantum;
>>  	opt.prio = cl->prio;
>>  	opt.level = cl->level;
>
>Acked-by: Eric Dumazet <edumazet@google.com>
>
>Isnt it a patch for net tree (and stable) ?

That may be.

>
>A bug origin (commit id/title) is welcomed to ease stable team work.


Okay. I will repost the patchset anyway because I misspelled "peak"
(and I will probably add similar patches I did for tbf for act_police).
I will include your acks and commit id/title.

Jiri
>
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 3/7] htb: remove pointless first initialization of buffer and cbuffer
  2013-02-08 12:58 ` [patch net-next 3/7] htb: remove pointless first initialization of buffer and cbuffer Jiri Pirko
@ 2013-02-08 16:35   ` Eric Dumazet
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 16:35 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> these are initialized correctly couple of lines later in the function.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/sched/sch_htb.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 14a83dc..547912e9 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -1503,9 +1503,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
>  			cl->prio = TC_HTB_NUMPRIO - 1;
>  	}
>  
> -	cl->buffer = hopt->buffer;
> -	cl->cbuffer = hopt->cbuffer;
> -
>  	cl->rate.rate_bps = (u64)hopt->rate.rate << 3;
>  	cl->ceil.rate_bps = (u64)hopt->ceil.rate << 3;
>  

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 4/7] htb: initialize cl->tokens and cl->ctokens correctly
  2013-02-08 12:58 ` [patch net-next 4/7] htb: initialize cl->tokens and cl->ctokens correctly Jiri Pirko
@ 2013-02-08 16:36   ` Eric Dumazet
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 16:36 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> These are in ns so convert from ticks to ns.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/sched/sch_htb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 547912e9..2b22544 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -1459,8 +1459,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
>  		cl->parent = parent;
>  
>  		/* set class to be in HTB_CAN_SEND state */
> -		cl->tokens = hopt->buffer;
> -		cl->ctokens = hopt->cbuffer;
> +		cl->tokens = PSCHED_TICKS2NS(hopt->buffer);
> +		cl->ctokens = PSCHED_TICKS2NS(hopt->cbuffer);
>  		cl->mbuffer = 60 * PSCHED_TICKS_PER_SEC;	/* 1min */
>  		cl->t_c = psched_get_time();
>  		cl->cmode = HTB_CAN_SEND;

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 5/7] sch: make htb_rate_cfg and functions around that generic
  2013-02-08 12:58 ` [patch net-next 5/7] sch: make htb_rate_cfg and functions around that generic Jiri Pirko
@ 2013-02-08 16:39   ` Eric Dumazet
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 16:39 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> As it is going to be used in tbf as well, push these to generic code.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  include/net/sch_generic.h | 18 +++++++++++++
>  net/sched/sch_generic.c   | 37 +++++++++++++++++++++++++++
>  net/sched/sch_htb.c       | 65 +++++++----------------------------------------
>  3 files changed, 64 insertions(+), 56 deletions(-)
> 
> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> index 2d06c2a..c7e5512 100644
> --- a/include/net/sch_generic.h
> +++ b/include/net/sch_generic.h
> @@ -679,4 +679,22 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask,
>  }
>  #endif
>  
> +struct psched_ratecfg {
> +	u64 rate_bps;
> +	u32 mult;
> +	u32 shift;
> +};
> +
> +static inline u64 psched_l2t_ns(struct psched_ratecfg *r, unsigned int len)

 const struct psched_ratecfg *r

> +{
> +	return ((u64)len * r->mult) >> r->shift;
> +}
> +
> +extern void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate);
> +
> +static inline u32 psched_ratecfg_getrate(struct psched_ratecfg *r)

const struct psched_ratecfg *r

> +{
> +	return r->rate_bps >> 3;
> +}
> +

other than that, patch is fine.

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 6/7] tbf: improved accuracy at high rates
  2013-02-08 12:58 ` [patch net-next 6/7] tbf: improved accuracy at high rates Jiri Pirko
@ 2013-02-08 16:42   ` Eric Dumazet
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 16:42 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> Current TBF uses rate table computed by the "tc" userspace program,
> which has the following issue:
> 
> The rate table has 256 entries to map packet lengths to
> token (time units).  With TSO sized packets, the 256 entry granularity
> leads to loss/gain of rate, making the token bucket inaccurate.
> 
> Thus, instead of relying on rate table, this patch explicitly computes
> the time and accounts for packet transmission times with nanosecond
> granularity.
> 
> This is a followup to 56b765b79e9a78dc7d3f8850ba5e5567205a3ecd
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/sched/sch_tbf.c | 60 ++++++++++++++++++++++++++---------------------------
>  1 file changed, 29 insertions(+), 31 deletions(-)
> 
> diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
> index 4b056c15..35bfd49 100644
> --- a/net/sched/sch_tbf.c
> +++ b/net/sched/sch_tbf.c
> @@ -19,6 +19,7 @@
>  #include <linux/errno.h>
>  #include <linux/skbuff.h>
>  #include <net/netlink.h>
> +#include <net/sch_generic.h>
>  #include <net/pkt_sched.h>
>  
> 
> @@ -100,23 +101,21 @@
>  struct tbf_sched_data {
>  /* Parameters */
>  	u32		limit;		/* Maximal length of backlog: bytes */
> -	u32		buffer;		/* Token bucket depth/rate: MUST BE >= MTU/B */
> +	s64		buffer;		/* Token bucket depth/rate: MUST BE >= MTU/B */
>  	u32		mtu;
>  	u32		max_size;
> -	struct qdisc_rate_table	*R_tab;
> -	struct qdisc_rate_table	*P_tab;
> +	struct psched_ratecfg rate;
> +	struct psched_ratecfg peek;
> +	bool peek_present;
>  

Seems good to me, I'll add my Ack when you resend it with 'peak' typo
and after my tests.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch net-next 7/7] tbf: ignore max_size check for gso skbs
  2013-02-08 12:58 ` [patch net-next 7/7] tbf: ignore max_size check for gso skbs Jiri Pirko
@ 2013-02-08 16:43   ` Eric Dumazet
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Dumazet @ 2013-02-08 16:43 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, edumazet, jhs, kuznet

On Fri, 2013-02-08 at 13:58 +0100, Jiri Pirko wrote:
> This check made bigger packets incorrectly dropped. Remove this
> limitation for gso skbs.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/sched/sch_tbf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
> index 35bfd49..7ee5bff 100644
> --- a/net/sched/sch_tbf.c
> +++ b/net/sched/sch_tbf.c
> @@ -121,7 +121,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc *sch)
>  	struct tbf_sched_data *q = qdisc_priv(sch);
>  	int ret;
>  
> -	if (qdisc_pkt_len(skb) > q->max_size)
> +	if (qdisc_pkt_len(skb) > q->max_size && !skb_is_gso(skb))
>  		return qdisc_reshape_fail(skb, sch);
>  
>  	ret = qdisc_enqueue(skb, q->qdisc);

Acked-by: Eric Dumazet <edumazet@gogle.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-02-08 16:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 12:58 [patch net-next 0/7] couple of net/sched fixes+improvements Jiri Pirko
2013-02-08 12:58 ` [patch net-next 1/7] htb: use PSCHED_TICKS2NS() Jiri Pirko
2013-02-08 15:51   ` Eric Dumazet
2013-02-08 12:58 ` [patch net-next 2/7] htb: fix values in opt dump Jiri Pirko
2013-02-08 15:54   ` Eric Dumazet
2013-02-08 16:02     ` Jiri Pirko
2013-02-08 12:58 ` [patch net-next 3/7] htb: remove pointless first initialization of buffer and cbuffer Jiri Pirko
2013-02-08 16:35   ` Eric Dumazet
2013-02-08 12:58 ` [patch net-next 4/7] htb: initialize cl->tokens and cl->ctokens correctly Jiri Pirko
2013-02-08 16:36   ` Eric Dumazet
2013-02-08 12:58 ` [patch net-next 5/7] sch: make htb_rate_cfg and functions around that generic Jiri Pirko
2013-02-08 16:39   ` Eric Dumazet
2013-02-08 12:58 ` [patch net-next 6/7] tbf: improved accuracy at high rates Jiri Pirko
2013-02-08 16:42   ` Eric Dumazet
2013-02-08 12:58 ` [patch net-next 7/7] tbf: ignore max_size check for gso skbs Jiri Pirko
2013-02-08 16:43   ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.