Re: [PATCH] pkt_sched: gen_estimator: use 64 bits intermediate counters for bps
From: Jarek Poplawski <hidden>
Date: 2009-05-19 07:42:57
From: Jarek Poplawski <hidden>
Date: 2009-05-19 07:42:57
On Tue, May 19, 2009 at 09:31:36AM +0200, Eric Dumazet wrote:
Jarek Poplawski a écrit :quoted
On Tue, May 19, 2009 at 01:59:55AM +0200, Eric Dumazet wrote: ...quoted
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c...quoted
- e->avbps += ((long)rate - (long)e->avbps) >> e->ewma_log; + e->avbps += ((s64)(brate - e->avbps)) >> e->ewma_log;Btw., I'm a bit concerned about the syntax here: isn't such shifting of signed ints implementation dependant?You are right Jarek, I very often forget to never ever use signed quantities at all ! (But also note original code has same undefined behavior)
Sure, I've meant the original code including 5 lines below.
Apparently gcc does the *right* thing on x86_32, but we probably want something stronger here. I could not find gcc documentation statement on right shifts of negative values.
I guess gcc and most of others do this "right"; but it looks "unkosher" anyway. Jarek P.