Skip to contentSkip to conversation

Patch "netlink: do not enter direct reclaim from netlink_dump()" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Nov 10, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

netlink: do not enter direct reclaim from netlink_dump()

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
netlink-do-not-enter-direct-reclaim-from-netlink_dump.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Thu Nov 10 16:42:45 CET 2016

From: Eric Dumazet <[email protected]>
Date: Thu, 6 Oct 2016 04:13:18 +0900
Subject: netlink: do not enter direct reclaim from netlink_dump()

From: Eric Dumazet <[email protected]>

[ Upstream commit d35c99ff77ecb2eb239731b799386f3b3637a31e ]

Since linux-3.15, netlink_dump() can use up to 16384 bytes skb allocations.

Due to struct skb_shared_info ~320 bytes overhead, we end up using order-3 (on x86) page allocations, that might trigger direct reclaim and add stress.

The intent was really to attempt a large allocation but immediately fallback to a smaller one (order-1 on x86) in case of memory stress.

On recent kernels (linux-4.4), we can remove __GFP_DIRECT_RECLAIM to meet the goal. Old kernels would need to remove __GFP_WAIT

While we are at it, since we do an order-3 allocation, allow to use all the allocated bytes instead of 16384 to reduce syscalls during large dumps.

iproute2 already uses 32KB recvmsg() buffer sizes.

Alexei provided an initial patch downsizing to SKB_WITH_OVERHEAD(16384)

---
 net/netlink/af_netlink.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/netlink/af_netlink.c +4 -5
@@ -2557,7 +2557,7 @@ static int netlink_recvmsg(struct socket
 	/* Record the max length of recvmsg() calls for future allocations */
 	nlk->max_recvmsg_len = max(nlk->max_recvmsg_len, len);
 	nlk->max_recvmsg_len = min_t(size_t, nlk->max_recvmsg_len,
-				     16384);
+				     SKB_WITH_OVERHEAD(32768));
 
 	copied = data_skb->len;
 	if (len < copied) {
@@ -2810,14 +2810,13 @@ static int netlink_dump(struct sock *sk)
 	if (alloc_min_size < nlk->max_recvmsg_len) {
 		alloc_size = nlk->max_recvmsg_len;
 		skb = netlink_alloc_skb(sk, alloc_size, nlk->portid,
-					GFP_KERNEL |
-					__GFP_NOWARN |
-					__GFP_NORETRY);
+					(GFP_KERNEL & ~__GFP_DIRECT_RECLAIM) |
+					__GFP_NOWARN | __GFP_NORETRY);
 	}
 	if (!skb) {
 		alloc_size = alloc_min_size;
 		skb = netlink_alloc_skb(sk, alloc_size, nlk->portid,
-					GFP_KERNEL);
+					(GFP_KERNEL & ~__GFP_DIRECT_RECLAIM));
 	}
 	if (!skb)
 		goto errout_skb;

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/ipv4-use-the-right-lock-for-ping_group_range.patch queue-4.4/ipv4-disable-bh-in-set_ping_group_range.patch queue-4.4/tcp-fix-a-compile-error-in-dbgundo.patch queue-4.4/net-avoid-sk_forward_alloc-overflows.patch queue-4.4/udp-fix-ip_checksum-handling.patch queue-4.4/netlink-do-not-enter-direct-reclaim-from-netlink_dump.patch queue-4.4/ipv6-tcp-restore-ip6cb-for-pktoptions-skbs.patch queue-4.4/tcp-fix-overflow-in-__tcp_retransmit_skb.patch queue-4.4/packet-on-direct_xmit-limit-tso-and-csum-to-supported-devices.patch queue-4.4/net-pktgen-remove-rcu-locking-in-pktgen_change_name.patch