1. 08 1月, 2014 1 次提交
  2. 24 7月, 2013 8 次提交
  3. 19 3月, 2013 18 次提交
  4. 16 1月, 2013 2 次提交
    • S
      tty: don't deadlock while flushing workqueue · 852e4a81
      Sebastian Andrzej Siewior 提交于
      Since commit 89c8d91e ("tty: localise the lock") I see a dead lock
      in one of my dummy_hcd + g_nokia test cases. The first run was usually
      okay, the second often resulted in a splat by lockdep and the third was
      usually a dead lock.
      Lockdep complained about tty->hangup_work and tty->legacy_mutex taken
      both ways:
      | ======================================================
      | [ INFO: possible circular locking dependency detected ]
      | 3.7.0-rc6+ #204 Not tainted
      | -------------------------------------------------------
      | kworker/2:1/35 is trying to acquire lock:
      |  (&tty->legacy_mutex){+.+.+.}, at: [<c14051e6>] tty_lock_nested+0x36/0x80
      |
      | but task is already holding lock:
      |  ((&tty->hangup_work)){+.+...}, at: [<c104f6e4>] process_one_work+0x124/0x5e0
      |
      | which lock already depends on the new lock.
      |
      | the existing dependency chain (in reverse order) is:
      |
      | -> #2 ((&tty->hangup_work)){+.+...}:
      |        [<c107fe74>] lock_acquire+0x84/0x190
      |        [<c104d82d>] flush_work+0x3d/0x240
      |        [<c12e6986>] tty_ldisc_flush_works+0x16/0x30
      |        [<c12e7861>] tty_ldisc_release+0x21/0x70
      |        [<c12e0dfc>] tty_release+0x35c/0x470
      |        [<c1105e28>] __fput+0xd8/0x270
      |        [<c1105fcd>] ____fput+0xd/0x10
      |        [<c1051dd9>] task_work_run+0xb9/0xf0
      |        [<c1002a51>] do_notify_resume+0x51/0x80
      |        [<c140550a>] work_notifysig+0x35/0x3b
      |
      | -> #1 (&tty->legacy_mutex/1){+.+...}:
      |        [<c107fe74>] lock_acquire+0x84/0x190
      |        [<c140276c>] mutex_lock_nested+0x6c/0x2f0
      |        [<c14051e6>] tty_lock_nested+0x36/0x80
      |        [<c1405279>] tty_lock_pair+0x29/0x70
      |        [<c12e0bb8>] tty_release+0x118/0x470
      |        [<c1105e28>] __fput+0xd8/0x270
      |        [<c1105fcd>] ____fput+0xd/0x10
      |        [<c1051dd9>] task_work_run+0xb9/0xf0
      |        [<c1002a51>] do_notify_resume+0x51/0x80
      |        [<c140550a>] work_notifysig+0x35/0x3b
      |
      | -> #0 (&tty->legacy_mutex){+.+.+.}:
      |        [<c107f3c9>] __lock_acquire+0x1189/0x16a0
      |        [<c107fe74>] lock_acquire+0x84/0x190
      |        [<c140276c>] mutex_lock_nested+0x6c/0x2f0
      |        [<c14051e6>] tty_lock_nested+0x36/0x80
      |        [<c140523f>] tty_lock+0xf/0x20
      |        [<c12df8e4>] __tty_hangup+0x54/0x410
      |        [<c12dfcb2>] do_tty_hangup+0x12/0x20
      |        [<c104f763>] process_one_work+0x1a3/0x5e0
      |        [<c104fec9>] worker_thread+0x119/0x3a0
      |        [<c1055084>] kthread+0x94/0xa0
      |        [<c140ca37>] ret_from_kernel_thread+0x1b/0x28
      |
      |other info that might help us debug this:
      |
      |Chain exists of:
      |  &tty->legacy_mutex --> &tty->legacy_mutex/1 --> (&tty->hangup_work)
      |
      | Possible unsafe locking scenario:
      |
      |       CPU0                    CPU1
      |       ----                    ----
      |  lock((&tty->hangup_work));
      |                               lock(&tty->legacy_mutex/1);
      |                               lock((&tty->hangup_work));
      |  lock(&tty->legacy_mutex);
      |
      | *** DEADLOCK ***
      
      Before the path mentioned tty_ldisc_release() look like this:
      
      |	tty_ldisc_halt(tty);
      |	tty_ldisc_flush_works(tty);
      |	tty_lock();
      
      As it can be seen, it first flushes the workqueue and then grabs the
      tty_lock. Now we grab the lock first:
      
      |	tty_lock_pair(tty, o_tty);
      |	tty_ldisc_halt(tty);
      |	tty_ldisc_flush_works(tty);
      
      so lockdep's complaint seems valid.
      
      The earlier version of this patch took the ldisc_mutex since the other
      user of tty_ldisc_flush_works() (tty_set_ldisc()) did this.
      Peter Hurley then said that it is should not be requried. Since it
      wasn't done earlier, I dropped this part.
      The code under tty_ldisc_kill() was executed earlier with the tty lock
      taken so it is taken again.
      
      I was able to reproduce the deadlock on v3.8-rc1, this patch fixes the
      problem in my testcase. I didn't notice any problems so far.
      
      Cc: Alan Cox <alan@linux.intel.com>
      Cc: Peter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      852e4a81
    • I
      tty: Only wakeup the line discipline idle queue when queue is active · bd5d7ce9
      Ivo Sieben 提交于
      Before waking up the tty line discipline idle queue first check if the queue is
      active (non empty). This prevents unnecessary entering the critical section in
      the wake_up() function and therefore avoid needless scheduling overhead on a
      PREEMPT_RT system caused by two processes being in the same critical section.
      Signed-off-by: NIvo Sieben <meltedpianoman@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd5d7ce9
  5. 25 10月, 2012 1 次提交
  6. 23 10月, 2012 2 次提交
    • J
      TTY: move tty buffers to tty_port · ecbbfd44
      Jiri Slaby 提交于
      So this is it. The big step why we did all the work over the past
      kernel releases. Now everything is prepared, so nothing protects us
      from doing that big step.
      
                 |  |            \  \ nnnn/^l      |  |
                 |  |             \  /     /       |  |
                 |  '-,.__   =>    \/   ,-`    =>  |  '-,.__
                 | O __.´´)        (  .`           | O __.´´)
                  ~~~   ~~          ``              ~~~   ~~
      The buffers are now in the tty_port structure and we can start
      teaching the buffer helpers (insert char/string, flip etc.) to use
      tty_port instead of tty_struct all around.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecbbfd44
    • J
      TTY: ldisc, wait for idle ldisc in release · 31e12128
      Jiri Slaby 提交于
      We reintroduced tty_ldisc_wait_idle in 100eeae2 (TTY: restore
      tty_ldisc_wait_idle) and used in set_ldisc. Then we added it also to
      the hangup path in 92f6fa09 (TTY: ldisc, do not close until there
      are readers). And we noted that there is one more path:
      ~   Before 65b77046 tty_ldisc_wait_idle was called also from
      ~   tty_ldisc_release. It is called from tty_release, so I don't think
      ~   we need to restore that one.
      
      Well, I was wrong. There might still be holders of an ldisc
      reference. Not from userspace, but drivers. If they take a reference
      and a user closes the device immediately after that, we have a
      problem. ldisc is halted and closed by TTY, but the driver still may
      call some ldisc's operation and cause a crash.
      
      So restore the tty_ldisc_wait_idle call also to the third location
      where it was before 65b77046 (tty-ldisc: turn ldisc user count
      into a proper refcount). Now we should be safe with respect to the
      ldisc reference counting as all* tty_ldisc_close paths are safely
      called with reference count of one.
      
      * Not the one in tty_ldisc_setup's fail path. But that is called
        before the first open finishes. So userspace does not see it yet.
        Even thought the driver is given the TTY already via ->install, it
        should not take a reference to the ldisc yet. If some driver is to
        do this, we should put one tty_ldisc_wait_idle also in the setup.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      31e12128
  7. 21 8月, 2012 1 次提交
    • T
      workqueue: deprecate flush[_delayed]_work_sync() · 43829731
      Tejun Heo 提交于
      flush[_delayed]_work_sync() are now spurious.  Mark them deprecated
      and convert all users to flush[_delayed]_work().
      
      If you're cc'd and wondering what's going on: Now all workqueues are
      non-reentrant and the regular flushes guarantee that the work item is
      not pending or running on any CPU on return, so there's no reason to
      use the sync flushes at all and they're going away.
      
      This patch doesn't make any functional difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Mattia Dongili <malattia@linux.it>
      Cc: Kent Yoder <key@linux.vnet.ibm.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: Bryan Wu <bryan.wu@canonical.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Alasdair Kergon <agk@redhat.com>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: linux-wireless@vger.kernel.org
      Cc: Anton Vorontsov <cbou@mail.ru>
      Cc: Sangbeom Kim <sbkim73@samsung.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Steven Whitehouse <swhiteho@redhat.com>
      Cc: Petr Vandrovec <petr@vandrovec.name>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Avi Kivity <avi@redhat.com> 
      43829731
  8. 11 8月, 2012 1 次提交
    • A
      tty: localise the lock · 89c8d91e
      Alan Cox 提交于
      The termios and other changes mean the other protections needed on the driver
      tty arrays should be adequate. Turn it all back on.
      
      This contains pieces folded in from the fixes made to the original patches
      
      | From: Geert Uytterhoeven <geert@linux-m68k.org>	(fix m68k)
      | From: Paul Gortmaker <paul.gortmaker@windriver.com>	(fix cris)
      | From: Jiri Kosina <jkosina@suze.cz>			(lockdep)
      | From: Eric Dumazet <eric.dumazet@gmail.com>		(lockdep)
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89c8d91e
  9. 28 7月, 2012 1 次提交
    • A
      tty: Fix race in tty release · d155255a
      Alan Cox 提交于
      Ian Abbott found that the tty layer would explode with the right set of
      parallel open and close operations. This is because we race in the
      handling of tty->drivers->termios[].
      
      Correct this by
      	Making tty_ldisc_release behave like nromal code (takes the lock,
      			does stuff, drops the lock)
      	Drop the tty lock earlier in tty_ldisc_release
      	Taking the tty mutex around the driver->termios update in all cases
      	Adding a WARN_ON to catch future screwups.
      
      I also forgot to clean up the pty resources properly. With a pty pair we
      need to pull both halves out of the tables.
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Tested-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d155255a
  10. 27 7月, 2012 1 次提交
  11. 17 7月, 2012 2 次提交
  12. 13 7月, 2012 1 次提交
  13. 07 7月, 2012 1 次提交
    • A
      tty: localise the lock · f5e3bcc5
      Alan Cox 提交于
      The termios and other changes mean the other protections needed on the driver
      tty arrays should be adequate. Turn it all back on.
      
      This contains pieces folded in from the fixes made to the original patches
      
      | From: Geert Uytterhoeven <geert@linux-m68k.org>	(fix m68k)
      | From: Paul Gortmaker <paul.gortmaker@windriver.com>	(fix cris)
      | From: Jiri Kosina <jkosina@suze.cz>			(lockdep)
      | From: Eric Dumazet <eric.dumazet@gmail.com>		(lockdep)
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5e3bcc5