lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 05 Apr 2007 16:40:20 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	virtualization@...ts.osdl.org,
	Glauber de Oliveira Costa <glommer@...il.com>,
	Rusty Russell <rusty@...tcorp.com.au>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] Lguest launcher, child starving parent

Glauber noticed long delays between hitting a key, and seeing data come
up on the virtual console.  Looking into this, I found that the
wake_parent routine that reads from all devices was actually starving
out the parent after sending the parent a signal to wake up.

The thing is, the child which takes the console input is recognized by
the scheduler as an interactive process.  The parent, doesn't do so
much, so it is recognized more as a CPU hog. So the child easily gets a
higher priority than the parent.

So when the child receives data from the console, it sends a signal to
the parent and then does another select.  The problem is that the select
doesn't actually read from the device, and will return immediately since
their is still data pending until it is read.  But it's the parent that
reads the data.  So the child actually starves the parent from reading
the data by spinning and waiting for it to read the data.

The fix I implemented was to have the child wait for a response from the
parent before going on. Since there was already communication between
the parent and child via a pipe, I used that. This time, the data
returned by the pipe is either everything went fine (fd == -1) or the
device should be ignored (fd >= 0).

Signed-off-by: Steven Rostedt <rostedt@...dmis.org>

Index: linux-2.6-lguest/Documentation/lguest/lguest.c
===================================================================
--- linux-2.6-lguest.orig/Documentation/lguest/lguest.c	2007-04-05 16:13:08.000000000 -0400
+++ linux-2.6-lguest/Documentation/lguest/lguest.c	2007-04-05 16:16:31.000000000 -0400
@@ -328,15 +328,15 @@ static void wake_parent(int pipefd, stru
 
 	for (;;) {
 		fd_set rfds = devices->infds;
+		int ignorefd;
 
 		select(devices->max_infd+1, &rfds, NULL, NULL, NULL);
-		if (FD_ISSET(pipefd, &rfds)) {
-			int ignorefd;
-			if (read(pipefd, &ignorefd, sizeof(ignorefd)) == 0)
-				exit(0);
-			FD_CLR(ignorefd, &devices->infds);
-		}
 		kill(getppid(), SIGUSR1);
+		/* wait for parent response */
+		if (read(pipefd, &ignorefd, sizeof(ignorefd)) == 0)
+			exit(0);
+		if (ignorefd >= 0)
+			FD_CLR(ignorefd, &devices->infds);
 	}
 }
 
@@ -594,6 +594,7 @@ static void handle_output(int fd, unsign
 static void handle_input(int fd, int childfd, struct device_list *devices)
 {
 	struct timeval poll = { .tv_sec = 0, .tv_usec = 0 };
+	int fdok = -1;
 
 	for (;;) {
 		struct device *i;
@@ -608,7 +609,9 @@ static void handle_input(int fd, int chi
 					FD_CLR(i->fd, &devices->infds);
 					/* Tell child to ignore it too... */
 					write(childfd, &i->fd, sizeof(i->fd));
-				}
+				} else
+					/* Tell child to continue */
+					write(childfd, &fdok, sizeof(fdok));
 			}
 		}
 	}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ