mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Pekka Enberg <penberg@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Sasha Levin <levinsasha928@gmail.com>,
	mingo@elte.hu
Subject: Re: [patch 0/3] kvm tool: Serial emulation overhaul
Date: Sat, 10 Dec 2011 21:51:43 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.02.1112102144370.3020@ionos> (raw)
In-Reply-To: <alpine.LFD.2.02.1112101715500.10936@tux.localdomain>

On Sat, 10 Dec 2011, Pekka Enberg wrote:

> On Sat, 10 Dec 2011, Thomas Gleixner wrote:
> > We observed massive hangs of the serial console in kvm tool which
> > turned out to be caused by the bogus emulation of the interrupt line
> > behaviour.
> > 
> > This series cleans up and simplifies the serial code and in the last
> > step fixes the interrupt handling proper.
> 
> Applied, thanks Thomas!

There is a slight problem with them. I only tested them with the
rt-guest kernels, but non rt kernels are slightly unhappy. Sorry for
not thinking about that.

Fix below.

Thanks,

	tglx
------------------>
Subject: kvm tools: serial: Make it work with non rt guests as well
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sat, 10 Dec 2011 21:27:26 +0100

Sasha reported, that a non RT guest reports "too much work for irq 4"
with the previous serial overhaul.

The reason is, that the new code allows unlimited tx transfers, which
triggers the sanity check in the 8250.c interrupt handler.

Limit the consecutive TX chars to 16 and let the guest kernel escape
from the 8250 interrupt handler. Set the TEMT/THRE bits in the
periodic serial console update.

Reported-by: Sasha Levin  <levinsasha928@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 tools/kvm/hw/serial.c |   30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

Index: linux-kvm/tools/kvm/hw/serial.c
===================================================================
--- linux-kvm.orig/tools/kvm/hw/serial.c
+++ linux-kvm/tools/kvm/hw/serial.c
@@ -19,6 +19,7 @@ struct serial8250_device {
 	u16			iobase;
 	u8			irq;
 	u8			irq_state;
+	int			txcnt;
 
 	u8			rbr;		/* receive buffer */
 	u8			dll;
@@ -105,6 +106,16 @@ static void serial8250_update_irq(struct
 			kvm__irq_line(kvm, dev->irq, 1);
 	}
 	dev->irq_state = iir;
+
+	/*
+	 * If the kernel disabled the tx interrupt, we know that there
+	 * is nothing more to transmit, so we can reset our tx logic
+	 * here.
+	 */
+	if (!(dev->ier & UART_IER_THRI)) {
+		dev->lsr |= UART_LSR_TEMT | UART_LSR_THRE;
+		dev->txcnt = 0;
+	}
 }
 
 #define SYSRQ_PENDING_NONE		0
@@ -134,6 +145,15 @@ static void serial8250__receive(struct k
 {
 	int c;
 
+	/*
+	 * If the guest transmitted 16 chars in a row, we clear the
+	 * TEMT/THRE bits to let the kernel escape from the 8250
+	 * interrupt handler. We come here only once a ms, so that
+	 * should give the kernel the desired pause.
+	 */
+	dev->lsr |= UART_LSR_TEMT | UART_LSR_THRE;
+	dev->txcnt = 0;
+
 	if (dev->lsr & UART_LSR_DR)
 		return;
 
@@ -212,14 +232,8 @@ static bool serial8250_out(struct ioport
 				term_putc(CONSOLE_8250, addr, size, dev->id);
 			/* else FIXME: Inject data into rcv path for LOOP */
 
-			/*
-			 * Set transmitter and transmit hold register
-			 * empty.  We have no FIFO at the moment and
-			 * on the TX side it's only interesting, when
-			 * we could coalesce port io on the kernel
-			 * kernel.
-			 */
-			dev->lsr |= UART_LSR_TEMT | UART_LSR_THRE;
+			if (++dev->txcnt == 16)
+				dev->lsr &= ~(UART_LSR_TEMT | UART_LSR_THRE);
 			break;
 		} else {
 			dev->dll = ioport__read8(data);



  reply	other threads:[~2011-12-10 20:51 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-10 13:27 Thomas Gleixner
2011-12-10 13:27 ` [patch 1/3] kvm tool: serial: Cleanup coding style Thomas Gleixner
2011-12-10 13:27 ` [patch 3/3] kvm tool: serial: Fix interrupt handling Thomas Gleixner
2011-12-10 13:27 ` [patch 2/3] kvm tool: serial: Simplify switch cases Thomas Gleixner
2011-12-10 15:17 ` [patch 0/3] kvm tool: Serial emulation overhaul Pekka Enberg
2011-12-10 20:51   ` Thomas Gleixner [this message]
2011-12-11  8:15     ` Pekka Enberg
2011-12-11 10:30       ` Ingo Molnar
2011-12-11 10:46         ` Ingo Molnar
2011-12-11 14:04         ` Thomas Gleixner
2011-12-11 15:53           ` Ingo Molnar
2011-12-12  5:30             ` Sasha Levin
2011-12-12 11:12               ` Ingo Molnar
2011-12-12 11:20                 ` Alan Cox
2011-12-12 17:20                   ` Ingo Molnar
2011-12-12 18:16                   ` Avi Kivity
2011-12-12 18:16                   ` Avi Kivity
2011-12-12 21:36                     ` Alan Cox
2011-12-13 10:32                       ` Avi Kivity
2011-12-12 11:23                 ` Cyrill Gorcunov
2011-12-12 17:40                 ` Sasha Levin
2011-12-12 17:45                   ` Ingo Molnar
2011-12-12  9:42             ` Thomas Gleixner
2011-12-12 11:19             ` Pekka Enberg
2011-12-12 17:20               ` Ingo Molnar
2011-12-12 18:40                 ` Pekka Enberg
2011-12-12 19:14                   ` Pekka Enberg
2011-12-12 19:21                   ` Ingo Molnar
2011-12-13  0:59                     ` Thomas Gleixner
2011-12-13  7:03                       ` Pekka Enberg
2011-12-13 11:05                         ` Alan Cox
2011-12-13 10:58                       ` Avi Kivity
2011-12-13 13:52                         ` Thomas Gleixner
2011-12-13 14:23                           ` Avi Kivity
2011-12-13 14:30                             ` Sasha Levin
2011-12-13 14:51                             ` Thomas Gleixner
2011-12-13 14:58                               ` Avi Kivity
2011-12-12 21:03                   ` James Courtier-Dutton
2011-12-12 18:19               ` Avi Kivity
2011-12-12 18:31                 ` Pekka Enberg
2011-12-13 10:33                   ` Avi Kivity
2011-12-12 10:27           ` Alan Cox
2011-12-12 10:59             ` Sasha Levin
2011-12-12 11:02               ` Alan Cox
2011-12-12 18:21                 ` Avi Kivity
2011-12-12 17:21               ` Ingo Molnar

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=alpine.LFD.2.02.1112102144370.3020@ionos \
    --to=tglx@linutronix.de \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@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 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®