diff options
author | Eric Dumazet <edumazet@google.com> | 2015-05-15 15:39:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-17 22:45:48 -0400 |
commit | b8da51ebb1aa93908350f95efae73aecbc2e266c (patch) | |
tree | 5d6b1edc272ea24b07ec2a38cbcba7c53fb44bae /include/net/tcp.h | |
parent | a6c5ea4ccf0033591e6e476d7a273c0074c07aa7 (diff) |
tcp: introduce tcp_under_memory_pressure()
Introduce an optimized version of sk_under_memory_pressure()
for TCP. Our intent is to use it in fast paths.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 841691a296dc..0d85223efa4c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -286,6 +286,14 @@ extern atomic_long_t tcp_memory_allocated; | |||
286 | extern struct percpu_counter tcp_sockets_allocated; | 286 | extern struct percpu_counter tcp_sockets_allocated; |
287 | extern int tcp_memory_pressure; | 287 | extern int tcp_memory_pressure; |
288 | 288 | ||
289 | /* optimized version of sk_under_memory_pressure() for TCP sockets */ | ||
290 | static inline bool tcp_under_memory_pressure(const struct sock *sk) | ||
291 | { | ||
292 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
293 | return !!sk->sk_cgrp->memory_pressure; | ||
294 | |||
295 | return tcp_memory_pressure; | ||
296 | } | ||
289 | /* | 297 | /* |
290 | * The next routines deal with comparing 32 bit unsigned ints | 298 | * The next routines deal with comparing 32 bit unsigned ints |
291 | * and worry about wraparound (automatic with unsigned arithmetic). | 299 | * and worry about wraparound (automatic with unsigned arithmetic). |