tty: move global ldisc idle waitqueue to the individual ldisc
The global wait_queue that is used for line discipline idle handling is moved to a separate wait_queue for each line instance. This prevents unnecessary blocking on one line, because of idle handling on another line. Signed-off-by: Ivo Sieben <meltedpianoman@gmail.com> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
3e62c413fb
Коммит
1541f845d1
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(tty_ldisc_lock);
|
static DEFINE_SPINLOCK(tty_ldisc_lock);
|
||||||
static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
|
static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
|
||||||
static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_idle);
|
|
||||||
/* Line disc dispatch table */
|
/* Line disc dispatch table */
|
||||||
static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
|
static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ static void put_ldisc(struct tty_ldisc *ld)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
wake_up(&tty_ldisc_idle);
|
wake_up(&ld->wq_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,6 +199,8 @@ static struct tty_ldisc *tty_ldisc_get(int disc)
|
||||||
|
|
||||||
ld->ops = ldops;
|
ld->ops = ldops;
|
||||||
atomic_set(&ld->users, 1);
|
atomic_set(&ld->users, 1);
|
||||||
|
init_waitqueue_head(&ld->wq_idle);
|
||||||
|
|
||||||
return ld;
|
return ld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +539,7 @@ static void tty_ldisc_flush_works(struct tty_struct *tty)
|
||||||
static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout)
|
static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout)
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
ret = wait_event_timeout(tty_ldisc_idle,
|
ret = wait_event_timeout(tty->ldisc->wq_idle,
|
||||||
atomic_read(&tty->ldisc->users) == 1, timeout);
|
atomic_read(&tty->ldisc->users) == 1, timeout);
|
||||||
return ret > 0 ? 0 : -EBUSY;
|
return ret > 0 ? 0 : -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
#include <linux/pps_kernel.h>
|
#include <linux/pps_kernel.h>
|
||||||
|
#include <linux/wait.h>
|
||||||
|
|
||||||
struct tty_ldisc_ops {
|
struct tty_ldisc_ops {
|
||||||
int magic;
|
int magic;
|
||||||
|
@ -154,6 +155,7 @@ struct tty_ldisc_ops {
|
||||||
struct tty_ldisc {
|
struct tty_ldisc {
|
||||||
struct tty_ldisc_ops *ops;
|
struct tty_ldisc_ops *ops;
|
||||||
atomic_t users;
|
atomic_t users;
|
||||||
|
wait_queue_head_t wq_idle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TTY_LDISC_MAGIC 0x5403
|
#define TTY_LDISC_MAGIC 0x5403
|
||||||
|
|
Загрузка…
Ссылка в новой задаче