Re: [PROBLEM] hard-lock with kmemtrace, relayfs, and splice

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Tom Zanussi
Date: Friday, October 10, 2008 - 9:58 pm

On Fri, 2008-10-10 at 12:42 +0300, Pekka Enberg wrote:

It looks like you hit the same problem as described here:

commit 8191ecd1d14c6914c660dfa007154860a7908857

    splice: fix infinite loop in generic_file_splice_read()

relay uses the same loop but it never got noticed or fixed.  Can you try
the following patch:

diff --git a/kernel/relay.c b/kernel/relay.c
index 8d13a78..6a4d439 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1318,12 +1318,9 @@ static ssize_t relay_file_splice_read(struct file *in,
 		if (ret < 0)
 			break;
 		else if (!ret) {
-			if (spliced)
-				break;
-			if (flags & SPLICE_F_NONBLOCK) {
+			if (flags & SPLICE_F_NONBLOCK)
 				ret = -EAGAIN;
-				break;
-			}
+			break;
 		}
 
 		*ppos += ret;


It worked for me, but I also had to apply the following patch to
kmemtraced:

diff --git a/kmemtraced.c b/kmemtraced.c
index 217478d..324ced9 100644
--- a/kmemtraced.c
+++ b/kmemtraced.c
@@ -109,6 +109,8 @@ static void *reader_thread(void *data)
 		if (retval < 0)
 			panic("splice() (from) failed: %s\n",
 			      strerror(errno));
+		if (!retval)
+			continue;
 		retval = splice(pipe_fd[0], NULL, log_fd, NULL,
 				128, SPLICE_F_MOVE);
 		if (retval < 0)


Otherwise it would end up hanging kmemtraced in the second splice (pipe
to log_fd) if the return from the first splice was 0 (i.e. there's no
data available (and we can never know if there will ever be any
more)).

I'm not sure why kmemtraced is only splicing 128 bytes at a time - it
seems to defeat the purpose - or why it wouldn't be using poll to know
when there's at least a whole sub-buffer to splice, but to each his own.
Hopefully the kernel patch at least fixes the loop. 

Tom



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

Messages in current thread:
[PROBLEM] hard-lock with kmemtrace, relayfs, and splice, Pekka Enberg, (Fri Oct 10, 2:42 am)
Re: [PROBLEM] hard-lock with kmemtrace, relayfs, and splice, Eduard - Gabriel Mun ..., (Fri Oct 10, 4:51 am)
Re: [PROBLEM] hard-lock with kmemtrace, relayfs, and splice, Tom Zanussi, (Fri Oct 10, 9:58 pm)
Re: [PROBLEM] hard-lock with kmemtrace, relayfs, and splice, Eduard - Gabriel Mun ..., (Sat Oct 11, 11:17 am)
Re: [PROBLEM] hard-lock with kmemtrace, relayfs, and splice, Eduard - Gabriel Mun ..., (Tue Oct 14, 12:30 am)
Re: [PROBLEM] hard-lock with kmemtrace, relayfs, and splice, Eduard - Gabriel Mun ..., (Sat Oct 25, 7:04 am)