[NET]: Add sk_stream_wmem_schedule
This patch introduces sk_stream_wmem_schedule as a short-hand for the sk_forward_alloc checking on egress. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
2dac4b96b9
commit
d80d99d643
@@ -709,6 +709,12 @@ static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb)
|
|||||||
sk_stream_mem_schedule(sk, skb->truesize, 1);
|
sk_stream_mem_schedule(sk, skb->truesize, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
|
||||||
|
{
|
||||||
|
return size <= sk->sk_forward_alloc ||
|
||||||
|
sk_stream_mem_schedule(sk, size, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Used by processes to "lock" a socket state, so that
|
/* Used by processes to "lock" a socket state, so that
|
||||||
* interrupts and bottom half handlers won't change it
|
* interrupts and bottom half handlers won't change it
|
||||||
* from under us. It essentially blocks any incoming
|
* from under us. It essentially blocks any incoming
|
||||||
@@ -1203,8 +1209,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
|
|||||||
skb = alloc_skb_fclone(size + hdr_len, gfp);
|
skb = alloc_skb_fclone(size + hdr_len, gfp);
|
||||||
if (skb) {
|
if (skb) {
|
||||||
skb->truesize += mem;
|
skb->truesize += mem;
|
||||||
if (sk->sk_forward_alloc >= (int)skb->truesize ||
|
if (sk_stream_wmem_schedule(sk, skb->truesize)) {
|
||||||
sk_stream_mem_schedule(sk, skb->truesize, 0)) {
|
|
||||||
skb_reserve(skb, hdr_len);
|
skb_reserve(skb, hdr_len);
|
||||||
return skb;
|
return skb;
|
||||||
}
|
}
|
||||||
@@ -1227,8 +1232,7 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk)
|
|||||||
{
|
{
|
||||||
struct page *page = NULL;
|
struct page *page = NULL;
|
||||||
|
|
||||||
if (sk->sk_forward_alloc >= (int)PAGE_SIZE ||
|
if (sk_stream_wmem_schedule(sk, PAGE_SIZE))
|
||||||
sk_stream_mem_schedule(sk, PAGE_SIZE, 0))
|
|
||||||
page = alloc_pages(sk->sk_allocation, 0);
|
page = alloc_pages(sk->sk_allocation, 0);
|
||||||
else {
|
else {
|
||||||
sk->sk_prot->enter_memory_pressure();
|
sk->sk_prot->enter_memory_pressure();
|
||||||
|
@@ -552,8 +552,7 @@ new_segment:
|
|||||||
tcp_mark_push(tp, skb);
|
tcp_mark_push(tp, skb);
|
||||||
goto new_segment;
|
goto new_segment;
|
||||||
}
|
}
|
||||||
if (sk->sk_forward_alloc < copy &&
|
if (!sk_stream_wmem_schedule(sk, copy))
|
||||||
!sk_stream_mem_schedule(sk, copy, 0))
|
|
||||||
goto wait_for_memory;
|
goto wait_for_memory;
|
||||||
|
|
||||||
if (can_coalesce) {
|
if (can_coalesce) {
|
||||||
|
Reference in New Issue
Block a user