Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1350107

[PATCH 3.12 012/116] net:Add sysctl_max_skb_frags

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject [PATCH 3.12 012/116] net:Add sysctl_max_skb_frags
Date 2016-03-04 11:00 +0100
Message-ID <r8UGD-4LF-9@gated-at.bofh.it> (permalink)
References <r8TUd-4rg-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

[ Upstream commit 5f74f82ea34c0da80ea0b49192bb5ea06e063593 ]

Devices may have limits on the number of fragments in an skb they support.
Current codebase uses a constant as maximum for number of fragments one
skb can hold and use.
When enabling scatter/gather and running traffic with many small messages
the codebase uses the maximum number of fragments and may thereby violate
the max for certain devices.
The patch introduces a global variable as max number of fragments.

Signed-off-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
Reviewed-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/skbuff.h     |  1 +
 net/core/skbuff.c          |  2 ++
 net/core/sysctl_net_core.c | 10 ++++++++++
 net/ipv4/tcp.c             |  4 ++--
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 16e753a9922a..e492ab7aadbf 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -149,6 +149,7 @@ struct sk_buff;
 #else
 #define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1)
 #endif
+extern int sysctl_max_skb_frags;
 
 typedef struct skb_frag_struct skb_frag_t;
 
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 56cdf3bb1e7f..7df6f539a402 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -76,6 +76,8 @@
 
 struct kmem_cache *skbuff_head_cache __read_mostly;
 static struct kmem_cache *skbuff_fclone_cache __read_mostly;
+int sysctl_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
+EXPORT_SYMBOL(sysctl_max_skb_frags);
 
 /**
  *	skb_panic - private function for out-of-line support
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index f3413ae3d973..d7962397d90f 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -27,6 +27,7 @@ static int one = 1;
 static int ushort_max = USHRT_MAX;
 static int min_sndbuf = SOCK_MIN_SNDBUF;
 static int min_rcvbuf = SOCK_MIN_RCVBUF;
+static int max_skb_frags = MAX_SKB_FRAGS;
 
 #ifdef CONFIG_RPS
 static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
@@ -362,6 +363,15 @@ static struct ctl_table net_core_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec
 	},
+	{
+		.procname	= "max_skb_frags",
+		.data		= &sysctl_max_skb_frags,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &one,
+		.extra2		= &max_skb_frags,
+	},
 	{ }
 };
 
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index a880ccc10f61..392d3259f9ad 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -886,7 +886,7 @@ new_segment:
 
 		i = skb_shinfo(skb)->nr_frags;
 		can_coalesce = skb_can_coalesce(skb, i, page, offset);
-		if (!can_coalesce && i >= MAX_SKB_FRAGS) {
+		if (!can_coalesce && i >= sysctl_max_skb_frags) {
 			tcp_mark_push(tp, skb);
 			goto new_segment;
 		}
@@ -1169,7 +1169,7 @@ new_segment:
 
 				if (!skb_can_coalesce(skb, i, pfrag->page,
 						      pfrag->offset)) {
-					if (i == MAX_SKB_FRAGS || !sg) {
+					if (i == sysctl_max_skb_frags || !sg) {
 						tcp_mark_push(tp, skb);
 						goto new_segment;
 					}
-- 
2.7.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.12 000/116] 3.12.56-stable review Jiri Slaby <jslaby@suse.cz> - 2016-03-04 10:10 +0100
  [PATCH 3.12 001/116] proc: Fix ptrace-based permission checks for accessing task maps Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 016/116] bonding: Fix ARP monitor validation Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 007/116] pptp: fix illegal memory access caused by multiple bind()s Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 012/116] net:Add sysctl_max_skb_frags Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 006/116] af_unix: fix struct pid memory leak Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 008/116] sctp: allow setting SCTP_SACK_IMMEDIATELY by the application Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 009/116] ipv6/udp: use sticky pktinfo egress ifindex on connect() Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 011/116] ipv6: fix a lockdep splat Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
    [PATCH 3.12 015/116] bonding: fix bond_arp_rcv() race of curr_active_slave Jiri Slaby <jslaby@suse.cz> - 2016-03-04 11:00 +0100
  Re: [PATCH 3.12 000/116] 3.12.56-stable review Guenter Roeck <linux@roeck-us.net> - 2016-03-04 15:10 +0100
    Re: [PATCH 3.12 000/116] 3.12.56-stable review Jiri Slaby <jslaby@suse.cz> - 2016-03-08 16:50 +0100
  Re: [PATCH 3.12 000/116] 3.12.56-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-03-04 15:50 +0100

csiph-web