On Thu, 2016-09-15 at 15:52 +0000, David Laight wrote:
> From: Eric Dumazet
> > Sent: 15 September 2016 16:13
> > If a TCP socket gets a large write queue, an overflow can happen
> > in a test in __tcp_retransmit_skb() preventing all retransmits.
> ...
> >     if (atomic_read(&sk->sk_wmem_alloc) >
> > -       min(sk->sk_wmem_queued + (sk->sk_wmem_queued >> 2), sk->sk_sndbuf))
> > +       min_t(u32, sk->sk_wmem_queued + (sk->sk_wmem_queued >> 2),
> > +             sk->sk_sndbuf))
> >             return -EAGAIN;
> 
> Might it also be better to split that test to (say):
> 
>       u32 wmem_alloc = atomic_read(&sk->sk_wmem_alloc);
>       if (unlikely((wmem_alloc > sk->sk_sndbuf))
>               return -EAGAIN;
>       if (unlikely(wmem_alloc > sk->sk_wmem_queued + (sk->sk_wmem_queued >> 
> 2)))
>               return -EAGAIN;

Well, I find the existing code more readable, but this is just an
opinion.

Thanks.


Reply via email to