Skip to contentSkip to conversation

serial: 8250: convert to threaded IRQ

PATCH Superseded Denys Zagorui 2 participants 2 messages Nov 15, 2017 – Nov 28, 2017 TTY layer and serial drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 serial: 8250: convert to threaded IRQ

During using virtualization it is common to see many "too much work for irq*" messages.

There are fixes proposed erlier:
- e7328ae1848966181a7ac47e8ae6cddbd2cf55f3 (serial:
8250, increase PASS_LIMIT)
- f4f653e9875e573860e783fecbebde284a8626f5 (serial:
8250, disable "too much work" messages

First one doesn't help now, last one was reverted (12de375ec493ab1767d4a07dde823e63ae5edc21) in fact it doesn't fix anything. So procesing interrupts in kthread give us an opportunity to perform rescheduling periodically.

---
 drivers/tty/serial/8250/8250_core.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/tty/serial/8250/8250_core.c +21 -7
index d29b512a7d9f..05a59f31c29f 100644
@@ -58,7 +58,7 @@ static struct uart_driver serial8250_reg;
 
 static unsigned int skip_txen_test; /* force skip of txen test at init time */
 
-#define PASS_LIMIT	512
+#define PASS_LIMIT	32
 
 #include <asm/serial.h>
 /*
@@ -135,10 +135,13 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
 		l = l->next;
 
 		if (l == i->head && pass_counter++ > PASS_LIMIT) {
-			/* If we hit this, we're dead. */
-			printk_ratelimited(KERN_ERR
-				"serial8250: too much work for irq%d\n", irq);
-			break;
+			spin_unlock(&i->lock);
+			cond_resched();
+			spin_lock(&i->lock);
+			end = NULL;
+			l = i->head;
+			pass_counter = 0;
+			continue;
 		}
 	} while (l != end);
 
@@ -146,9 +149,20 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
 
 	pr_debug("%s(%d): end\n", __func__, irq);
 
+	enable_irq(i->irq);
+
 	return IRQ_RETVAL(handled);
 }
 
+static irqreturn_t serial8250_hard_irq(int irq, void *dev_id)
+{
+	struct irq_info *i = dev_id;
+
+	disable_irq_nosync(i->irq);
+
+	return IRQ_WAKE_THREAD;
+}
+
 /*
  * To support ISA shared interrupts, we need to have one interrupt
  * handler that ensures that the IRQ line has been deasserted
@@ -217,8 +231,8 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 		i->head = &up->list;
 		spin_unlock_irq(&i->lock);
 		irq_flags |= up->port.irqflags;
-		ret = request_irq(up->port.irq, serial8250_interrupt,
-				  irq_flags, up->port.name, i);
+		ret = request_threaded_irq(up->port.irq, serial8250_hard_irq,
+						serial8250_interrupt, irq_flags, up->port.name, i);
 		if (ret < 0)
 			serial_do_unlink(i, up);
 	}
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 15 lines · Denys Zagorui

During using virtualization it is common to see many "too much work for irq*" messages.

There are fixes proposed erlier:

(quoted diff) +0 -2
-  e7328ae1848966181a7ac47e8ae6cddbd2cf55f3 (serial:
   8250, increase PASS_LIMIT)
-  f4f653e9875e573860e783fecbebde284a8626f5 (serial:
   8250, disable "too much work" messages

First one doesn't help now, last one was reverted (12de375ec493ab1767d4a07dde823e63ae5edc21) in fact it doesn't fix anything. So procesing interrupts in kthread give us an opportunity to perform rescheduling periodically.

Quoted 5 lines
---
 drivers/tty/serial/8250/8250_core.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

Always say what changed from v1 below the --- line, otherwise we have no idea.

v3?