mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
tcp: annotate sk->sk_rcvbuf lockless reads
For the sake of tcp_poll(), there are few places where we fetch sk->sk_rcvbuf while this field can change from IRQ or other cpu. We need to add READ_ONCE() annotations, and also make sure write sides use corresponding WRITE_ONCE() to avoid store-tearing. Note that other transports probably need similar fixes. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d9b55bf7b6
commit
ebb3b78db7
7 changed files with 15 additions and 12 deletions
|
@ -483,8 +483,9 @@ static void tcp_clamp_window(struct sock *sk)
|
|||
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK) &&
|
||||
!tcp_under_memory_pressure(sk) &&
|
||||
sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0)) {
|
||||
sk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc),
|
||||
net->ipv4.sysctl_tcp_rmem[2]);
|
||||
WRITE_ONCE(sk->sk_rcvbuf,
|
||||
min(atomic_read(&sk->sk_rmem_alloc),
|
||||
net->ipv4.sysctl_tcp_rmem[2]));
|
||||
}
|
||||
if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf)
|
||||
tp->rcv_ssthresh = min(tp->window_clamp, 2U * tp->advmss);
|
||||
|
@ -648,7 +649,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
|
|||
rcvbuf = min_t(u64, rcvwin * rcvmem,
|
||||
sock_net(sk)->ipv4.sysctl_tcp_rmem[2]);
|
||||
if (rcvbuf > sk->sk_rcvbuf) {
|
||||
sk->sk_rcvbuf = rcvbuf;
|
||||
WRITE_ONCE(sk->sk_rcvbuf, rcvbuf);
|
||||
|
||||
/* Make the window clamp follow along. */
|
||||
tp->window_clamp = tcp_win_from_space(sk, rcvbuf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue