From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; dkim=none; arc=none (Message is not ARC signed); dmarc=fail (Used From Domain Record) header.from=toke.dk policy.dmarc=none From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Jamal Hadi Salim , netdev@vger.kernel.org Cc: Jamal Hadi Salim , Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , cake@lists.bufferbloat.net, Victor Nogueira , Sashiko In-Reply-To: References: Date: Thu, 08 Oct 2026 12:06:05 +0200 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <875wzctsky.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain Message-ID-Hash: ZF3O3IERWWVURKO43PDZJYAJ2GMSOSKO X-Message-ID-Hash: ZF3O3IERWWVURKO43PDZJYAJ2GMSOSKO X-MailFrom: toke@toke.dk X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Subject: [Cake] Re: [PATCH net-next 1/4] net/sched/sch_cake: serialize reconfiguration with the datapath List-Id: Cake - FQ_codel the next generation Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: > 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? -Toke