From: Eduard-Gabriel Munteanu <maxdamage@aladin.ro>
To: jdike@karaya.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] UML: fix missing non-blocking I/O, now DEBUG_SHIRQ works
Date: Mon, 11 Jun 2007 01:01:57 +0300 [thread overview]
Message-ID: <1181512917.3157.8.camel@localhost> (raw)
*This message was transferred with a trial version of CommuniGate(r) Pro*
DEBUG_SHIRQ generates spurious interrupts, triggering handlers such as
mconsole_interrupt() or line_interrupt(). They expect data to be
available to be read from their sockets/pipes, but in the case of
spurious interrupts, the host didn't actually send anything, so UML
hangs in read() and friends. Setting those fd's as O_NONBLOCK makes
DEBUG_SHIRQ-enabled UML kernels boot and run correctly.
The patch was written and tested on Linux 2.6.22-rc2-mm1.
I have also included a couple of short/minor fixes for potential
problems.
Signed-off-by: Eduard-Gabriel Munteanu <maxdamage@aladin.ro>
---
arch/um/drivers/chan_user.c | 6 ++++++
arch/um/drivers/mconsole_kern.c | 11 +++++------
arch/um/drivers/mconsole_user.c | 5 +++--
arch/um/drivers/ubd_user.c | 6 ++++++
arch/um/drivers/xterm.c | 7 +++++++
5 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
index 13f0bf8..0a8b785 100644
--- a/arch/um/drivers/chan_user.c
+++ b/arch/um/drivers/chan_user.c
@@ -170,6 +170,12 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out)
err = -EINVAL;
goto out_close;
}
+
+ if (os_set_fd_block(*fd_out, 0)) {
+ printk("winch_tramp: failed to set thread_fd non-blocking.\n");
+ goto out_close;
+ }
+
return err ;
out_close:
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 542c9ef..02d132e 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -74,12 +74,11 @@ static DECLARE_WORK(mconsole_work, mc_work_proc);
static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
{
- /* long to avoid size mismatch warnings from gcc */
- long fd;
+ int fd;
struct mconsole_entry *new;
static struct mc_request req; /* that's OK */
- fd = (long) dev_id;
+ fd = *((int *) dev_id);
while (mconsole_get_request(fd, &req)){
if(req.cmd->context == MCONSOLE_INTR)
(*req.cmd->handler)(&req);
@@ -798,10 +797,10 @@ void mconsole_stack(struct mc_request *req)
*/
static char *notify_socket = NULL;
+static int sock;
+
static int mconsole_init(void)
{
- /* long to avoid size mismatch warnings from gcc */
- long sock;
int err;
char file[256];
@@ -818,7 +817,7 @@ static int mconsole_init(void)
err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt,
IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
- "mconsole", (void *)sock);
+ "mconsole", &sock);
if (err){
printk("Failed to get IRQ for management console\n");
return(1);
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c
index 62e5ad6..f31e715 100644
--- a/arch/um/drivers/mconsole_user.c
+++ b/arch/um/drivers/mconsole_user.c
@@ -86,8 +86,9 @@ int mconsole_get_request(int fd, struct mc_request *req)
int len;
req->originlen = sizeof(req->origin);
- req->len = recvfrom(fd, &req->request, sizeof(req->request), 0,
- (struct sockaddr *) req->origin, &req->originlen);
+ req->len = recvfrom(fd, &req->request, sizeof(req->request),
+ MSG_DONTWAIT, (struct sockaddr *) req->origin,
+ &req->originlen);
if (req->len < 0)
return 0;
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
index 4707b3f..56f2c23 100644
--- a/arch/um/drivers/ubd_user.c
+++ b/arch/um/drivers/ubd_user.c
@@ -43,6 +43,12 @@ int start_io_thread(unsigned long sp, int *fd_out)
kernel_fd = fds[0];
*fd_out = fds[1];
+ err = os_set_fd_block(*fd_out, 0);
+ if (err) {
+ printk("start_io_thread - failed to set nonblocking I/O.\n");
+ goto out_close;
+ }
+
pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
NULL);
if(pid < 0){
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index 571c2b3..2b65b57 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -151,6 +151,13 @@ int xterm_open(int input, int output, int primary, void *d,
goto out;
}
+ err = os_set_fd_block(new, 0);
+ if (err) {
+ printk("xterm_open : failed to set xterm descriptor "
+ "non-blocking, err = %d\n", -err);
+ return(err);
+ }
+
CATCH_EINTR(err = tcgetattr(new, &data->tt));
if(err){
new = err;
next reply other threads:[~2007-06-10 23:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-10 22:01 Eduard-Gabriel Munteanu [this message]
2007-06-11 17:31 ` [PATCH 1/1] UML: fix missing non-blocking I/O, now DEBUG_SHIRQ works Jeff Dike
2007-06-11 19:39 ` Eduard-Gabriel Munteanu
2007-06-11 21:16 ` Jeff Dike
2007-06-11 22:39 ` Eduard-Gabriel Munteanu
2007-06-12 0:48 ` Jeff Dike
2007-06-12 5:44 ` Eduard-Gabriel Munteanu
2007-06-12 13:26 ` Jeff Dike
-- strict thread matches above, loose matches on Subject: below --
2007-06-10 22:20 Eduard-Gabriel Munteanu
2007-06-11 10:26 ` Eduard-Gabriel Munteanu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1181512917.3157.8.camel@localhost \
--to=maxdamage@aladin.ro \
--cc=jdike@karaya.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.