[NET] generalise tcp_moderate_sndbuf

Renaming it to sk_stream_moderate_sndbuf, further patches will move
all the tcp memory pressure handling support into net/core/stream.c
to make them usable by the poor cousins, starting with LLC.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@conectiva.com.br>
parent dd87b025
...@@ -1095,6 +1095,14 @@ static inline void sk_wake_async(struct sock *sk, int how, int band) ...@@ -1095,6 +1095,14 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
#define SOCK_MIN_SNDBUF 2048 #define SOCK_MIN_SNDBUF 2048
#define SOCK_MIN_RCVBUF 256 #define SOCK_MIN_RCVBUF 256
static inline void sk_stream_moderate_sndbuf(struct sock *sk)
{
if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) {
sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued / 2);
sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF);
}
}
/* /*
* Default write policy as shown to user space via poll/select/SIGIO * Default write policy as shown to user space via poll/select/SIGIO
*/ */
......
...@@ -1893,14 +1893,6 @@ static inline void tcp_enter_memory_pressure(void) ...@@ -1893,14 +1893,6 @@ static inline void tcp_enter_memory_pressure(void)
} }
} }
static inline void tcp_moderate_sndbuf(struct sock *sk)
{
if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) {
sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued / 2);
sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF);
}
}
static inline struct sk_buff *tcp_alloc_pskb(struct sock *sk, int size, int mem, int gfp) static inline struct sk_buff *tcp_alloc_pskb(struct sock *sk, int size, int mem, int gfp)
{ {
struct sk_buff *skb = alloc_skb(size+MAX_TCP_HEADER, gfp); struct sk_buff *skb = alloc_skb(size+MAX_TCP_HEADER, gfp);
...@@ -1915,7 +1907,7 @@ static inline struct sk_buff *tcp_alloc_pskb(struct sock *sk, int size, int mem, ...@@ -1915,7 +1907,7 @@ static inline struct sk_buff *tcp_alloc_pskb(struct sock *sk, int size, int mem,
__kfree_skb(skb); __kfree_skb(skb);
} else { } else {
tcp_enter_memory_pressure(); tcp_enter_memory_pressure();
tcp_moderate_sndbuf(sk); sk_stream_moderate_sndbuf(sk);
} }
return NULL; return NULL;
} }
...@@ -1934,7 +1926,7 @@ static inline struct page * tcp_alloc_page(struct sock *sk) ...@@ -1934,7 +1926,7 @@ static inline struct page * tcp_alloc_page(struct sock *sk)
return page; return page;
} }
tcp_enter_memory_pressure(); tcp_enter_memory_pressure();
tcp_moderate_sndbuf(sk); sk_stream_moderate_sndbuf(sk);
return NULL; return NULL;
} }
......
...@@ -333,7 +333,7 @@ int tcp_mem_schedule(struct sock *sk, int size, int kind) ...@@ -333,7 +333,7 @@ int tcp_mem_schedule(struct sock *sk, int size, int kind)
suppress_allocation: suppress_allocation:
if (!kind) { if (!kind) {
tcp_moderate_sndbuf(sk); sk_stream_moderate_sndbuf(sk);
/* Fail only if socket is _under_ its sndbuf. /* Fail only if socket is _under_ its sndbuf.
* In this case we cannot block, so that we have to fail. * In this case we cannot block, so that we have to fail.
......
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