diff mbox

[net-next] net: allow better page reuse in splice(sock -> pipe)

Message ID 1334864297.2395.220.camel@edumazet-glaptop
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet April 19, 2012, 7:38 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

splice() from socket to pipe needs linear_to_page() helper to transfert
skb header to part of page.

We can reset the offset in the current sk->sk_sndmsg_page if we are the
last user of the page.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/skbuff.c |    3 +++
 1 file changed, 3 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller April 21, 2012, 8:31 p.m. UTC | #1
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 19 Apr 2012 21:38:17 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> splice() from socket to pipe needs linear_to_page() helper to transfert
> skb header to part of page.
> 
> We can reset the offset in the current sk->sk_sndmsg_page if we are the
> last user of the page.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 43c490d..bf257de 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1565,6 +1565,9 @@  new_page:
 	} else {
 		unsigned int mlen;
 
+		/* If we are the only user of the page, we can reset offset */
+		if (page_count(p) == 1)
+			sk->sk_sndmsg_off = 0;
 		off = sk->sk_sndmsg_off;
 		mlen = PAGE_SIZE - off;
 		if (mlen < 64 && mlen < *len) {