From: Kirill Tkhai <ktkhai@parallels.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>, <netdev@vger.kernel.org>,
<edumazet@google.com>
Subject: Re: net: unix: Align send data_len up to PAGE_SIZE
Date: Thu, 15 May 2014 18:27:56 +0400 [thread overview]
Message-ID: <1400164076.3782.32.camel@tkhai> (raw)
In-Reply-To: <1400160440.7973.135.camel@edumazet-glaptop2.roam.corp.google.com>
В Чт, 15/05/2014 в 06:27 -0700, Eric Dumazet пишет:
> On Thu, 2014-05-15 at 12:54 +0400, Kirill Tkhai wrote:
>
> >
> > And I assumed it's OK to allocate skbs with zero header size like this:
> >
> > sock_alloc_send_pskb(sk, 0, data_len)
> >
> > Please say, if it's wrong.
> >
>
> Its OK
>
Thanks for the reply. So, new version is below.
[PATCH]net: unix: Align send data_len up to PAGE_SIZE
Using whole of allocated pages reduces requested skb->data size.
This is just a little more thriftily allocation.
netperf does not show difference with the current performance.
Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
---
net/unix/af_unix.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 749f80c..65d67c2 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1492,10 +1492,12 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
if (len > sk->sk_sndbuf - 32)
goto out;
- if (len > SKB_MAX_ALLOC)
+ if (len > SKB_MAX_ALLOC) {
data_len = min_t(size_t,
len - SKB_MAX_ALLOC,
MAX_SKB_FRAGS * PAGE_SIZE);
+ data_len = PAGE_ALIGN(data_len);
+ }
skb = sock_alloc_send_pskb(sk, len - data_len, data_len,
msg->msg_flags & MSG_DONTWAIT, &err,
@@ -1670,6 +1672,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
data_len = max_t(int, 0, size - SKB_MAX_HEAD(0));
+ data_len = min_t(size_t, size, PAGE_ALIGN(data_len));
+
skb = sock_alloc_send_pskb(sk, size - data_len, data_len,
msg->msg_flags & MSG_DONTWAIT, &err,
get_order(UNIX_SKB_FRAGS_SZ));
next prev parent reply other threads:[~2014-05-15 14:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 14:52 net: unix: Align send data_len up to PAGE_SIZE Kirill Tkhai
2014-05-14 19:15 ` David Miller
2014-05-15 8:54 ` Kirill Tkhai
2014-05-15 13:27 ` Eric Dumazet
2014-05-15 14:27 ` Kirill Tkhai [this message]
2014-05-15 15:41 ` Eric Dumazet
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=1400164076.3782.32.camel@tkhai \
--to=ktkhai@parallels.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.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;
as well as URLs for NNTP newsgroup(s).