aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2012-07-31 19:44:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:46 -0400
commitb4b9e3558508980fc0cd161a545ffb55a1f13ee9 (patch)
treeabb2ab54f4b201b1cbdaf181ec16912c3dd889eb /net/core/sock.c
parent0614002bb5f7411e61ffa0dfe5be1f2c84df3da3 (diff)
netvm: set PF_MEMALLOC as appropriate during SKB processing
In order to make sure pfmemalloc packets receive all memory needed to proceed, ensure processing of pfmemalloc SKBs happens under PF_MEMALLOC. This is limited to a subset of protocols that are expected to be used for writing to swap. Taps are not allowed to use PF_MEMALLOC as these are expected to communicate with userspace processes which could be paged out. [a.p.zijlstra@chello.nl: Ideas taken from various patches] [jslaby@suse.cz: Lock imbalance fix] Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: David S. Miller <davem@davemloft.net> Cc: Neil Brown <neilb@suse.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Christie <michaelc@cs.wisc.edu> Cc: Eric B Munson <emunson@mgebm.net> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Cc: Mel Gorman <mgorman@suse.de> Cc: Christoph Lameter <cl@linux.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index c8c5816289fe..32fdcd2d6e8f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -298,6 +298,22 @@ void sk_clear_memalloc(struct sock *sk)
298} 298}
299EXPORT_SYMBOL_GPL(sk_clear_memalloc); 299EXPORT_SYMBOL_GPL(sk_clear_memalloc);
300 300
301int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
302{
303 int ret;
304 unsigned long pflags = current->flags;
305
306 /* these should have been dropped before queueing */
307 BUG_ON(!sock_flag(sk, SOCK_MEMALLOC));
308
309 current->flags |= PF_MEMALLOC;
310 ret = sk->sk_backlog_rcv(sk, skb);
311 tsk_restore_flags(current, pflags, PF_MEMALLOC);
312
313 return ret;
314}
315EXPORT_SYMBOL(__sk_backlog_rcv);
316
301#if defined(CONFIG_CGROUPS) 317#if defined(CONFIG_CGROUPS)
302#if !defined(CONFIG_NET_CLS_CGROUP) 318#if !defined(CONFIG_NET_CLS_CGROUP)
303int net_cls_subsys_id = -1; 319int net_cls_subsys_id = -1;