diff --git a/include/net/tcp.h b/include/net/tcp.h index 662a7dace3a6276d09aae98d53d093ad5720e546..2bcccfac22f16f83e8c8ca1e14b91c1d7c7de83f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -261,7 +261,7 @@ static inline bool tcp_under_memory_pressure(const struct sock *sk) mem_cgroup_under_socket_pressure(sk->sk_memcg)) return true; - return tcp_memory_pressure; + return READ_ONCE(tcp_memory_pressure); } /* * The next routines deal with comparing 32 bit unsigned ints diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index a7a804bece7aca273e64ac4b41bcc07654e1df5f..adab7c5f35d61a5033ba83b17c4f6552b286543f 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -325,7 +325,7 @@ void tcp_enter_memory_pressure(struct sock *sk) { unsigned long val; - if (tcp_memory_pressure) + if (READ_ONCE(tcp_memory_pressure)) return; val = jiffies; @@ -340,7 +340,7 @@ void tcp_leave_memory_pressure(struct sock *sk) { unsigned long val; - if (!tcp_memory_pressure) + if (!READ_ONCE(tcp_memory_pressure)) return; val = xchg(&tcp_memory_pressure, 0); if (val)