Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Amit Salecha <amit.salecha@qlogic.com>
Cc: David Miller <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Ameen Rahman <ameen.rahman@qlogic.com>,
	Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Subject: RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2
Date: Tue, 21 Sep 2010 11:23:13 +0200	[thread overview]
Message-ID: <1285060993.2617.163.camel@edumazet-laptop> (raw)
In-Reply-To: <99737F4847ED0A48AECC9F4A1974A4B80F86F80278@MNEXMB2.qlogic.org>

Le mardi 21 septembre 2010 à 03:41 -0500, Amit Salecha a écrit :

> > Amit, if you believe this is a problem, you should address it for all
> > NICS, not only qlcnic.
> > 
> > Qlcnic was lying to stack, because it consumed 2Kbytes blocs and
> > pretended they were consuming skb->len bytes.
> > (assuming MTU=1500, problem is worse if MTU is bigger)
> > 
> > So in order to improve "throughput", you were allowing for memory
> > exhaust and freeze of the _machine_ ?
> >
> This won't lead to such problem. truesize is used for accounting only.

You must have big machines in your lab and never hit OOM ?

You really should take a look on various files in net/core, net/ipv4
trees. And files like "/proc/sys/net/tcp_mem", "/proc/sys/net/udp_mem"

In fact, truesize is _underestimated_ : (we dont account for struct
skb_shared_info) and kmalloc() rounding

We probably should use this patch (without having to check all possible
net drivers !)

Problem is this would slow down alloc_skb(), so this patch is not for
inclusion.

cheap alternative would be to use 

size + sizeof(struct sk_buff) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))

If you think about it, when 128bit arches come, truesize will grow anyway.
If some tuning is needed in our stack, we'll do it.

(socket api SO_RCVBUF/ SO_SNDBUF is the problem, because
 applications are not aware of packetization or kernel internals)

SOCK_MIN_RCVBUF is way too small, since sizeof(struct sk_buff) 
is already close to 256. I guess we cannot even receive a single frame.

 include/net/sock.h |    2 +-
 net/core/skbuff.c  |    2 +-
 net/core/sock.c    |    8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/include/net/sock.h b/include/net/sock.h
index 8ae97c4..348fc9e 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1558,7 +1558,7 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
 }
 
 #define SOCK_MIN_SNDBUF 2048
-#define SOCK_MIN_RCVBUF 256
+#define SOCK_MIN_RCVBUF 1024
 
 static inline void sk_stream_moderate_sndbuf(struct sock *sk)
 {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 752c197..5ab2e8e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -196,7 +196,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
 	 * the tail pointer in struct sk_buff!
 	 */
 	memset(skb, 0, offsetof(struct sk_buff, tail));
-	skb->truesize = size + sizeof(struct sk_buff);
+	skb->truesize = ksize(data) + sizeof(struct sk_buff);
 	atomic_set(&skb->users, 1);
 	skb->head = data;
 	skb->data = data;
diff --git a/net/core/sock.c b/net/core/sock.c
index f3a06c4..803e041 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -535,10 +535,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 			val = sysctl_wmem_max;
 set_sndbuf:
 		sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
-		if ((val * 2) < SOCK_MIN_SNDBUF)
+		if ((val * 4) < SOCK_MIN_SNDBUF)
 			sk->sk_sndbuf = SOCK_MIN_SNDBUF;
 		else
-			sk->sk_sndbuf = val * 2;
+			sk->sk_sndbuf = val * 4;
 
 		/*
 		 *	Wake up sending tasks if we
@@ -579,10 +579,10 @@ set_rcvbuf:
 		 * returning the value we actually used in getsockopt
 		 * is the most desirable behavior.
 		 */
-		if ((val * 2) < SOCK_MIN_RCVBUF)
+		if ((val * 4) < SOCK_MIN_RCVBUF)
 			sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
 		else
-			sk->sk_rcvbuf = val * 2;
+			sk->sk_rcvbuf = val * 4;
 		break;
 
 	case SO_RCVBUFFORCE:



  reply	other threads:[~2010-09-21  9:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-17  5:14 [PATCHv2 NEXT 0/5]qlcnic: vlan rx accleration support Amit Kumar Salecha
2010-09-17  5:14 ` [PATCHv2 NEXT 1/5] qlcnic: support vlan rx accleration Amit Kumar Salecha
2010-09-17  5:29   ` Eric Dumazet
2010-09-17  9:57   ` [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2 Eric Dumazet
2010-09-17 10:53     ` Amit Salecha
2010-09-18  5:58     ` David Miller
2010-09-20 11:16     ` Amit Salecha
2010-09-20 12:18       ` Eric Dumazet
2010-09-20 12:28         ` [PATCH net-next-2.6] qlnic: dont set skb->truesize Eric Dumazet
2010-09-20 17:09           ` David Miller
2010-09-20 15:58       ` [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2 David Miller
2010-09-21  8:19         ` Amit Salecha
2010-09-21  8:34           ` Eric Dumazet
2010-09-21  8:41             ` Amit Salecha
2010-09-21  9:23               ` Eric Dumazet [this message]
2010-09-21 19:33               ` David Miller
2010-09-21 19:55                 ` [PATCH] netxen: dont set skb->truesize Eric Dumazet
2010-09-21 20:04                   ` David Miller
2010-09-17  5:14 ` [PATCHv2 NEXT 2/5] qlcnic: vlan gro support Amit Kumar Salecha
2010-09-17 18:24   ` David Miller
2010-09-17 18:25     ` David Miller
2010-09-17  5:14 ` [PATCHv2 NEXT 3/5] qlcnic: vlan lro support Amit Kumar Salecha
2010-09-17  5:14 ` [PATCHv2 NEXT 4/5] qlcnic: remove fw version check Amit Kumar Salecha
2010-09-17  5:14 ` [PATCHv2 NEXT 5/5] qlcnic: update version 5.0.10 Amit Kumar Salecha
2010-09-17 18:31 ` [PATCHv2 NEXT 0/5]qlcnic: vlan rx accleration support David Miller

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=1285060993.2617.163.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=ameen.rahman@qlogic.com \
    --cc=amit.salecha@qlogic.com \
    --cc=anirban.chakraborty@qlogic.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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