netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	netdev <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<brouer@redhat.com>, <jpirko@redhat.com>, <jbrouer@redhat.com>
Subject: Re: [PATCH] net: sched: tbf: fix calculation of max_size
Date: Tue, 26 Nov 2013 09:28:15 +0800	[thread overview]
Message-ID: <5293F92F.606@huawei.com> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B7443@saturn3.aculab.com>

On 2013/11/25 20:22, David Laight wrote:
>> From: Yang Yingliang <yangyingliang@huawei.com>
>>
>> Current max_size is caluated from rate table. Now, the rate table
>> has been replaced and it's wrong to caculate max_size based on this
>> rate table. It can lead wrong calculation of max_size.
>>
>> The burst in kernel may be lower than user asked, because burst may gets
>> some loss when transform it to buffer(E.g. "burst 40kb rate 30mbit/s")
>> and it seems we cannot avoid this loss. And burst's value(max_size) based
>> on rate table may be equal user asked. If a packet's length is max_size,
>> this packet will be stalled in tbf_dequeue() because its length is above
>> the burst in kernel so that it cannot get enough tokens. The max_size guards
>> against enqueuing packet sizes above q->buffer "time" in tbf_enqueue().
> 
> Why not adjust the calculations so that the number of allocated tokens
> can go negative?
> 
> So allow the transfer if the number of tokens is +ve and then subtract
> the number needed for the message itself.

Thanks for your advice!
I had considered it before. But, I think that we calculate tokens from ns
but max_size is calculated based on rate table causes the problem. I think we
should make them consistent.

> 
> I think this would change the semantics of the configured 'burst' value
> very slightly (to 'at least' from 'at most') but the average would still
> be correct.

Hmm, I'm not sure it is 'at least'. Maybe it could be lower.

Regards,
Yang

> 
> FWIW I've done similar rate limiters that run directly in units of 'time'.
> The fact that system time advances automatically generates credit.
> 
> 	David
> 
> 

  reply	other threads:[~2013-11-26  1:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  7:25 [PATCH net v3 0/2] net: sched: fix some issues Yang Yingliang
2013-11-19  7:25 ` [PATCH net v3 1/2] net: sched: tbf: fix calculation of max_size Yang Yingliang
2013-11-19  9:38   ` Jesper Dangaard Brouer
2013-11-20  2:14     ` Yang Yingliang
2013-11-20 10:04       ` Jesper Dangaard Brouer
2013-11-20 12:50         ` Yang Yingliang
2013-11-23 19:06   ` Eric Dumazet
2013-11-24  7:28     ` Yang Yingliang
2013-11-24 18:40       ` Eric Dumazet
2013-11-25  3:43         ` Yang Yingliang
2013-11-25 12:04           ` [PATCH] " Yang Yingliang
2013-11-25 12:22             ` David Laight
2013-11-26  1:28               ` Yang Yingliang [this message]
2013-11-26  2:35                 ` Yang Yingliang
2013-12-02  1:11               ` David Miller
2013-12-02 10:29                 ` David Laight
2013-12-02 16:45             ` David Miller
2013-12-03  0:59               ` Yang Yingliang
2013-11-19  7:25 ` [PATCH net v3 2/2] net: sched: htb: fix 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=5293F92F.606@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).