[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B7471@saturn3.aculab.com>
Date: Mon, 9 Dec 2013 10:07:53 -0000
From: "David Laight" <David.Laight@...LAB.COM>
To: "Yang Yingliang" <yangyingliang@...wei.com>, <davem@...emloft.net>,
<netdev@...r.kernel.org>
Cc: <eric.dumazet@...il.com>, <brouer@...hat.com>, <jpirko@...hat.com>,
<jbrouer@...hat.com>
Subject: RE: [PATCH net v6 1/2] net: sched: tbf: fix the calculation of max_size
> From: Yang Yingliang
> On 2013/12/6 18:56, David Laight wrote:
> >> From: Yang Yingliang
> > ...
> >
> > You are multiplying two values then dividing by 10**9
> > I'd guess that the intermediate value might exceed 2**64.
> >
> >> + if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
> >> + len = (len / 53) * 48;
> >
> > You probably want to do the multiply first.
> > But why not scale rate_bytes_ps instead.
> >
>
> When the linklayer is ATM, the formula to calculate tokens is:
>
> ((u64)(DIV_ROUND_UP(len,48)*53) * r->mult) >> r->shift
>
> So, I scale len here.
Seems to me that there are a lot of unnecessary multiplies and
divides going on here.
Looks to me like the code was originally written to require one
multiply and one shift for each packet.
In any case the latter code is allowing for more of the ATM cell
overhead. I'm not at all sure the intent is to remove that when
setting up the constants.
OTOH should this code be worrying about the packet overheads at all?
Does it add in the ethernet pre-emable, CRC and inter packet gap?
I'd guess that the most the ATM code should do it round the length
up to a multiple of 48 (user payload in a cell).
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists