From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
"Stephen Hemminger" <shemminger@vyatta.com>,
"David Täht" <dave.taht@gmail.com>
Subject: [PATCH] sch_red: fix red_calc_qavg_from_idle_time
Date: Wed, 30 Nov 2011 22:34:51 +0100 [thread overview]
Message-ID: <1322688891.2602.15.camel@edumazet-laptop> (raw)
Since commit a4a710c4a7490587 (pkt_sched: Change PSCHED_SHIFT from 10 to
6) it seems [G]RED are broken in red_calc_qavg_from_idle_time()
This function computes a delay in us units, but this delay is now 16
times bigger than real delay, so the final qavg result is wrong...
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
Maybe we should use native kernel time services in red ?
(ktime_get(), ktime_us_delta())
include/net/pkt_sched.h | 1 +
include/net/red.h | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index fffdc60..c719d9b 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -43,6 +43,7 @@ typedef long psched_tdiff_t;
/* Avoid doing 64 bit divide */
#define PSCHED_SHIFT 6
#define PSCHED_TICKS2NS(x) ((s64)(x) << PSCHED_SHIFT)
+#define PSCHED_TICKS2US(x) (PSCHED_TICKS2NS(x) >> 10) /* approximate 1000 by 1024 */
#define PSCHED_NS2TICKS(x) ((x) >> PSCHED_SHIFT)
#define PSCHED_TICKS_PER_SEC PSCHED_NS2TICKS(NSEC_PER_SEC)
diff --git a/include/net/red.h b/include/net/red.h
index 3319f16..a413638 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -175,7 +175,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p)
int shift;
now = psched_get_time();
- us_idle = psched_tdiff_bounded(now, p->qidlestart, p->Scell_max);
+ us_idle = PSCHED_TICKS2US(psched_tdiff_bounded(now, p->qidlestart, p->Scell_max));
/*
* The problem: ideally, average length queue recalcultion should
next reply other threads:[~2011-11-30 21:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-30 21:34 Eric Dumazet [this message]
2011-11-30 21:40 ` [PATCH] sch_red: fix red_calc_qavg_from_idle_time Eric Dumazet
2011-11-30 22:10 ` [PATCH V2] " Eric Dumazet
2011-11-30 22:35 ` Dave Taht
2011-11-30 22:44 ` Eric Dumazet
2011-12-01 11:04 ` [PATCH iproute2] red: give a hint about burst value Eric Dumazet
2011-12-01 14:25 ` [PATCH iproute2] red: make burst optional Eric Dumazet
2011-12-01 17:24 ` Stephen Hemminger
2011-12-01 4:29 ` [PATCH V2] sch_red: fix red_calc_qavg_from_idle_time David Miller
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=1322688891.2602.15.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=dave.taht@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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