[Devel] [PATCH RHEL7 COMMIT] ms/net: unix: Align send data_len up to PAGE_SIZE

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jun 24 06:50:08 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.17
------>
commit 3085cf4598565a484bb029376dc77805faab73a9
Author: Kirill Tkhai <ktkhai at odin.com>
Date:   Wed Jun 24 17:50:08 2015 +0400

    ms/net: unix: Align send data_len up to PAGE_SIZE
    
    Port commit 31ff6aa5c86f7564f0dd97c5b3e1404cad238d00 from mainstream.
    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 at parallels.com>
    
    Acked-by: Eric Dumazet <edumazet at google.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    Signed-off-by: Kirill Tkhai <ktkhai at odin.com>
---
 net/unix/af_unix.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 01625cc..23b2c6c 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1483,10 +1483,14 @@ 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);
+
+		BUILD_BUG_ON(SKB_MAX_ALLOC < PAGE_SIZE);
+	}
 
 	skb = sock_alloc_send_pskb(sk, len - data_len, data_len,
 				   msg->msg_flags & MSG_DONTWAIT, &err,
@@ -1661,6 +1665,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));



More information about the Devel mailing list