Netdev List
 help / color / mirror / Atom feed
* [PATCH] sch_red: fix red_calc_qavg_from_idle_time
@ 2011-11-30 21:34 Eric Dumazet
  2011-11-30 21:40 ` Eric Dumazet
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2011-11-30 21:34 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Stephen Hemminger, David Täht

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

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

end of thread, other threads:[~2011-12-01 17:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-30 21:34 [PATCH] sch_red: fix red_calc_qavg_from_idle_time Eric Dumazet
2011-11-30 21:40 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox