[PATCH] tcp: splice as many packets as possible at once

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jens Axboe <jens.axboe@...>
Cc: David Miller <davem@...>, Jarek Poplawski <jarkao2@...>, Ben Mansell <ben@...>, Ingo Molnar <mingo@...>, <linux-kernel@...>, <netdev@...>
Date: Thursday, January 8, 2009 - 1:30 pm

Jens,

here's the other patch I was talking about, for better behaviour of
non-blocking splice(). Ben Mansell also confirms similar improvements
in his tests, where non-blocking splice() initially showed half of
read()/write() performance. Ben, would you mind adding a Tested-By
line ?

Also, please note that this is unrelated to the corruption bug I reported
and does not fix it.

Regards,
Willy

From fafe76713523c8e9767805cfdc7b73323d7bf180 Mon Sep 17 00:00:00 2001
From: Willy Tarreau
Date: Thu, 8 Jan 2009 17:10:13 +0100
Subject: [PATCH] tcp: splice as many packets as possible at once

Currently, in non-blocking mode, tcp_splice_read() returns after
splicing one segment regardless of the len argument. This results
in low performance and very high overhead due to syscall rate when
splicing from interfaces which do not support LRO.

The fix simply consists in not breaking out of the loop after the
first read. That way, we can read up to the size requested by the
caller and still return when there is no data left.

Performance has significantly improved with this fix, with the
number of calls to splice() divided by about 20, and CPU usage
dropped from 100% to 75%.

Signed-off-by: Willy Tarreau
---
net/ipv4/tcp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 35bcddf..80261b4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -615,7 +615,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
lock_sock(sk);

if (sk->sk_err || sk->sk_state == TCP_CLOSE ||
- (sk->sk_shutdown & RCV_SHUTDOWN) || !timeo ||
+ (sk->sk_shutdown & RCV_SHUTDOWN) ||
signal_pending(current))
break;
}
--
1.6.0.3

--
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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] tcp: splice as many packets as possible at once, Willy Tarreau, (Thu Jan 8, 1:30 pm)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Fri Jan 9, 6:42 pm)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Sun Jan 11, 8:58 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Sun Jan 11, 9:35 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Sun Jan 11, 12:05 pm)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Tue Jan 13, 8:13 pm)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Tue Jan 13, 8:22 pm)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 4:53 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Tue Jan 20, 4:37 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Fri Jan 16, 2:51 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Tue Jan 20, 8:11 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Tue Jan 20, 10:06 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Mon Jan 19, 4:40 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Mon Jan 26, 3:59 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 5:54 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 8:15 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 8:06 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 5:42 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 6:47 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 7:40 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Jarek Poplawski, (Wed Jan 14, 7:45 am)
Re: [PATCH] tcp: splice as many packets as possible at once, Evgeniy Polyakov, (Fri Jan 9, 7:01 pm)
[PATCH] tcp: splice as many packets as possible at once, Willy Tarreau, (Thu Jan 8, 4:16 pm)