All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Mohamed Dawod <mhm.dawod@gmail.com>, netdev@vger.kernel.org
Cc: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, ye.zh-yuan@socionext.com,
	linux-kernel@vger.kernel.org, Mohamed Dawod <mhm.dawod@gmail.com>
Subject: Re: [PATCH net] net/sched: cbs: fix 32-bit overflow in transmission time estimate
Date: Thu, 19 Nov 2026 16:17:06 -0800	[thread overview]
Message-ID: <871p8gtkzh.fsf@intel.com> (raw)
In-Reply-To: <20261119053357.2033707-1-mhm.dawod@gmail.com>

Mohamed Dawod <mhm.dawod@gmail.com> writes:

> cbs_dequeue_soft() estimates when the transmission of a packet completes:
>
> 	q->last = now + div64_s64(len * NSEC_PER_SEC, port_rate);
>
> len is an int and NSEC_PER_SEC is 1000000000L. On 32-bit architectures
> long is 32 bits wide, so the product is computed in 32 bits and wraps
> before it is widened for div64_s64(). For a 1242 byte frame the product
> is 1242000000000 mod 2^32 = 754451456, which gives a transmission time
> of about 60 ns at 100 Mbit/s instead of about 99 us.
>
> As a result q->last stays almost equal to now and the packet sending
> time is ignored again, which is the problem 'commit 961d0e5b3294
> ("net: cbs: Fix software cbs to consider packet sending time")'
> set out to fix. The throughput becomes
>
> 	idleslope * port_rate / |sendslope|
>
> instead of idleslope.
>
> Measured on a BeagleBone Black (32-bit ARM, CPSW, 100 Mbit/s full
> duplex) with software CBS (offload 0), one UDP flow with a 1200 byte
> payload (1242 byte frames), sendslope = idleslope - 100000. The rate
> was read from the qdisc byte counters:
>
> 	idleslope [kbit/s]   before [Mbit/s]   after [Mbit/s]
> 	10000                11.1              10
> 	20000                25.0              20
> 	30000                42.9              30
>
> Cast len to s64 so the multiplication is done in 64 bits on all
> architectures.
>
> Fixes: 961d0e5b3294 ("net: cbs: Fix software cbs to consider packet sending time")
> Signed-off-by: Mohamed Dawod <mhm.dawod@gmail.com>

It seems that you had tool issues and the diff ended up being
duplicated. With that mechanical/process issue fixed:

Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>

It seems that it would also save CPU time, less 'qdisc_watchdog' being
scheduled without being able to make any progress.


Cheers,
-- 
Vinicius

      reply	other threads:[~2026-11-20  0:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  5:33 [PATCH net] net/sched: cbs: fix 32-bit overflow in transmission time estimate Mohamed Dawod
2026-11-20  0:17 ` Vinicius Costa Gomes [this message]

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=871p8gtkzh.fsf@intel.com \
    --to=vinicius.gomes@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhm.dawod@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ye.zh-yuan@socionext.com \
    /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.