From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796479260; b=Sfsw07Pb7pjrnsB9QGdWM2srAIZUoJ+DQ7CYo7QFzdbMFFUYCABS6yxCsUY54TbkW2sq CgpXv4lOeSMGWoTXY5Sbj5ukv3QUb2OuHztLrHT0P6RKXTBaDNqnKrsQUPH+o6ND/+FQ7 HOQGEO1vaZnv0F1VmKT8UpURjoiFG8zzb9NY/BVm1lQRS0oRbFeiMsEI0hzrs0STm6vcD 59CKFnzzMgmobIMscEQYOud3zuNH08STAoTeSYIXnwsVYzChuqA1HqbnRhjOgnZyKnFGP swsodjMqx84EBcT5wWOs7DMeynmIfcSqtVYd6Ib9oigpFbPjkcaj+E6pJbi88f0BsDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796479260; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; bh=KLijNmq4g1wU1Ae3eiF06QDK7onyEaCWUeScX4v/808=; b=MbXoCNGbjB4DDFhyrue32Zbj8ZqSsJ+sSRe4In7GEOCeY1Gk5yhP5rj7UKcIpj0g+NWg v923it6H6ySjHfh5ZtVV5l/6GEZsfarjIJ7voQl7/iP2YKtGXnM5BdbEa4SjnviaLYeNg K/3olCmPzB1HCBBgDEZdMZhDTrppBDUCAXSmRQcjW9RGtS/J+KfHXoY63lOVRhS1FSzK+ p4kOXUD56WNR7FfdA026RVPQS8EzgYR9wD8oMFW0hAn3gYUw2rHvqno/Xyc0udl3KkUTi RpLpyelTZ6W/VvxXGdEadEItKScX4NvTsAypTgs62RysNeWT5jSO78UsZxmDsyxtrgA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=o2uO8KUs; arc=none smtp.remote-ip=209.85.128.44 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE8CA606A322 for ; Sat, 5 Dec 2026 14:00:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EE8CA606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=o2uO8KUs Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bba5e17cbeso16850235e9.1 for ; Sat, 05 Dec 2026 06:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796479258; x=1797084058; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=KLijNmq4g1wU1Ae3eiF06QDK7onyEaCWUeScX4v/808=; b=o2uO8KUs/8pAcn3Rls6PN4rvLEng21/4w7Q0FhUu6ognVedIEwc7q4PA/hNTNt+8kt GgfF6xWztWjWRXYSwZICszIPAgLyYdNlzVBg20IWYXxijvD46ZLZhd1dVqvjWrZjHLtv OaLOyLMP/fAjlCGfY24wasrTL/ffgJpD+oyMtXQ/D7IVaHRzIV6r+wj/HxeXrutahLVb FxkIdF/LkxUFuu90aS7j2j6+BFSTwqohh4SGrCyPn/erBaloiYbmg5r+T4s/HjR03cVg DBUk9I5OjmDFmMb9drr44JSDcx0+ldJ4j9X8le2xqmdTV5Ls71s+5pYVB4Wnboaqte+f 0fjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796479258; x=1797084058; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KLijNmq4g1wU1Ae3eiF06QDK7onyEaCWUeScX4v/808=; b=WKR99Erswl7dznCpZrLs9Hw2RpU9GoToHO1TMbhKoetN714177bFMEybDJdxHc9x7O TyQLKKaTf4oVQBYG+/RxQeOOuoXp92YBMQ6mi7+A4sBgMi8G3PDdK+Pm9y3ANHajDh0E JsfAm4K5EJqKbehdd4LAHAOxcKBjrR++c1R4PPXi4B7QaixAySxWDUlv1LAlI9QkgaHA /MwTXNxwjJsQRuyRE+MiRBmfnFZQzu7colNqRQhCudKhuI2KtcKnyKy94uxJHMPsMrKA wTzXd5b0pmOTiwoQuOtynzro7G7HLIEYw6Aoe9RhJ5ePaD4TzlJ9DOzYafGK+BNlt799 zGcw== X-Forwarded-Encrypted: i=1; AL+hErFUxMgHX+LAdmwA4YOn/D1WxYFcKgkOZD9TlbhD6nFNso7NRQeybFOM459W6+881n0LNeDAJlM=@vger.kernel.org X-Gm-Message-State: APuU4Z/wuFs45V4Py/cACUZYqcSoZsd8RSWyyaFk/nNt0tS4RfTG7eoh E0ze8Gtwe3An00F4oa3i1Li6s+f6d1VpMo/BeWzYCnom1O5LuAJIEKjm X-Gm-Gg: AZFdTZfndA3yqdNZE8DOeh++VK0th2+ggwRHdX0gp6fxFIvVtGJQlwViyLK77kBWShH 04LIBM2rTCxbXZZZ8Xyg2ZmmL6rrKBGQ0MIe5VzOL2cQaMcXb35TQaSgTbydRivHKDV/tbZ1BV/ HOzdSvJAfAnycRjjUAC7AToqKrBaX8SYs5r/+LV7sRBD0hzXQY22vIUwKdrp2cr/dsxwPxcohOp 8ilh6L/l9kEpZ+9TKBd3GMGor3qgdwk6Jt01KskeV93llIaugxKPxQwVAlQsPmtt3LDE3OdORP+ A/Ju1e2DqWQZ8KaHRM9e3fDSI/zaz6diEOFt1TJpN7/ttCtg4di9b6XD/8xi88sareOsgee1+Yc VtbqLQy+nAo38waR0ChNW/xzI+8umZIoPXfP8ACUuDj4X8tvx84ybMfeTnhUA1OXIfF8vGk257C Aniz9rarXYJ0tzULfnEytFtCWgAeU9uevDzDaxmuNsaWnpjt/H7e8Pot/Yx+Aupq+6xifO4ac5Y MTqiT0KESA95FljdN4BISzMg8D4vJwbRUW78TkysraVnOx/jqzo2Jir2xpe+q2iNj4aFBuwO4By iQvdgK96POi/nHMT244V6/iN4Ix1Tv5KcC188MmCDut/eEoXRq6CSI0V X-Received: by 2002:a05:600c:a11b:b0:4bb:efbd:20fb with SMTP id 5b1f17b1804b1-4bbefbd224cmr64294435e9.32.1796479258038; Sat, 05 Dec 2026 06:00:58 -0800 (PST) Received: from smtpclient.apple ([45.128.223.51]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe0030c6fsm254195065e9.2.2026.12.05.06.00.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Dec 2026 06:00:57 -0800 (PST) Content-Type: text/plain; charset=us-ascii X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH net v5 1/2] net/sched: cbs: use signed 64-bit math for BYTES_PER_KBIT conversions From: Jack Wang <163wangjack@gmail.com> In-Reply-To: Date: Sat, 5 Dec 2026 22:00:46 +0800 Cc: vinicius.gomes@intel.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, victor@mojatatu.com, mhm.dawod@gmail.com, esalomatkina@ispras.ru, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <511951B9-B7B2-48BC-9535-E092BA64F24D@gmail.com> References: <20261205073304.86227-1-163wangjack@gmail.com> <20261205073304.86227-2-163wangjack@gmail.com> To: andriy.shevchenko@linux.intel.com X-Mailer: Apple Mail (2.3864.600.51.1.1) On Sat, 5 Dec 2026 13:19:17 +0200, Andy Shevchenko wrote: > On Sat, Dec 05, 2026 at 03:33:03PM +0800, Jack Wang wrote: >> BYTES_PER_KBIT is unsigned long, so ILP32 uses 32-bit unsigned math. >> Since v6.8, negative sendslope turns positive, breaking software CBS >> and cbs_dump() while high idleslope/port_rate overflow. >>=20 >> Cast BYTES_PER_KBIT and speed in cbs_set_port_rate() to s64 to ensure >> signed 64-bit arithmetic on all architectures. >=20 > ... >=20 >> skip: >> - port_rate =3D speed * 1000 * BYTES_PER_KBIT; >> + port_rate =3D (s64)speed * 1000 * (s64)BYTES_PER_KBIT; >=20 > The second casting is redundant. Actually how do you expect port_rate = be > negative? >=20 > ... >=20 >> - WRITE_ONCE(q->idleslope, qopt->idleslope * BYTES_PER_KBIT); >> - WRITE_ONCE(q->sendslope, qopt->sendslope * BYTES_PER_KBIT); >> + WRITE_ONCE(q->idleslope, qopt->idleslope * (s64)BYTES_PER_KBIT); >> + WRITE_ONCE(q->sendslope, qopt->sendslope * (s64)BYTES_PER_KBIT); >=20 > Taking into account the above, why this casting near to the constant = and not to > the variable(s)? >=20 > ... >=20 >> - opt.sendslope =3D div64_s64(READ_ONCE(q->sendslope), = BYTES_PER_KBIT); >> - opt.idleslope =3D div64_s64(READ_ONCE(q->idleslope), = BYTES_PER_KBIT); >=20 >> + opt.sendslope =3D div64_s64(READ_ONCE(q->sendslope), = (s64)BYTES_PER_KBIT); >> + opt.idleslope =3D div64_s64(READ_ONCE(q->idleslope), = (s64)BYTES_PER_KBIT); >=20 > Why? What makes the difference here? The parameter of the function is = already > s64. Agreed on all these points. I will address them in v6.