Re: [PATCH net-next v4 1/2] tcp: annotate lockless access to sk->sk_err

From: quanyeyang

Date: Fri Sep 18 2026 - 07:27:16 EST


On Friday, September 18th, 2026 at AM 2:51, David Laight <david.laight.linux@xxxxxxxxx> wrote:

> Don't they need annotating with data_race() ?

I think READ_ONCE() is the intended marker here.

These loads are part of the I/O control flow (stop send/recv/splice),
not diagnostic or heuristic reads. data_race() would silence KCSAN
but would not restrict compiler optimizations, so the load could still
be torn, fused or reissued. READ_ONCE() is a single-copy atomic load
and pairs with the existing WRITE_ONCE()/xchg() updates of sk_err,
same as tcp_poll() after e13ec3da05d1.

sock_error() uses data_race() only on the fast-path "is it zero?"
check, which is then validated by xchg(). That pattern does not
apply to these peeks.

Quanye