lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 17 Jan 2020 18:27:54 +0100
From:   Paolo Abeni <pabeni@...hat.com>
To:     netdev@...r.kernel.org
Cc:     "David S. Miller" <davem@...emloft.net>,
        Willem de Bruijn <willemdebruijn.kernel@...il.com>
Subject: [PATCH net 1/3] net: generic enter_memory_pressure implementation.

Currently sk_leave_memory_pressure() offers a generic implementation
for protocol lacking the leave_memory_pressure() helper, but
supporting the memory pressure model.

sk_enter_memory_pressure() lacks such bits. As a result we get code
duplication and additional, avoidable indirect calls.

This change provides a generic implementation for entering memory pressure,
similar to the existing sk_leave_memory_pressure().

Note: no existing protocol is affected, until the existing
enter_memory_pressure helper is removed from the relevant 'proto'
struct.

Signed-off-by: Paolo Abeni <pabeni@...hat.com>
---
 net/core/sock.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 8459ad579f73..8cf24dca9bde 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2323,10 +2323,14 @@ EXPORT_SYMBOL(sock_cmsg_send);
 
 static void sk_enter_memory_pressure(struct sock *sk)
 {
-	if (!sk->sk_prot->enter_memory_pressure)
-		return;
+	if (sk->sk_prot->enter_memory_pressure) {
+		sk->sk_prot->enter_memory_pressure(sk);
+	} else {
+		unsigned long *memory_pressure = sk->sk_prot->memory_pressure;
 
-	sk->sk_prot->enter_memory_pressure(sk);
+		if (memory_pressure && !READ_ONCE(*memory_pressure))
+			WRITE_ONCE(*memory_pressure, 1);
+	}
 }
 
 static void sk_leave_memory_pressure(struct sock *sk)
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ