From: Eric Dumazet <erdnetdev@gmail.com>
To: Daniel Borkmann <dborkman@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: sock: adapt SOCK_MIN_RCVBUF and SOCK_MIN_SNDBUF
Date: Wed, 19 Jun 2013 02:58:19 -0700 [thread overview]
Message-ID: <1371635899.3252.290.camel@edumazet-glaptop> (raw)
In-Reply-To: <1371635505.3252.285.camel@edumazet-glaptop>
On Wed, 2013-06-19 at 02:51 -0700, Eric Dumazet wrote:
> On Wed, 2013-06-19 at 11:18 +0200, Daniel Borkmann wrote:
> > The current situation is that SOCK_MIN_RCVBUF is 2048 + sizeof(struct sk_buff))
> > while SOCK_MIN_SNDBUF is 2048. Since in both cases, skb->truesize is used for
> > sk_{r,w}mem_alloc accounting, we should have both sizes equal and adjusted
> > through the macro SKB_TRUESIZE(), which is also used elsewhere to adjust sk
> > buffer sizes. The minor adaption in sk_stream_moderate_sndbuf() is to silence
> > a warning by using a typed max macro, as similarly done in SOCK_MIN_RCVBUF
> > occurences, that would appear otherwise.
> >
> > Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> > ---
> > include/net/sock.h | 11 ++++++-----
> > 1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/net/sock.h b/include/net/sock.h
> > index ac8e181..189ef98 100644
> > --- a/include/net/sock.h
> > +++ b/include/net/sock.h
> > @@ -2045,18 +2045,19 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
> > sock_wake_async(sk->sk_socket, how, band);
> > }
> >
> > -#define SOCK_MIN_SNDBUF 2048
> > /*
> > - * Since sk_rmem_alloc sums skb->truesize, even a small frame might need
> > - * sizeof(sk_buff) + MTU + padding, unless net driver perform copybreak
> > + * Since sk_{r,w}mem_alloc sums skb->truesize, even a small frame might
> > + * need sizeof(sk_buff) + sizeof(skb_shared_info) + MTU + padding, unless
> > + * net driver perform copybreak.
> > */
> > -#define SOCK_MIN_RCVBUF (2048 + sizeof(struct sk_buff))
> > +#define SOCK_MIN_RCVBUF SKB_TRUESIZE(2048)
> > +#define SOCK_MIN_SNDBUF SKB_TRUESIZE(2048)
> >
> >
> > static inline void sk_stream_moderate_sndbuf(struct sock *sk)
> > {
> > if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) {
> > sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued >> 1);
> > - sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF);
> > + sk->sk_sndbuf = max_t(u32, sk->sk_sndbuf, SOCK_MIN_SNDBUF);
> > }
> > }
> >
>
> Funny you send this patch, because I prepared a similar patch
> yesterday ;)
>
> My motivation was a bit different, because we hit a (small) regression
> here in Google for some applications setting low SO_SNDBUF/SO_RCVBUF
> values, because of new TCP needs :
>
> Minimal skb truesize in transmit path is indeed SKB_TRUESIZE(2048) after
> commit f07d960df33c5aef ("tcp: avoid frag allocation for small frames")
>
> And tcp sendmsg() tries to limit skb size to half the congestion window,
> meaning we try to build two skbs at minimum.
>
> So I believe that we need :
>
> /* TCP works better if we can build two skbs at minimum */
> #define SOCK_MIN_SNDBUF (2 * SKB_TRUESIZE(2048))
Or more exactly :
prev parent reply other threads:[~2013-06-19 9:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 9:18 [PATCH net-next] net: sock: adapt SOCK_MIN_RCVBUF and SOCK_MIN_SNDBUF Daniel Borkmann
2013-06-19 9:51 ` Eric Dumazet
2013-06-19 9:57 ` Daniel Borkmann
2013-06-19 10:02 ` Eric Dumazet
2013-06-19 9:58 ` Eric Dumazet [this message]
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=1371635899.3252.290.camel@edumazet-glaptop \
--to=erdnetdev@gmail.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--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