Commit a92c895e authored by Eric Dumazet's avatar Eric Dumazet Committed by Greg Kroah-Hartman

tcp: annotate lockless access to tcp_memory_pressure

[ Upstream commit 1f142c17 ]

tcp_memory_pressure is read without holding any lock,
and its value could be changed on other cpus.

Use READ_ONCE() to annotate these lockless reads.

The write side is already using atomic ops.

Fixes: b8da51eb ("tcp: introduce tcp_under_memory_pressure()")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent b0fb910b
......@@ -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
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment