Article View: linux.kernel.netdev
Article #653Re: [PATCH net-next 1/4] net/sched/sch_cake: serialize reconfiguration with the datapath
From: Toke Høiland-Jørgensen
Date: Thu, 08 Oct 2026 12:03
Date: Thu, 08 Oct 2026 12:03
65 lines
7574 bytes
7574 bytes
Jamal Hadi Salim <jhs@mojatatu.com> writes: > On Thu, Oct 8, 2026 at 6:29 AM Toke Høiland-Jørgensen <toke@toke.dk> wrote: >> >> > The qdisc is left with autorate disabled but with the estimate installed >> > instead of X. On 32-bit machines the unlocked 64-bit rate_bps store is >> > also not atomic, so a reader can observe a torn rate. iproute2 reaches >> > this because parsing 'bandwidth X' sets autorate = 0 and emits both >> > TCA_CAKE_BASE_RATE64 and TCA_CAKE_AUTORATE. >> > >> > Commit the parsed configuration and reconfigure while holding the same >> > qdisc lock that serializes the datapath, so the netlink writer and the >> > autorate writer can no longer interleave. Make rate_bps an atomic64_t >> > so a 64-bit rate update is atomic on 32-bit machines as well, and keep >> > the READ_ONCE()/WRITE_ONCE() annotations for the remaining lockless >> > readers (cake_config_dump(), which runs without the lock, and the >> > cake_mq shared config, which readers observe under different child >> > locks). >> >> So atomic_t.txt has this section: >> >> "SEMANTICS >> --------- >> >> Non-RMW ops: >> >> The non-RMW ops are (typically) regular LOADs and STOREs and are canonically >> implemented using READ_ONCE(), WRITE_ONCE(), smp_load_acquire() and >> smp_store_release() respectively. Therefore, if you find yourself only using >> the Non-RMW operations of atomic_t, you do not in fact need atomic_t at all >> and are doing it wrong." >> >> >> So AFAICT, we don't need atomic_t, we just need READ/WRITE_ONCE() >> annotations? >> > > hrm. actually, the sch_tree_lock() already protects cake_change(): it > commits the parsed config and reconfigures together with the datapath > under the same qdisc lock, so the netlink writer and the autorate > store can no longer interleave. So the atomic64_t was never needed for > the lost update. > > on the atomic_t.txt point you pointed out: rate_bps takes only non-RMW > ops, so per SEMANTICS it should be a plain u64 with > READ_ONCE()/WRITE_ONCE(). I'll drop the atomic64_t. > > The only lockless readers left are cake_config_dump() (cosmetic) and > the cake_mq shared config, which a child reads while holding a > different child's lock than the parent writes it under - on 32-bit > READ_ONCE() on a u64 can tear there. It's an advisory rate that > self-corrects on the next sync interval, so best-effort is fine. > > I will resend a v2 with rate_bps as u64 + READ/WRITE_ONCE. Let's wait > for Sashiko first - it will always find something to complain about. SGTM. -Toke
Technical Details
Message-ID:
<87se2gs8ld.fsf@toke.dk>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342945-linux-kernel-netdev=dewy.ruReferences:
<QDISC-5RTM.v1.20261007130704@mojatatu.com> <QDISC-5RTM.v1.20261007130704-2@mojatatu.com> <875wzctsky.fsf@toke.dk> <CAM0EoMk2nKEaywg0fa6bwKxdAH8kp7dKfxHq2unZi=Qd7HBttg@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342945-linux-kernel-netdev=dewy.ru From: toke@toke.dk (Toke Høiland-Jørgensen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 1/4] net/sched/sch_cake: serialize reconfiguration with the datapath Date: Thu, 08 Oct 2026 14:03:10 +0200 Organization: Usenet Network Message-ID: <87se2gs8ld.fsf@toke.dk> References: <QDISC-5RTM.v1.20261007130704@mojatatu.com> <QDISC-5RTM.v1.20261007130704-2@mojatatu.com> <875wzctsky.fsf@toke.dk> <CAM0EoMk2nKEaywg0fa6bwKxdAH8kp7dKfxHq2unZi=Qd7HBttg@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="875735"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:POcAH4EnbTsbTAgcS1u206uee+E= sha256:uHhOZwdv2XT5CKMtYviSIlz+KxHCA3caGCnVxug9sdk= sha1:iIvQ7+jNUsoCfqyoD/v9S4dsxN0= sha256:ETxCrxzdAcrBlD17oOpThwPHWxRK9birOXHdU96ZY54= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 86C3310F3CC; Thu, 8 Oct 2026 15:04:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.851 X-Spam-Status: No, score=-1.851 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_ADSP_ALL=1.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BtxvCOb_RxCj; Thu, 8 Oct 2026 15:04:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-342945-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=toke.dk X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id B615510F33D; Thu, 8 Oct 2026 15:03:59 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id E98552403F; Thu, 8 Oct 2026 12:03:36 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59038392C46; Thu, 8 Oct 2026 12:03:35 +0000 (UTC) X-Received: from mail.toke.dk (mail.toke.dk [45.145.95.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B875B3C7E1D for <netdev@vger.kernel.org>; Thu, 8 Oct 2026 12:03:32 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.145.95.4 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791461015; cv=none; b=k3MrMjRbi4FhfZwkz0qDjVenAJNPF+JsJ5YNInPI+/iCsIchngZ/vKV1NqWmcMfsNxJN7/9AeOdGILqTHCNS/0d6/+1RYAPDa/SWi5uIZqY6KZQg64jZ5VL2evwtV+bRkWkUftGSUEJO0w+YKi13HLeJT2dbPSBJmTicSasU5Ew= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791461015; c=relaxed/simple; bh=OYGEaUQOc84tn+UWAjYrfHv+cxmGpTCjaaEPswNuzZY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=sh9R40a6cPIdfy8jJA1qXlWIC0YcxOi4wqmw0bdWUFb0bo3L+UV0HTyyXnYm8t0LniG13seLLl7Rvk/QWTOzgdK+32e8qLuOMNlh49xkkdusctgyODHUoJjxyWoWBZxR9DWy3jzZfA21efmDSco9k6I+2m+x/Q159xGKQCoRpFU= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=toke.dk; spf=pass smtp.mailfrom=toke.dk; arc=none smtp.client-ip=45.145.95.4 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=toke.dk X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=toke.dk X-Authentication-Results: mail.toke.dk; dkim=none X-Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, cake@lists.bufferbloat.net, Victor Nogueira <victor@mojatatu.com>, Sashiko <sashiko-bot@kernel.org> X-In-Reply-To: <CAM0EoMk2nKEaywg0fa6bwKxdAH8kp7dKfxHq2unZi=Qd7HBttg@mail.gmail.com> X-Clacks-Overhead: GNU Terry Pratchett X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>