mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Matteo Croce <mcroce@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	linux-kernel@vger.kernel.org
Subject: Re: VirtIO console hangs
Date: Fri, 31 Aug 2018 13:49:43 +1000	[thread overview]
Message-ID: <20180831134943.7f516fed@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <CAGnkfhxhV_4JNhCm2s=XP15sp3bKax9O1R+nFwA+oRJXQ53xsg@mail.gmail.com>

On Tue, 28 Aug 2018 15:00:14 +0000
Matteo Croce <mcroce@redhat.com> wrote:

> On Tue, Aug 28, 2018 at 2:35 PM Nicholas Piggin <npiggin@gmail.com> wrote:
> >
> > On Tue, 28 Aug 2018 12:54:08 +0000
> > Matteo Croce <mcroce@redhat.com> wrote:
> >  
> > > With kernel 4.19.0-rc1 virtio_console hangs very often.
> > > I can always trigger the bug by pasting some characters in the
> > > terminal window, the console will stop receiving keypresses, but I can
> > > still see output from the console.
> > > Stangely, logging in the VM via SSH and sending lot of data to hvc0,
> > > like 'dmesg >/dev/hvc0' will fix the issue until the next paste.
> > >
> > > I did a git bisect and I've found that this is the offending commit,
> > > reverting it fixes it.
> > >
> > > Cheers,
> > >
> > > commit ec97eaad1383ab2500fcf9a07ade6044fbcc67f5
> > > Author: Nicholas Piggin <npiggin@gmail.com>
> > > Date:   Tue May 1 00:55:54 2018 +1000
> > >
> > >     tty: hvc: hvc_poll() break hv read loop  
> >
> > Thanks for the report. I can't immediately see what the problem
> > is. Can you try get a stack trace of where it is stuck?
> >  
> 
> I tried but didn't get one.
> 
> > Perhaps try this patch if you have time (it's a bit of a shot
> > in the dark).
> >  
> 
> Yes it seems to fix. Thanks!

Okay sorry for the delay, I can reproduce it here and found a better
fix, if I could trouble you to test again.

[PATCH] tty: hvc: hvc_poll() fix read loop hang

Patch ec97eaad1383 ("tty: hvc: hvc_poll() break hv read loop") causes
the virtio console to hang if you paste a bunch of characters to it.

The reason is that get_chars must return 0 before we can be sure the
driver will kick or poll input again, but this patch only scheduled a
poll if get_chars had returned a full count. Change this to poll on
> 0 count.

Fixes: ec97eaad1383 ("tty: hvc: hvc_poll() break hv read loop")
Reported-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 drivers/tty/hvc/hvc_console.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c
b/drivers/tty/hvc/hvc_console.c index 5414c4a87bea..219369aebb1f 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -717,10 +717,13 @@ static int __hvc_poll(struct hvc_struct *hp, bool
may_sleep) #endif /* CONFIG_MAGIC_SYSRQ */
 		tty_insert_flip_char(&hp->port, buf[i], 0);
 	}
-	if (n == count)
-		poll_mask |= HVC_POLL_READ;
 	read_total = n;
 
+	/* Activity is occurring, so reset the polling backoff value to
+	   a minimum for performance. */
+	timeout = MIN_TIMEOUT;
+	poll_mask |= HVC_POLL_READ;
+
  out:
 	/* Wakeup write queue if necessary */
 	if (hp->do_wakeup) {
@@ -730,13 +733,8 @@ static int __hvc_poll(struct hvc_struct *hp, bool
may_sleep) bail:
 	spin_unlock_irqrestore(&hp->lock, flags);
 
-	if (read_total) {
-		/* Activity is occurring, so reset the polling backoff
value to
-		   a minimum for performance. */
-		timeout = MIN_TIMEOUT;
-
+	if (read_total)
 		tty_flip_buffer_push(&hp->port);
-	}
 	tty_kref_put(tty);
 
 	return poll_mask;
-- 
2.18.0


  parent reply	other threads:[~2018-08-31  3:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 12:54 Matteo Croce
2018-08-28 14:35 ` Nicholas Piggin
2018-08-28 15:00   ` Matteo Croce
2018-08-28 15:33     ` Nicholas Piggin
2018-08-31  3:49     ` Nicholas Piggin [this message]
2018-08-31 15:17       ` Matteo Croce
2018-08-31 22:51         ` Nicholas Piggin
2018-08-31 22:57         ` Nicholas Piggin
2018-09-05  3:53         ` Nicholas Piggin
2018-09-05  9:16           ` Matteo Croce

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=20180831134943.7f516fed@roar.ozlabs.ibm.com \
    --to=npiggin@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcroce@redhat.com \
    --cc=mpe@ellerman.id.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®