From d2b77ffe10854d1aa3d68c1c346a7d003faa50ca Mon Sep 17 00:00:00 2001 From: TAKIZAWA Fumiya Date: Sat, 9 May 2020 23:59:08 +0900 Subject: [PATCH 2/6] Revert "tty: move tty_port workqueue to be a kthread" This reverts commit 6504bb3e934293960287fcf31aba8fd58407d22a. This is a workaround for a crash when CONFIG_VT=y --- drivers/tty/tty_buffer.c | 27 +++++++-------------------- include/linux/tty.h | 6 ++---- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 8917b6f87b04..4706df20191b 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -71,7 +71,7 @@ void tty_buffer_unlock_exclusive(struct tty_port *port) atomic_dec(&buf->priority); mutex_unlock(&buf->lock); if (restart) - queue_kthread_work(&port->worker, &buf->work); + queue_work(system_unbound_wq, &buf->work); } EXPORT_SYMBOL_GPL(tty_buffer_unlock_exclusive); @@ -132,7 +132,6 @@ void tty_buffer_free_all(struct tty_port *port) buf->tail = &buf->sentinel; atomic_set(&buf->mem_used, 0); - kthread_stop(port->worker_thread); } /** @@ -405,7 +404,7 @@ void tty_schedule_flip(struct tty_port *port) * flush_to_ldisc() sees buffer data. */ smp_store_release(&buf->tail->commit, buf->tail->used); - queue_kthread_work(&port->worker, &buf->work); + queue_work(system_unbound_wq, &buf->work); } EXPORT_SYMBOL(tty_schedule_flip); @@ -473,7 +472,7 @@ receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) * 'consumer' */ -static void flush_to_ldisc(struct kthread_work *work) +static void flush_to_ldisc(struct work_struct *work) { struct tty_port *port = container_of(work, struct tty_port, buf.work); struct tty_bufhead *buf = &port->buf; @@ -563,20 +562,8 @@ void tty_buffer_init(struct tty_port *port) init_llist_head(&buf->free); atomic_set(&buf->mem_used, 0); atomic_set(&buf->priority, 0); + INIT_WORK(&buf->work, flush_to_ldisc); buf->mem_limit = TTYB_DEFAULT_MEM_LIMIT; - init_kthread_work(&buf->work, flush_to_ldisc); - init_kthread_worker(&port->worker); - port->worker_thread = kthread_run(kthread_worker_fn, &port->worker, - "tty_worker_thread"); - if (IS_ERR(port->worker_thread)) { - /* - * Not good, we can't unwind, this tty is going to be really - * sad... - */ - pr_err("Unable to start tty_worker_thread\n"); - } - - } /** @@ -604,15 +591,15 @@ void tty_buffer_set_lock_subclass(struct tty_port *port) bool tty_buffer_restart_work(struct tty_port *port) { - return queue_kthread_work(&port->worker, &port->buf.work); + return queue_work(system_unbound_wq, &port->buf.work); } bool tty_buffer_cancel_work(struct tty_port *port) { - return kthread_cancel_work_sync(&port->buf.work); + return cancel_work_sync(&port->buf.work); } void tty_buffer_flush_work(struct tty_port *port) { - flush_kthread_work(&port->buf.work); + flush_work(&port->buf.work); } diff --git a/include/linux/tty.h b/include/linux/tty.h index 1c1bb90f6819..99165b4e6a7b 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -12,7 +12,7 @@ #include #include #include -#include + /* * Lock subclasses for tty locks @@ -82,7 +82,7 @@ static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs) struct tty_bufhead { struct tty_buffer *head; /* Queue head */ - struct kthread_work work; + struct work_struct work; struct mutex lock; atomic_t priority; struct tty_buffer sentinel; @@ -240,8 +240,6 @@ struct tty_port { based drain is needed else set to size of fifo */ struct kref kref; /* Ref counter */ - struct kthread_worker worker; /* worker thread */ - struct task_struct *worker_thread; /* worker thread */ }; /* -- 2.26.2