Re: [PATCH 4.19 012/120] tcp: annotate tp->write_seq lockless reads

From: Eric Dumazet
Date: Tue Mar 16 2021 - 06:00:51 EST


On Tue, Mar 16, 2021 at 10:50 AM Pavel Machek <pavel@xxxxxxx> wrote:
>

> > --- a/net/ipv4/tcp_minisocks.c
> > +++ b/net/ipv4/tcp_minisocks.c
> > @@ -510,7 +510,7 @@ struct sock *tcp_create_openreq_child(co
> > newtp->app_limited = ~0U;
> >
> > tcp_init_xmit_timers(newsk);
> > - newtp->write_seq = newtp->pushed_seq = treq->snt_isn + 1;
> > + WRITE_ONCE(newtp->write_seq, newtp->pushed_seq = treq->snt_isn + 1);
>
> Would it be better to do assignment to pushed_seq outside of
> WRITE_ONCE macro? This is ... "interesting".

You are probably right, this looks odd and was not something I intended.
It happened to just work, but feel free to send a patch to clean it up.

Thanks.