linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] [PATCH 1/3] BUG: UML does not handle sigpipe. As a result when running it under expect or redirecting the IO from the console to an external program it will crash if the program stops or exits.
@ 2014-03-08  6:51 anton.ivanov
  2014-03-08  6:51 ` [uml-devel] [PATCH 2/3] BUG: Memory corruption on startup anton.ivanov
  2014-03-08  6:51 ` [uml-devel] [PATCH 3/3] BUG: PIPE is the wrong IPC for this type of inter-thread communication anton.ivanov
  0 siblings, 2 replies; 4+ messages in thread
From: anton.ivanov @ 2014-03-08  6:51 UTC (permalink / raw)
  To: user-mode-linux-devel

From: Anton Ivanov <antivano@cisco.com>


Signed-off-by: Anton Ivanov <antivano@cisco.com>
---
 arch/um/os-Linux/main.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index 7a86dd5..048166d 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -149,6 +149,7 @@ int __init main(int argc, char **argv, char **envp)
 #endif
 
 	do_uml_initcalls();
+	change_sig(SIGPIPE, 0);
 	ret = linux_main(argc, argv);
 
 	/*
-- 
1.7.10.4


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [uml-devel] [PATCH 2/3] BUG: Memory corruption on startup
  2014-03-08  6:51 [uml-devel] [PATCH 1/3] BUG: UML does not handle sigpipe. As a result when running it under expect or redirecting the IO from the console to an external program it will crash if the program stops or exits anton.ivanov
@ 2014-03-08  6:51 ` anton.ivanov
  2014-03-08  6:51 ` [uml-devel] [PATCH 3/3] BUG: PIPE is the wrong IPC for this type of inter-thread communication anton.ivanov
  1 sibling, 0 replies; 4+ messages in thread
From: anton.ivanov @ 2014-03-08  6:51 UTC (permalink / raw)
  To: user-mode-linux-devel

From: Anton Ivanov <antivano@cisco.com>

The reverse case of this race (you must msync before read) is
well known. This is the not so common one.

It can be triggered only on systems which do a lot of task
switching and only at UML startup. If you are starting 200+ UMLs
~ 0.5% will always die without this fix.

Signed-off-by: Anton Ivanov <antivano@cisco.com>
---
 arch/um/include/shared/os.h |    1 +
 arch/um/kernel/physmem.c    |    1 +
 arch/um/os-Linux/file.c     |    6 ++++++
 3 files changed, 8 insertions(+)

diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index 89b686c1..3c9738d 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
@@ -136,6 +136,7 @@ extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
 extern int os_get_ifname(int fd, char *namebuf);
 extern int os_set_slip(int fd);
 extern int os_mode_fd(int fd, int mode);
+extern int os_fsync_file(int fd);
 
 extern int os_seek_file(int fd, unsigned long long offset);
 extern int os_open_file(const char *file, struct openflags flags, int mode);
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index f116db1..30fdd5d0 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -103,6 +103,7 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
 	 */
 	os_seek_file(physmem_fd, __pa(&__syscall_stub_start));
 	os_write_file(physmem_fd, &__syscall_stub_start, PAGE_SIZE);
+	os_fsync_file(physmem_fd);
 
 	bootmap_size = init_bootmem(pfn, pfn + delta);
 	free_bootmem(__pa(reserve_end) + bootmap_size,
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index b049a63..a4f0e65 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -237,6 +237,12 @@ void os_close_file(int fd)
 {
 	close(fd);
 }
+int os_fsync_file(int fd)
+{
+	if (fsync(fd) < 0) 
+	    return -errno;
+	return 0;
+}
 
 int os_seek_file(int fd, unsigned long long offset)
 {
-- 
1.7.10.4


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [uml-devel] [PATCH 3/3] BUG: PIPE is the wrong IPC for this type of inter-thread communication.
  2014-03-08  6:51 [uml-devel] [PATCH 1/3] BUG: UML does not handle sigpipe. As a result when running it under expect or redirecting the IO from the console to an external program it will crash if the program stops or exits anton.ivanov
  2014-03-08  6:51 ` [uml-devel] [PATCH 2/3] BUG: Memory corruption on startup anton.ivanov
@ 2014-03-08  6:51 ` anton.ivanov
  2014-03-08  7:47   ` Anton Ivanov
  1 sibling, 1 reply; 4+ messages in thread
From: anton.ivanov @ 2014-03-08  6:51 UTC (permalink / raw)
  To: user-mode-linux-devel

From: Anton Ivanov <antivano@cisco.com>

For more details see:

http://stackoverflow.com/questions/4624071/pipe-buffer-size-is-4k-or-64k

The observations on that thread have been confirmed by us for UML's
UBD driver. If you load UML with network IO and do disk IO at the same
time the UBD IO helper thread fails to process requests fast enough.

In most cases this will lead to a slowdown in disk IO as well as
inability to execute new processes until the network load goes away.
In some cases however it will not recover. Example - with our new high
performance 1G+ network drivers a wget of 1G file from the network
is a nearly guaranteed crash if it writes out to UBD.

The crashes and the slowdowns are not observed with this patch -
it switches the IPC to socket which does not have the pipe granularity
and queue size problems.

This signifies a problem with overall UBD error handling which this
patch fails to fix. The workaround should be good enough for most
cases.

Signed-off-by: Anton Ivanov <antivano@cisco.com>
---
 arch/um/drivers/ubd_kern.c |    2 +-
 arch/um/drivers/ubd_user.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 944453a..c9a5717 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1291,7 +1291,7 @@ static void do_ubd_request(struct request_queue *q)
 			n = os_write_file(thread_fd, &io_req,
 					  sizeof(struct io_thread_req *));
 			if(n != sizeof(struct io_thread_req *)){
-				if(n != -EAGAIN)
+				if(!((n == -EAGAIN) || (n == -ENOBUFS)))
 					printk("write to io thread failed, "
 					       "errno = %d\n", -n);
 				else if(list_empty(&dev->restart))
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
index 007b94d..f1f84a4 100644
--- a/arch/um/drivers/ubd_user.c
+++ b/arch/um/drivers/ubd_user.c
@@ -32,7 +32,7 @@ int start_io_thread(unsigned long sp, int *fd_out)
 {
 	int pid, fds[2], err;
 
-	err = os_pipe(fds, 1, 1);
+	err = socketpair(AF_UNIX, SOCK_STREAM, 0, (int *) &fds);
 	if(err < 0){
 		printk("start_io_thread - os_pipe failed, err = %d\n", -err);
 		goto out;
-- 
1.7.10.4


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH 3/3] BUG: PIPE is the wrong IPC for this type of inter-thread communication.
  2014-03-08  6:51 ` [uml-devel] [PATCH 3/3] BUG: PIPE is the wrong IPC for this type of inter-thread communication anton.ivanov
@ 2014-03-08  7:47   ` Anton Ivanov
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Ivanov @ 2014-03-08  7:47 UTC (permalink / raw)
  To: user-mode-linux-devel

This bug has been there as far back as 2.6.x... It is known as
"userspace process sits in Z state", occasional hang, etc. It has been
tagged by maintainers as "unreproducible" for 7 odd years now. I agree -
on stock UML it is difficult to reproduce - it may take half a day to
hit it when running a specially designed test case. You have to improve
network IO to a reasonable performance level for it to come and shine on
a regular basis.

In any case - this fix also provides a considerable performance
improvement on "real life" network apps which need both disk io and
network. There you hit the "pipe is no longer consuming requests"
barrier on a very regular basis.

For example: when wgetting a file and storing it across a 1GBit link
without it I get ~ 340MBit max. With it I can hit line rate.

I have filed it as Debian 741077, the other two are 741076 and 741075.

By the way - this means that the request disposal and handling of failed
requests in the UBD driver is wrong somewhere else. No idea where.

A.


On 08/03/14 06:51, anton.ivanov@kot-begemot.co.uk wrote:
> From: Anton Ivanov <antivano@cisco.com>
>
> For more details see:
>
> http://stackoverflow.com/questions/4624071/pipe-buffer-size-is-4k-or-64k
>
> The observations on that thread have been confirmed by us for UML's
> UBD driver. If you load UML with network IO and do disk IO at the same
> time the UBD IO helper thread fails to process requests fast enough.
>
> In most cases this will lead to a slowdown in disk IO as well as
> inability to execute new processes until the network load goes away.
> In some cases however it will not recover. Example - with our new high
> performance 1G+ network drivers a wget of 1G file from the network
> is a nearly guaranteed crash if it writes out to UBD.
>
> The crashes and the slowdowns are not observed with this patch -
> it switches the IPC to socket which does not have the pipe granularity
> and queue size problems.
>
> This signifies a problem with overall UBD error handling which this
> patch fails to fix. The workaround should be good enough for most
> cases.
>
> Signed-off-by: Anton Ivanov <antivano@cisco.com>
> ---
>  arch/um/drivers/ubd_kern.c |    2 +-
>  arch/um/drivers/ubd_user.c |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 944453a..c9a5717 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -1291,7 +1291,7 @@ static void do_ubd_request(struct request_queue *q)
>  			n = os_write_file(thread_fd, &io_req,
>  					  sizeof(struct io_thread_req *));
>  			if(n != sizeof(struct io_thread_req *)){
> -				if(n != -EAGAIN)
> +				if(!((n == -EAGAIN) || (n == -ENOBUFS)))
>  					printk("write to io thread failed, "
>  					       "errno = %d\n", -n);
>  				else if(list_empty(&dev->restart))
> diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
> index 007b94d..f1f84a4 100644
> --- a/arch/um/drivers/ubd_user.c
> +++ b/arch/um/drivers/ubd_user.c
> @@ -32,7 +32,7 @@ int start_io_thread(unsigned long sp, int *fd_out)
>  {
>  	int pid, fds[2], err;
>  
> -	err = os_pipe(fds, 1, 1);
> +	err = socketpair(AF_UNIX, SOCK_STREAM, 0, (int *) &fds);
>  	if(err < 0){
>  		printk("start_io_thread - os_pipe failed, err = %d\n", -err);
>  		goto out;


-- 
"If you think it's expensive to hire a professional to do the job,
    wait until you hire an amateur."
				    Paul Neal "Red" Adair 

A. R. Ivanov
E-mail:  anton.ivanov@kot-begemot.co.uk


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-08  7:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-08  6:51 [uml-devel] [PATCH 1/3] BUG: UML does not handle sigpipe. As a result when running it under expect or redirecting the IO from the console to an external program it will crash if the program stops or exits anton.ivanov
2014-03-08  6:51 ` [uml-devel] [PATCH 2/3] BUG: Memory corruption on startup anton.ivanov
2014-03-08  6:51 ` [uml-devel] [PATCH 3/3] BUG: PIPE is the wrong IPC for this type of inter-thread communication anton.ivanov
2014-03-08  7:47   ` Anton Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox