diff options
author | Mel Gorman <mgorman@suse.de> | 2012-07-31 19:44:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-31 21:42:46 -0400 |
commit | 7cb0240492caea2f6467f827313478f41877e6ef (patch) | |
tree | 4836f7c2c07ed199e3122ea70bedf34f048ecd81 /net | |
parent | 99a1dec70d5acbd8c6b3928cdebb4a2d1da676c8 (diff) |
netvm: allow the use of __GFP_MEMALLOC by specific sockets
Allow specific sockets to be tagged SOCK_MEMALLOC and use __GFP_MEMALLOC
for their allocations. These sockets will be able to go below watermarks
and allocate from the emergency reserve. Such sockets are to be used to
service the VM (iow. to swap over). They must be handled kernel side,
exposing such a socket to user-space is a bug.
There is a risk that the reserves be depleted so for now, the
administrator is responsible for increasing min_free_kbytes as necessary
to prevent deadlock for their workloads.
[a.p.zijlstra@chello.nl: Original patches]
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')
-rw-r--r-- | net/core/sock.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index a67b06280e4c..3617f652f6b0 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -271,6 +271,28 @@ __u32 sysctl_rmem_default __read_mostly = SK_RMEM_MAX; | |||
271 | int sysctl_optmem_max __read_mostly = sizeof(unsigned long)*(2*UIO_MAXIOV+512); | 271 | int sysctl_optmem_max __read_mostly = sizeof(unsigned long)*(2*UIO_MAXIOV+512); |
272 | EXPORT_SYMBOL(sysctl_optmem_max); | 272 | EXPORT_SYMBOL(sysctl_optmem_max); |
273 | 273 | ||
274 | /** | ||
275 | * sk_set_memalloc - sets %SOCK_MEMALLOC | ||
276 | * @sk: socket to set it on | ||
277 | * | ||
278 | * Set %SOCK_MEMALLOC on a socket for access to emergency reserves. | ||
279 | * It's the responsibility of the admin to adjust min_free_kbytes | ||
280 | * to meet the requirements | ||
281 | */ | ||
282 | void sk_set_memalloc(struct sock *sk) | ||
283 | { | ||
284 | sock_set_flag(sk, SOCK_MEMALLOC); | ||
285 | sk->sk_allocation |= __GFP_MEMALLOC; | ||
286 | } | ||
287 | EXPORT_SYMBOL_GPL(sk_set_memalloc); | ||
288 | |||
289 | void sk_clear_memalloc(struct sock *sk) | ||
290 | { | ||
291 | sock_reset_flag(sk, SOCK_MEMALLOC); | ||
292 | sk->sk_allocation &= ~__GFP_MEMALLOC; | ||
293 | } | ||
294 | EXPORT_SYMBOL_GPL(sk_clear_memalloc); | ||
295 | |||
274 | #if defined(CONFIG_CGROUPS) | 296 | #if defined(CONFIG_CGROUPS) |
275 | #if !defined(CONFIG_NET_CLS_CGROUP) | 297 | #if !defined(CONFIG_NET_CLS_CGROUP) |
276 | int net_cls_subsys_id = -1; | 298 | int net_cls_subsys_id = -1; |