[PATCH 3/3] drivers/tty/tty_buffer.c: use a separate kthread for low_latency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ports that are marked low-latency get their own kthread that is
high-priority.
---
 drivers/tty/tty_buffer.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 4564202..b3c1298 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -12,6 +12,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/sched/prio.h>
 #include <linux/wait.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
@@ -522,10 +523,14 @@ EXPORT_SYMBOL(tty_flip_buffer_push);
  */
 
 static DEFINE_KTHREAD_WORKER(tty_buffer_worker);
+static DEFINE_KTHREAD_WORKER(tty_buffer_worker_ll);
 
 void tty_buffer_queue_work(struct tty_port *port)
 {
-	queue_kthread_work(&tty_buffer_worker, &port->buf.work);
+	if (port->low_latency)
+		queue_kthread_work(&tty_buffer_worker_ll, &port->buf.work);
+	else
+		queue_kthread_work(&tty_buffer_worker, &port->buf.work);
 }
 
 void tty_buffer_flush_work(struct tty_port *port)
@@ -535,7 +540,14 @@ void tty_buffer_flush_work(struct tty_port *port)
 
 void tty_buffer_init_kthread()
 {
+	struct task_struct *task;
+	/* Use same default priority as threaded irq handlers */
+	struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO/2 };
+
 	kthread_run(kthread_worker_fn, &tty_buffer_worker, "tty");
+	task = kthread_run(kthread_worker_fn, &tty_buffer_worker_ll,
+			   "tty-low-latency");
+	sched_setscheduler(task, SCHED_FIFO, &param);
 }
 
 void tty_buffer_init(struct tty_port *port)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux