diff options
author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 03:11:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 03:11:50 -0400 |
commit | 48467641bcc057f7cba3b6cbbe66cb834d64cc81 (patch) | |
tree | f7c5c5e964c220de30fcdcd06b0f1efdb3e22439 /include/net/sock.h | |
parent | 3863e72414fa2ebf5f3b615d1bf99de32e59980a (diff) | |
parent | d70063c4634af060a5387337b7632f6334ca3458 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 312cb25cbd18..cf628261da52 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -709,6 +709,12 @@ static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb) | |||
709 | sk_stream_mem_schedule(sk, skb->truesize, 1); | 709 | sk_stream_mem_schedule(sk, skb->truesize, 1); |
710 | } | 710 | } |
711 | 711 | ||
712 | static inline int sk_stream_wmem_schedule(struct sock *sk, int size) | ||
713 | { | ||
714 | return size <= sk->sk_forward_alloc || | ||
715 | sk_stream_mem_schedule(sk, size, 0); | ||
716 | } | ||
717 | |||
712 | /* Used by processes to "lock" a socket state, so that | 718 | /* Used by processes to "lock" a socket state, so that |
713 | * interrupts and bottom half handlers won't change it | 719 | * interrupts and bottom half handlers won't change it |
714 | * from under us. It essentially blocks any incoming | 720 | * from under us. It essentially blocks any incoming |
@@ -1203,8 +1209,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, | |||
1203 | skb = alloc_skb_fclone(size + hdr_len, gfp); | 1209 | skb = alloc_skb_fclone(size + hdr_len, gfp); |
1204 | if (skb) { | 1210 | if (skb) { |
1205 | skb->truesize += mem; | 1211 | skb->truesize += mem; |
1206 | if (sk->sk_forward_alloc >= (int)skb->truesize || | 1212 | if (sk_stream_wmem_schedule(sk, skb->truesize)) { |
1207 | sk_stream_mem_schedule(sk, skb->truesize, 0)) { | ||
1208 | skb_reserve(skb, hdr_len); | 1213 | skb_reserve(skb, hdr_len); |
1209 | return skb; | 1214 | return skb; |
1210 | } | 1215 | } |
@@ -1227,10 +1232,8 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk) | |||
1227 | { | 1232 | { |
1228 | struct page *page = NULL; | 1233 | struct page *page = NULL; |
1229 | 1234 | ||
1230 | if (sk->sk_forward_alloc >= (int)PAGE_SIZE || | 1235 | page = alloc_pages(sk->sk_allocation, 0); |
1231 | sk_stream_mem_schedule(sk, PAGE_SIZE, 0)) | 1236 | if (!page) { |
1232 | page = alloc_pages(sk->sk_allocation, 0); | ||
1233 | else { | ||
1234 | sk->sk_prot->enter_memory_pressure(); | 1237 | sk->sk_prot->enter_memory_pressure(); |
1235 | sk_stream_moderate_sndbuf(sk); | 1238 | sk_stream_moderate_sndbuf(sk); |
1236 | } | 1239 | } |