netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Jonathan Lennox <jonathan.lennox@8x8.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] tc: Fix rounding in tc_calc_xmittime and tc_calc_xmitsize.
Date: Sun, 16 Feb 2025 22:14:44 -0800	[thread overview]
Message-ID: <20250216221444.6a94a0fe@hermes.local> (raw)
In-Reply-To: <85371219-A098-4873-B3B9-0E881E812F2A@8x8.com>

On Wed, 5 Feb 2025 16:16:21 -0500
Jonathan Lennox <jonathan.lennox@8x8.com> wrote:

> The logic in tc that converts between sizes and times for a given rate (the
> functions tc_calc_xmittime and tc_calc_xmitsize) suffers from double rounding,
> with intermediate values getting cast to unsigned int.
> 
> As a result, for example, on my test system (where tick_in_usec=15.625,
> clock_factor=1, and hz=1000000000) for a bitrate of 1Gbps, all tc htb burst
> values between 0 and 999 get encoded as 0; all values between 1000 and 1999
> get encoded as 15 (equivalent to 960 bytes); all values between 2000 and 2999
> as 31 (1984 bytes); etc.
> 
> The attached patch changes this so these calculations are done entirely in
> floating-point, and only rounded to integer values when the value is returned.
> It also changes tc_calc_xmittime to round its calculated value up, rather than
> down, to ensure that the calculated time is actually sufficient for the requested
> size.
> 
> This is a userspace-only fix to tc; no kernel changes are necessary.
> 
> (Please let me know if anything is wrong with this patch, this is my first
> time submitting to any Linux kernel mailing lists.)
> 
> ---

The concept makes sense, but is missing a valid Signed-Off-by: and therefore
needs to be resent.

Also, you don't need to rename the functions, why not always use floating point


  reply	other threads:[~2025-02-17  6:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 21:16 [PATCH iproute2] tc: Fix rounding in tc_calc_xmittime and tc_calc_xmitsize Jonathan Lennox
2025-02-17  6:14 ` Stephen Hemminger [this message]
2025-02-18 20:10   ` Jonathan Lennox
2025-02-18 20:10   ` [PATCH iproute2 v2] " Jonathan Lennox
2025-02-24  3:06     ` David Ahern
2025-02-24 16:36       ` Jonathan Lennox
2025-02-24 16:58         ` David Ahern
2025-02-24 18:42           ` [PATCH iproute2 v3] " Jonathan Lennox
2025-02-26 16:06             ` David Ahern
2025-02-26 18:55               ` Jonathan Lennox
2025-02-26 18:53           ` Jonathan Lennox
2025-02-28 15:50             ` patchwork-bot+netdevbpf
2025-03-03 18:39               ` Pedro Tammela
2025-03-03 19:43                 ` Jonathan Lennox
2025-03-03 20:35                   ` Pedro Tammela
2025-03-03 22:13                     ` Jonathan Lennox
2025-03-04 17:51                       ` Pedro Tammela
2025-03-04 19:38                         ` [PATCH net-next] tc-tests: Update tc police action tests for tc buffer size rounding fixes Jonathan Lennox
2025-03-11  9:16                           ` Paolo Abeni
2025-03-11  9:49                             ` Jakub Kicinski
2025-03-11 11:15                               ` Jamal Hadi Salim
2025-03-12 17:42                                 ` Jonathan Lennox
2025-03-26 11:39                                 ` Jakub Kicinski
2025-03-26 19:04                                   ` Pedro Tammela
2025-03-26 19:07                                     ` Pedro Tammela
2025-03-12 16:47                         ` [PATCH net-next v2] " Jonathan Lennox
2025-03-12 17:48                         ` [PATCH net-next v3] " Jonathan Lennox
2025-03-12 17:48                           ` Jonathan Lennox
2025-03-19 17:50                           ` patchwork-bot+netdevbpf

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=20250216221444.6a94a0fe@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=jonathan.lennox@8x8.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).