From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796479260; b=5LP6AZWFvwMgZGw3OYSNyYrlOJMnfP4p3+QxxuJc43fEQQolOYAdHF93Am7GofSWkPV9 EZM6Pz0J7M071WD22OpUnlJw/a4SDFutTfYfHoGOeSnEJ1Hi2zS29Ia/a3ydjw9zh6ZnV 8AUlTs94Npnd9s1DmUZwQfVK9PThrfKutHzvxo2hQLRYovbgDxir8XrGaI90yyfFwdEuR ejS3zA1RHnLChyNET5eCAni/BySbCRWjhr2uD13yUsz6DxpUmiUs2sSx+AMdkYd116BXY ANdoKCmMEcqZwA4GjT3tDuhC9YHI9m5SpGbx3+mW9LRwrKaPqZlnv7RzNQQxbiIROlQ== 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=1Kq6sk01XTtMB5C++mkHmdJfu16+LRCsxW7IkkCy9rN7I86EgDGNHHdcHhdWMCLnjyzv 19t3hUtk8Engk1hCOAJKY+g7LMhin5pCN1TLmslK7PQHSAgoReZDirNgx8Pymjk2gN1OG lDWDqZMX6BUq1ZUD1xIBTfyTP2dECSvqXaRMx7sleaWI6V4vLigW4Hc1leOqNUBMuyMww k/rLRSM7NEr9JTstJANlRUOUjnweijFSjW4iHvikn7MX3qLzrXnmAtaIp0ZQMzXI7jhDm Iw/JgQTUjHjREqrBbexoCESVlmZ26eESch6yvJzD7M8SmhYXX5RECg8rQ+E3wjbA9zQ== 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.45 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 F3A21606A32F for ; Sat, 5 Dec 2026 14:00:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3A21606A32F 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-f45.google.com with SMTP id 5b1f17b1804b1-4a5177d78c7so18627635e9.2 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=El7kmj1Q+OUnZY3TDiCO1FIY6tJMnrNkT/q+Ccgi+6cq2b1HFCjJme4bHYRXj1MnP/ vhlZsRxs4qAjEz2ue2d4ID8maZ5FNaR69Eh1wSlPv1dugyKmB8Ilxlvc+WI5cVNV5kRg e2MS1c3tyQyGY13AbBKnrO13trPWzyAKZVBEjB552kSdLvOtO5htPVqPAsvV7rjzhomm gdM9tntUYPtb3yWcx9WY0kMVmUHxD/+f+Me/RXwtg0143YsLqFYmOgVAsvbFZCl/ZuCa AEsVnQ2xVLnzkmy24CF5rOh2RhniO5C37HLz/JOKSxKCYSxgwraxM1WBjBfNHerH33mh f0Ow== X-Forwarded-Encrypted: i=1; AL+hErHE2uQP6EtIHllT+Y0gTsCHIh1oTNoJMOd6P8u5Ry88z5S0pXDqFeIZCWQ/d4BDdRjrXPspr4wRSL/oXGU=@vger.kernel.org X-Gm-Message-State: APuU4Z/3ogR8+3ni0jGmaDpLo64ZdYz8e3/jDxwfOsuJCGQSJIKz+pHN hicEiUSiofLzYtjcHyMdFRG0GTFoDuRQyQUHV/twYfiIMqFCBy7o+j9G X-Gm-Gg: AZFdTZfZ0u9jPXxzEZsBTVNDvQECBx1gJDAWZ1y4i7uKT6eDNPLQOGkOJZDzlk51uyc DRkjYQJBpFuAfrOl5wOB5JmWpcQoN93j8KLIHWdcFoKjt9BksckRnmFVaeudfWownlj5B+uI/L1 OnBNu3U3C1jGo+6Dg9DaQfh17ckn5CmvB3bxc/z67UtFJkUg1lJuItXnoQCoU3nZzUmXtXdLpaS ZK/e6n3AKVgH6rzOjUxHQEn2/Xk1XSEH33v2rhcGLUmyAVsbtelaYuOLS/ouCcwALj52V071aYz sgqRZDxEHCLmceP5whf0dAjiPVK5qOzp720Q8q8Q+liCzkrClQfnF78OZsprSVo/IN6zFMTfBbP G2fAJMB9K58SR0+fif7lo9IZ2ox0GGtajvmYzOLSfVGe/sesrQyLF9vNkYWBx3JHsfe9mcc6nx+ DtAzbmbDWeYYsUi76kf+R2LtvVkNSmqtjoxK31M6hRTO2rMHs9VR50+hkSdjaq75R76EQODCJJP 3JhSpqlZYLlAH3K6yPrNSafjX/zW9ymmvVNsslX6nQQKFooBxtIzFkq3UYywH0SpN2vxDxkkG2y rP7dHmBmi5YXjZJyXonzkazt+27m4LwYN24ght2jI0qxtpWVtrRsWeqh 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: linux-kernel@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.