From: Hangbin Liu <hangbin.liu@linux.dev>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Jay Vosburgh <jv@jvosburgh.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Nikolay Aleksandrov <razor@blackwall.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Hangbin Liu <liuhangbin@kylinos.cn>
Subject: Re: [PATCH net v5 2/2] bonding: fix u32 overflow in compute_gap()
Date: Fri, 28 Aug 2026 09:28:12 +0800 [thread overview]
Message-ID: <apDkLDjq7atCR97E@fedora> (raw)
In-Reply-To: <d045bf04-be89-41ad-bd0a-b62fe4de8dfe@redhat.com>
On Thu, Aug 27, 2026 at 03:42:23PM +0200, Paolo Abeni wrote:
> > @@ -170,8 +171,14 @@ static void tlb_deinitialize(struct bonding *bond)
> >
> > static long long compute_gap(struct slave *slave)
> > {
> > - return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */
> > - (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
> > + u32 raw_speed = READ_ONCE(slave->speed);
> > +
> > + /* It's meaningless to compare gap on unknown speed NIC */
> > + if (raw_speed == (u32)SPEED_UNKNOWN)
> > + return LLONG_MIN;
>
> Sashiko noted the above could entirely disable:
>
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260825-bond_overflow-v5-0-7a800de133f1%40kylinos.cn
>
> I think the v2 code for the above should be fine.
Thanks, it looks like I was over‑thinking this.
I was considering a case with two slaves: one at 1 Gbit/s and another at
10 Gbit/s. Once traffic exceeds 1 Gbit/s, `compute_gap` may still select the
1 Gbit/s slave, which leads to overload.
In any case, this behavior is still better than no balancing at all. I will fix this.
Thanks
Hangbin
next prev parent reply other threads:[~2026-08-28 1:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 1:01 [PATCH net v5 0/2] bonding: fix TLB load-tracking overflow on high-speed NICs Hangbin Liu
2026-08-25 1:01 ` [PATCH net v5 1/2] bonding: convert unbalanced_load to per-cpu state Hangbin Liu
2026-08-26 7:34 ` Nikolay Aleksandrov
2026-08-25 1:01 ` [PATCH net v5 2/2] bonding: fix u32 overflow in compute_gap() Hangbin Liu
2026-08-26 7:34 ` Nikolay Aleksandrov
2026-08-27 13:42 ` Paolo Abeni
2026-08-28 1:28 ` Hangbin Liu [this message]
2026-08-27 18:20 ` David Laight
2026-08-27 19:09 ` Nikolay Aleksandrov
2026-08-27 20:56 ` David Laight
2026-08-28 9:19 ` Nikolay Aleksandrov
2026-08-31 1:23 ` Hangbin Liu
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=apDkLDjq7atCR97E@fedora \
--to=hangbin.liu@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.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.