netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, jhs@mojatatu.com,
	kuznet@ms2.inr.ac.ru, j.vimal@gmail.com
Subject: [patch net-next v4 08/11] tbf: fix value set for q->ptokens
Date: Sun, 10 Feb 2013 11:52:16 +0100	[thread overview]
Message-ID: <1360493539-14868-9-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1360493539-14868-1-git-send-email-jiri@resnulli.us>

q->ptokens is in ns and we are assigning q->mtu directly to it. That is
wrong. psched_l2t_ns() should be used to compute correct value.

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

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index dc562a8..0ac6224 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -111,6 +111,7 @@ struct tbf_sched_data {
 /* Variables */
 	s64	tokens;			/* Current number of B tokens */
 	s64	ptokens;		/* Current number of P tokens */
+	s64	mtu_ptokens;
 	psched_time_t	t_c;		/* Time check-point */
 	struct Qdisc	*qdisc;		/* Inner qdisc, default - bfifo queue */
 	struct qdisc_watchdog watchdog;	/* Watchdog timer */
@@ -165,8 +166,8 @@ static struct sk_buff *tbf_dequeue(struct Qdisc *sch)
 
 		if (q->peak_present) {
 			ptoks = toks + q->ptokens;
-			if (ptoks > (long)q->mtu)
-				ptoks = q->mtu;
+			if (ptoks > q->mtu_ptokens)
+				ptoks = q->mtu_ptokens;
 			ptoks -= (s64) psched_l2t_ns(&q->peak, len);
 		}
 		toks += q->tokens;
@@ -215,7 +216,8 @@ static void tbf_reset(struct Qdisc *sch)
 	sch->q.qlen = 0;
 	q->t_c = ktime_to_ns(ktime_get());
 	q->tokens = q->buffer;
-	q->ptokens = q->mtu;
+	if (q->peak_present)
+		q->ptokens = q->mtu_ptokens;
 	qdisc_watchdog_cancel(&q->watchdog);
 }
 
@@ -296,11 +298,12 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
 	q->max_size = max_size;
 	q->buffer = PSCHED_TICKS2NS(qopt->buffer);
 	q->tokens = q->buffer;
-	q->ptokens = q->mtu;
 
 	psched_ratecfg_precompute(&q->rate, rtab->rate.rate);
 	if (ptab) {
 		psched_ratecfg_precompute(&q->peak, ptab->rate.rate);
+		q->mtu_ptokens = (s64) psched_l2t_ns(&q->peak, q->mtu);
+		q->ptokens = q->mtu_ptokens;
 		q->peak_present = true;
 	} else {
 		q->peak_present = false;
-- 
1.8.1.2

  parent reply	other threads:[~2013-02-10 10:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10 10:52 [patch net-next v4 00/11] couple of net/sched fixes+improvements Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 01/11] htb: use PSCHED_TICKS2NS() Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 02/11] htb: fix values in opt dump Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 03/11] htb: remove pointless first initialization of buffer and cbuffer Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 04/11] htb: initialize cl->tokens and cl->ctokens correctly Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 05/11] sch: make htb_rate_cfg and functions around that generic Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 06/11] tbf: improved accuracy at high rates Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 07/11] tbf: ignore max_size check for gso skbs Jiri Pirko
2013-02-11 21:02   ` Jiri Pirko
2013-02-11 21:11     ` David Miller
2013-02-10 10:52 ` Jiri Pirko [this message]
2013-02-10 10:52 ` [patch net-next v4 09/11] act_police: move struct tcf_police to act_police.c Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 10/11] act_police: improved accuracy at high rates Jiri Pirko
2013-02-10 10:52 ` [patch net-next v4 11/11] act_police: remove <=mtu check for gso skbs Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360493539-14868-9-git-send-email-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=j.vimal@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).