[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJwJo6ahUWWSMWfM+qk109YfzJAB0HBMKcrVFqK2wzdBv_OtGQ@mail.gmail.com>
Date: Tue, 2 Apr 2019 15:22:43 +0100
From: Dmitry Safonov <0x7f454c46@...il.com>
To: Ben Hutchings <ben@...adent.org.uk>
Cc: open list <linux-kernel@...r.kernel.org>,
stable <stable@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Denis Kirjanov <kda@...ux-powerpc.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>,
kernel test robot <rong.a.chen@...el.com>,
Dmitry Safonov <dima@...sta.com>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH 3.16 23/99] tty/ldsem: Wake up readers after timed out down_write()
Hi Ben,
JFI: I haven't checked your tree, but the same patches set contains fixes
that are more important to my mind (looking at 4.9 stable tree):
- "tty: Drop tty->count on tty_reopen() failure" commit fe3241679009
- "tty: Hold tty_ldisc_lock() during tty_reopen()" commit 83d817f41070
with follow-up fixup "tty: Don't hold ldisc lock in tty_reopen() if
ldisc present"
commit d3736d82e816
So, I don't know your policy about choosing backports, but I thought worth
to mention those patches as you might like to glance at them.
(maybe they are already in your tree)
Thanks,
Dmitry
On Tue, 2 Apr 2019 at 14:44, Ben Hutchings <ben@...adent.org.uk> wrote:
>
> 3.16.65-rc1 review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Dmitry Safonov <dima@...sta.com>
>
> commit 231f8fd0cca078bd4396dd7e380db813ac5736e2 upstream.
>
> ldsem_down_read() will sleep if there is pending writer in the queue.
> If the writer times out, readers in the queue should be woken up,
> otherwise they may miss a chance to acquire the semaphore until the last
> active reader will do ldsem_up_read().
>
> There was a couple of reports where there was one active reader and
> other readers soft locked up:
> Showing all locks held in the system:
> 2 locks held by khungtaskd/17:
> #0: (rcu_read_lock){......}, at: watchdog+0x124/0x6d1
> #1: (tasklist_lock){.+.+..}, at: debug_show_all_locks+0x72/0x2d3
> 2 locks held by askfirst/123:
> #0: (&tty->ldisc_sem){.+.+.+}, at: ldsem_down_read+0x46/0x58
> #1: (&ldata->atomic_read_lock){+.+...}, at: n_tty_read+0x115/0xbe4
>
> Prevent readers wait for active readers to release ldisc semaphore.
>
> Link: lkml.kernel.org/r/20171121132855.ajdv4k6swzhvktl6@...-t540p.sh.intel.com
> Link: lkml.kernel.org/r/20180907045041.GF1110@...o2-debian
> Cc: Jiri Slaby <jslaby@...e.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Reported-by: kernel test robot <rong.a.chen@...el.com>
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
> ---
> drivers/tty/tty_ldsem.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> --- a/drivers/tty/tty_ldsem.c
> +++ b/drivers/tty/tty_ldsem.c
> @@ -306,6 +306,16 @@ down_write_failed(struct ld_semaphore *s
> if (!locked)
> ldsem_atomic_update(-LDSEM_WAIT_BIAS, sem);
> list_del(&waiter.list);
> +
> + /*
> + * In case of timeout, wake up every reader who gave the right of way
> + * to writer. Prevent separation readers into two groups:
> + * one that helds semaphore and another that sleeps.
> + * (in case of no contention with a writer)
> + */
> + if (!locked && list_empty(&sem->write_wait))
> + __ldsem_wake_readers(sem);
> +
> raw_spin_unlock_irq(&sem->wait_lock);
>
> __set_task_state(tsk, TASK_RUNNING);
>
Powered by blists - more mailing lists