netvm: allow skb allocation to use PFMEMALLOC reserves
Change the skb allocation API to indicate RX usage and use this to fall back to the PFMEMALLOC reserve when needed. SKBs allocated from the reserve are tagged in skb->pfmemalloc. If an SKB is allocated from the reserve and the socket is later found to be unrelated to page reclaim, the packet is dropped so that the memory remains available for page reclaim. Network protocols are expected to recover from this packet loss. [a.p.zijlstra@chello.nl: Ideas taken from various patches] [davem@davemloft.net: Use static branches, coding style corrections] [sebastian@breakpoint.cc: Avoid unnecessary cast, fix !CONFIG_NET build] 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>
This commit is contained in:

committed by
Linus Torvalds

parent
7cb0240492
commit
c93bdd0e03
@@ -271,6 +271,9 @@ __u32 sysctl_rmem_default __read_mostly = SK_RMEM_MAX;
|
||||
int sysctl_optmem_max __read_mostly = sizeof(unsigned long)*(2*UIO_MAXIOV+512);
|
||||
EXPORT_SYMBOL(sysctl_optmem_max);
|
||||
|
||||
struct static_key memalloc_socks = STATIC_KEY_INIT_FALSE;
|
||||
EXPORT_SYMBOL_GPL(memalloc_socks);
|
||||
|
||||
/**
|
||||
* sk_set_memalloc - sets %SOCK_MEMALLOC
|
||||
* @sk: socket to set it on
|
||||
@@ -283,6 +286,7 @@ void sk_set_memalloc(struct sock *sk)
|
||||
{
|
||||
sock_set_flag(sk, SOCK_MEMALLOC);
|
||||
sk->sk_allocation |= __GFP_MEMALLOC;
|
||||
static_key_slow_inc(&memalloc_socks);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sk_set_memalloc);
|
||||
|
||||
@@ -290,6 +294,7 @@ void sk_clear_memalloc(struct sock *sk)
|
||||
{
|
||||
sock_reset_flag(sk, SOCK_MEMALLOC);
|
||||
sk->sk_allocation &= ~__GFP_MEMALLOC;
|
||||
static_key_slow_dec(&memalloc_socks);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sk_clear_memalloc);
|
||||
|
||||
|
Reference in New Issue
Block a user