Re: [linux-next / tty] possible circular locking dependency detected

From: Jiri Slaby
Date: Mon May 22 2017 - 06:26:59 EST


On 05/22/2017, 12:24 PM, Greg Kroah-Hartman wrote:
> On Mon, May 22, 2017 at 04:39:43PM +0900, Sergey Senozhatsky wrote:
>> Hello,
>>
>> [ 1274.378287] ======================================================
>> [ 1274.378289] WARNING: possible circular locking dependency detected
>> [ 1274.378290] 4.12.0-rc1-next-20170522-dbg-00007-gc09b2ab28b74-dirty #1317 Not tainted
>> [ 1274.378291] ------------------------------------------------------
>> [ 1274.378293] kworker/u8:5/111 is trying to acquire lock:
>> [ 1274.378294] (&buf->lock){+.+...}, at: [<ffffffff812f2831>] tty_buffer_flush+0x34/0x88
>> [ 1274.378300]
>> but task is already holding lock:
>> [ 1274.378301] (&o_tty->termios_rwsem/1){++++..}, at: [<ffffffff812ee5c7>] isig+0x47/0xd2
>> [ 1274.378307]
>> which lock already depends on the new lock.
>>
>> [ 1274.378309]
>> the existing dependency chain (in reverse order) is:
>> [ 1274.378310]
>> -> #2 (&o_tty->termios_rwsem/1){++++..}:
>> [ 1274.378316] lock_acquire+0x183/0x1ae
>> [ 1274.378319] down_read+0x3e/0x62
>> [ 1274.378321] n_tty_write+0x6c/0x3d6
>> [ 1274.378322] tty_write+0x1cc/0x25f
>> [ 1274.378325] __vfs_write+0x26/0xec
>> [ 1274.378327] vfs_write+0xe1/0x16a
>> [ 1274.378329] SyS_write+0x51/0x8e
>> [ 1274.378330] entry_SYSCALL_64_fastpath+0x18/0xad
>> [ 1274.378331]
>> -> #1 (&tty->atomic_write_lock){+.+.+.}:
>> [ 1274.378335] lock_acquire+0x183/0x1ae
>> [ 1274.378337] __mutex_lock+0x95/0x7ba
>> [ 1274.378339] mutex_lock_nested+0x1b/0x1d
>> [ 1274.378340] tty_port_default_receive_buf+0x4e/0x81

...
> Does this also show up in 4.11?

According to traces, I very believe this is caused by
commit 925bb1ce47f429f69aad35876df7ecd8c53deb7e
Author: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
Date: Thu May 11 12:18:52 2017 +0200

tty: fix port buffer locking

thanks,
--
js
suse labs