aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2011-12-11 16:47:02 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-12 19:04:10 -0500
commit180d8cd942ce336b2c869d324855c40c5db478ad (patch)
tree2424d854345d81464d6030ef8090a8e22bd414b0 /net/ipv4/tcp_input.c
parente5671dfae59b165e2adfd4dfbdeab11ac8db5bda (diff)
foundations of per-cgroup memory pressure controlling.
This patch replaces all uses of struct sock fields' memory_pressure, memory_allocated, sockets_allocated, and sysctl_mem to acessor macros. Those macros can either receive a socket argument, or a mem_cgroup argument, depending on the context they live in. Since we're only doing a macro wrapping here, no performance impact at all is expected in the case where we don't have cgroups disabled. Signed-off-by: Glauber Costa <glommer@parallels.com> Reviewed-by: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: David S. Miller <davem@davemloft.net> CC: Eric W. Biederman <ebiederm@xmission.com> CC: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index b9cbc351c511..f131d92d25ee 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -322,7 +322,7 @@ static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb)
322 /* Check #1 */ 322 /* Check #1 */
323 if (tp->rcv_ssthresh < tp->window_clamp && 323 if (tp->rcv_ssthresh < tp->window_clamp &&
324 (int)tp->rcv_ssthresh < tcp_space(sk) && 324 (int)tp->rcv_ssthresh < tcp_space(sk) &&
325 !tcp_memory_pressure) { 325 !sk_under_memory_pressure(sk)) {
326 int incr; 326 int incr;
327 327
328 /* Check #2. Increase window, if skb with such overhead 328 /* Check #2. Increase window, if skb with such overhead
@@ -411,8 +411,8 @@ static void tcp_clamp_window(struct sock *sk)
411 411
412 if (sk->sk_rcvbuf < sysctl_tcp_rmem[2] && 412 if (sk->sk_rcvbuf < sysctl_tcp_rmem[2] &&
413 !(sk->sk_userlocks & SOCK_RCVBUF_LOCK) && 413 !(sk->sk_userlocks & SOCK_RCVBUF_LOCK) &&
414 !tcp_memory_pressure && 414 !sk_under_memory_pressure(sk) &&
415 atomic_long_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) { 415 sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0)) {
416 sk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc), 416 sk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc),
417 sysctl_tcp_rmem[2]); 417 sysctl_tcp_rmem[2]);
418 } 418 }
@@ -4866,7 +4866,7 @@ static int tcp_prune_queue(struct sock *sk)
4866 4866
4867 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) 4867 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
4868 tcp_clamp_window(sk); 4868 tcp_clamp_window(sk);
4869 else if (tcp_memory_pressure) 4869 else if (sk_under_memory_pressure(sk))
4870 tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss); 4870 tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss);
4871 4871
4872 tcp_collapse_ofo_queue(sk); 4872 tcp_collapse_ofo_queue(sk);
@@ -4932,11 +4932,11 @@ static int tcp_should_expand_sndbuf(const struct sock *sk)
4932 return 0; 4932 return 0;
4933 4933
4934 /* If we are under global TCP memory pressure, do not expand. */ 4934 /* If we are under global TCP memory pressure, do not expand. */
4935 if (tcp_memory_pressure) 4935 if (sk_under_memory_pressure(sk))
4936 return 0; 4936 return 0;
4937 4937
4938 /* If we are under soft global TCP memory pressure, do not expand. */ 4938 /* If we are under soft global TCP memory pressure, do not expand. */
4939 if (atomic_long_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0]) 4939 if (sk_memory_allocated(sk) >= sk_prot_mem_limits(sk, 0))
4940 return 0; 4940 return 0;
4941 4941
4942 /* If we filled the congestion window, do not expand. */ 4942 /* If we filled the congestion window, do not expand. */