Thread (7 messages) 7 messages, 3 authors, 2020-01-17
STALE2363d

[PATCH net 2/3] net: add annotations to memory_pressure lockless access

From: Paolo Abeni <pabeni@redhat.com>
Date: 2020-01-17 17:28:34
Subsystem: networking [general], networking [sockets], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Kuniyuki Iwashima, Willem de Bruijn, Linus Torvalds

The proto memory pressure status is updated without any related lock
held. This patch adds annotations to document this fact and avoid
future syzbot complains.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 include/net/sock.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 8dff68b4c316..08383624b8cb 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1264,7 +1264,7 @@ static inline bool sk_under_memory_pressure(const struct sock *sk)
 	    mem_cgroup_under_socket_pressure(sk->sk_memcg))
 		return true;
 
-	return !!*sk->sk_prot->memory_pressure;
+	return !!READ_ONCE(*sk->sk_prot->memory_pressure);
 }
 
 static inline long
@@ -1318,7 +1318,7 @@ proto_memory_pressure(struct proto *prot)
 {
 	if (!prot->memory_pressure)
 		return false;
-	return !!*prot->memory_pressure;
+	return !!READ_ONCE(*prot->memory_pressure);
 }
 
 
-- 
2.21.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help