From: Yang Yingliang <yangyingliang@huawei.com>
To: David Laight <David.Laight@ACULAB.COM>, <davem@davemloft.net>,
<netdev@vger.kernel.org>
Cc: <eric.dumazet@gmail.com>, <brouer@redhat.com>,
<jpirko@redhat.com>, <jbrouer@redhat.com>
Subject: Re: [PATCH net v6 1/2] net: sched: tbf: fix the calculation of max_size
Date: Mon, 9 Dec 2013 11:26:02 +0800 [thread overview]
Message-ID: <52A5384A.8050106@huawei.com> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B7468@saturn3.aculab.com>
On 2013/12/6 18:56, David Laight wrote:
>> From: Yang Yingliang
> ...
>>
>> +/* Time to Length, convert time in ns to length in bytes
>> + * to determinate how many bytes can be sent in given time.
>> + */
>> +static u64 psched_ns_t2l(const struct psched_ratecfg *r,
>> + u64 time_in_ns)
>> +{
>> + /* The formula is :
>> + * len = (time_in_ns * r->rate_bytes_ps) / NSEC_PER_SEC
>> + */
>> + u64 len = time_in_ns * r->rate_bytes_ps;
>> +
>> + do_div(len, NSEC_PER_SEC);
>
> 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.
Regards,
Yang
next prev parent reply other threads:[~2013-12-09 3:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 7:00 [PATCH net v6 0/2] net: sched: fix two issues Yang Yingliang
2013-12-06 7:00 ` [PATCH net v6 1/2] net: sched: tbf: fix the calculation of max_size Yang Yingliang
2013-12-06 10:56 ` David Laight
2013-12-09 2:26 ` Yang Yingliang
2013-12-09 3:26 ` Yang Yingliang [this message]
2013-12-09 10:07 ` David Laight
2013-12-09 12:21 ` Yang Yingliang
2013-12-09 13:10 ` [PATCH RFC ] " Yang Yingliang
2013-12-09 15:12 ` Eric Dumazet
2013-12-10 2:29 ` Yang Yingliang
2013-12-10 2:39 ` Eric Dumazet
2013-12-09 13:11 ` [PATCH net v6 1/2] " David Laight
2013-12-10 2:04 ` Yang Yingliang
2013-12-06 7:00 ` [PATCH net v6 2/2] net: sched: htb: fix the calculation of quantum Yang Yingliang
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=52A5384A.8050106@huawei.com \
--to=yangyingliang@huawei.com \
--cc=David.Laight@ACULAB.COM \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jbrouer@redhat.com \
--cc=jpirko@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.