From: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>,
"David S. Miller" <davem@davemloft.net>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
James Morris <jmorris@namei.org>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
Patrick McHardy <kaber@trash.net>,
"\"\"hannes@stressinduktion.org\"\"" <hannes@stressinduktion.org>,
netdev@vger.kernel.org (open list:NETWORKING [GENERAL]),
linux-kernel@vger.kernel.org (open list),
"Haakon Bugge" <haakon.bugge@oracle.com>
Subject: [PATCH v2] net:Add sysctl_tcp_sg_max_skb_frags
Date: Wed, 27 Jan 2016 14:20:29 +0100 [thread overview]
Message-ID: <1453900829-3384-1-git-send-email-hans.westgaard.ry@oracle.com> (raw)
In-Reply-To: <568F87AC.60405@oracle.com>
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 in
scatter/gather.
Signed-off-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
---
include/net/tcp.h | 2 ++
net/ipv4/sysctl_net_ipv4.c | 10 ++++++++++
net/ipv4/tcp.c | 8 +++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index f80e74c..8d18df3 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -285,6 +285,8 @@ extern int sysctl_tcp_invalid_ratelimit;
extern int sysctl_tcp_pacing_ss_ratio;
extern int sysctl_tcp_pacing_ca_ratio;
+extern int sysctl_tcp_sg_max_skb_frags;
+
extern atomic_long_t tcp_memory_allocated;
extern struct percpu_counter tcp_sockets_allocated;
extern int tcp_memory_pressure;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index a0bd7a5..498dcf9 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -40,6 +40,7 @@ static int ip_ttl_min = 1;
static int ip_ttl_max = 255;
static int tcp_syn_retries_min = 1;
static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
+static int tcp_sg_max_skb_frags = MAX_SKB_FRAGS;
static int ip_ping_group_range_min[] = { 0, 0 };
static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
@@ -761,6 +762,15 @@ static struct ctl_table ipv4_table[] = {
.proc_handler = proc_dointvec_ms_jiffies,
},
{
+ .procname = "tcp_sg_max_skb_frags",
+ .data = &sysctl_tcp_sg_max_skb_frags,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = &one,
+ .extra2 = &tcp_sg_max_skb_frags,
+ },
+ {
.procname = "icmp_msgs_per_sec",
.data = &sysctl_icmp_msgs_per_sec,
.maxlen = sizeof(int),
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c82cca1..928d2c7 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -300,7 +300,9 @@ EXPORT_SYMBOL(sysctl_tcp_wmem);
atomic_long_t tcp_memory_allocated; /* Current allocated memory. */
EXPORT_SYMBOL(tcp_memory_allocated);
-
+/* maximum number of fragments for tcp scatter/gather */
+int sysctl_tcp_sg_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
+EXPORT_SYMBOL(sysctl_tcp_sg_max_skb_frags);
/*
* Current number of TCP sockets.
*/
@@ -938,7 +940,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_tcp_sg_max_skb_frags) {
tcp_mark_push(tp, skb);
goto new_segment;
}
@@ -1211,7 +1213,7 @@ new_segment:
if (!skb_can_coalesce(skb, i, pfrag->page,
pfrag->offset)) {
- if (i == MAX_SKB_FRAGS || !sg) {
+ if (i == sysctl_tcp_sg_max_skb_frags || !sg) {
tcp_mark_push(tp, skb);
goto new_segment;
}
--
2.4.3
next prev parent reply other threads:[~2016-01-27 13:21 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-06 13:16 [PATCH] net: add per device sg_max_frags for skb Hans Westgaard Ry
2016-01-06 13:59 ` David Laight
2016-01-08 9:55 ` Hans Westgaard Ry
2016-01-08 10:33 ` David Laight
2016-01-08 11:47 ` Hannes Frederic Sowa
2016-01-13 13:57 ` Hans Westgaard Ry
2016-01-13 14:19 ` Eric Dumazet
2016-01-13 14:20 ` Eric Dumazet
2016-01-13 15:07 ` Hannes Frederic Sowa
2016-01-13 15:38 ` David Miller
2016-01-13 15:44 ` Eric Dumazet
2016-01-13 21:07 ` Eric W. Biederman
2016-01-27 13:20 ` Hans Westgaard Ry [this message]
2016-01-27 15:15 ` [PATCH v2] net:Add sysctl_tcp_sg_max_skb_frags Eric Dumazet
2016-01-27 18:12 ` Hannes Frederic Sowa
2016-02-01 13:12 ` Hans Westgaard Ry
2016-01-27 20:13 ` David Miller
2016-02-03 8:26 ` [PATCH v3] net:Add sysctl_max_skb_frags Hans Westgaard Ry
2016-02-03 11:25 ` Herbert Xu
2016-02-03 11:36 ` Hannes Frederic Sowa
2016-02-03 12:20 ` Herbert Xu
2016-02-03 14:03 ` Hannes Frederic Sowa
2016-02-03 14:30 ` Eric Dumazet
2016-02-03 17:36 ` David Laight
2016-02-03 15:58 ` Alexander Duyck
2016-02-03 16:07 ` Eric Dumazet
2016-02-03 17:43 ` Alexander Duyck
2016-02-03 17:54 ` Eric Dumazet
2016-02-03 18:24 ` Alexander Duyck
2016-02-03 19:23 ` Eric Dumazet
2016-02-03 21:03 ` Alexander Duyck
2016-02-09 9:30 ` David Miller
2016-01-06 14:05 ` [PATCH] net: add per device sg_max_frags for skb Eric Dumazet
2016-01-08 10:01 ` Hans Westgaard Ry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453900829-3384-1-git-send-email-hans.westgaard.ry@oracle.com \
--to=hans.westgaard.ry@oracle.com \
--cc=davem@davemloft.net \
--cc=haakon.bugge@oracle.com \
--cc=hannes@stressinduktion.org \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).