Skip to content

ldisc patchset

Peter Hurley linux-ppp linux-serial lkml netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest44 patches 18 repliesIn review
  2. v432 patches 13 repliesSuperseded
  3. v323 patches 20 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/44tty: Add diagnostic for halted line disciplinedrivers/tty/n_tty.c drivers/tty/tty_ldisc.c include/linux/tty.h+15 -10 replies
2/44n_tty: Factor packet mode status change for reusedrivers/tty/n_tty.c+14 -100 replies
3/44n_tty: Don't flush buffer when closing ldiscdrivers/tty/n_tty.c+3 -10 replies
4/44tty: Refactor wait for ldisc refs out of tty_ldisc_hangup()drivers/tty/tty_ldisc.c+36 -180 replies
5/44tty: Remove unnecessary re-test of ldisc ref countdrivers/tty/tty_ldisc.c+19 -190 replies
6/44tty: Fix ldisc halt sequence on hangupdrivers/tty/tty_ldisc.c+19 -200 replies
7/44tty: Relocate tty_ldisc_halt() to avoid forward declarationdrivers/tty/tty_ldisc.c+23 -230 replies
8/44tty: Strengthen no-subsequent-use guarantee of tty_ldisc_halt()drivers/tty/tty_ldisc.c+24 -180 replies
9/44tty: Halt both ldiscs concurrentlydrivers/tty/tty_ldisc.c+25 -130 replies
10/44tty: Wait for SAK work before waiting for hangup workdrivers/tty/tty_ldisc.c+1 -10 replies
11/44n_tty: Correct unthrottle-with-buffer-flush commentsdrivers/tty/n_tty.c+5 -80 replies
12/44n_tty: Fully initialize ldisc before restarting buffer workdrivers/tty/n_tty.c+8 -90 replies
13/44tty: Don't reenable already enabled ldiscdrivers/tty/tty_io.c drivers/tty/tty_ldisc.c include/linux/tty.h+1 -40 replies
14/44tty: Complete ownership transfer of flip buffersdrivers/tty/tty_io.c drivers/tty/tty_ldisc.c drivers/tty/tty_port.c+14 -350 replies
15/44tty: Make core responsible for synchronizing its workdrivers/tty/tty_io.c drivers/tty/tty_ldisc.c+21 -200 replies
16/44tty: Fix 'deferred reopen' ldisc commentdrivers/tty/tty_ldisc.c+5 -40 replies
17/44tty: Bracket ldisc release with TTY_DEBUG_HANGUP messagesdrivers/tty/tty_io.c+4 -10 replies
18/44tty: Add ldisc hangup debug messagesdrivers/tty/tty_ldisc.c+19 -00 replies
19/44tty: Don't protect atomic operation with mutexdrivers/tty/tty_io.c+0 -20 replies
20/44tty: Separate release semantics of ldisc referencedrivers/tty/tty_ldisc.c+35 -340 replies
21/44tty: Document unsafe ldisc reference acquiredrivers/tty/tty_ldisc.c+5 -90 replies
22/44tty: Fold one-line assign function into callersdrivers/tty/tty_ldisc.c+6 -250 replies
23/44tty: Locate get/put ldisc functions togetherdrivers/tty/tty_ldisc.c+23 -230 replies
24/44tty: Remove redundant tty_wait_until_sent()drivers/tty/tty_ldisc.c+0 -90 replies
25/44tty: Fix recursive deadlock in tty_perform_flush()drivers/net/ppp/ppp_async.c drivers/net/ppp/ppp_synctty.c drivers/tty/tty_ioctl.c+21 -111 reply
26/44tty: Add read-recursive, writer-prioritized rw semaphoredrivers/tty/Makefile drivers/tty/tty_ldsem.c include/linux/tty_ldisc.h+555 -15 replies
27/44tty: Drop lock contention stat from ldsem trylocksdrivers/tty/tty_ldsem.c+0 -30 replies
28/44tty: Remove ldsem recursion supportdrivers/tty/tty_ldsem.c include/linux/tty_ldisc.h+8 -774 replies
29/44tty: Add lock/unlock ldisc pair functionsdrivers/tty/tty_ldisc.c+87 -00 replies
30/44tty: Replace ldisc locking with ldisc_semdrivers/tty/tty_buffer.c drivers/tty/tty_io.c drivers/tty/tty_ldisc.c +2 more+48 -2920 replies
31/44tty: Clarify ldisc variabledrivers/tty/tty_ldisc.c+7 -70 replies
32/44tty: Fix hangup race with TIOCSETD ioctldrivers/tty/tty_ldisc.c+2 -40 replies
33/44tty: Clarify multiple-references comment in TIOCSETD ioctldrivers/tty/tty_ldisc.c+6 -40 replies
34/44tty: Fix tty_ldisc_lock name collisiondrivers/tty/tty_ldisc.c+12 -120 replies
35/44tty: Drop "tty is NULL" flip buffer diagnosticdrivers/tty/tty_buffer.c+1 -10 replies
36/44tty: Inline ldsem down_failed() into down_{read,write}_failed()drivers/tty/tty_ldsem.c+57 -130 replies
37/44tty: Drop ldsem wait typedrivers/tty/tty_ldsem.c+2 -170 replies
38/44tty: Drop wake type optimizationdrivers/tty/tty_ldsem.c include/linux/tty_ldisc.h+21 -360 replies
39/44tty: Factor ldsem writer trylockdrivers/tty/tty_ldsem.c+15 -70 replies
40/44tty: Simplify lock taking for waiting writersdrivers/tty/tty_ldsem.c+16 -360 replies
41/44tty: Implement ldsem fast path write lock stealingdrivers/tty/tty_ldsem.c+11 -70 replies
42/44tty: Reduce and simplify ldsem atomic opsdrivers/tty/tty_ldsem.c+23 -360 replies
43/44tty: Early-out ldsem write lock stealingdrivers/tty/tty_ldsem.c+15 -80 replies
44/44tty: Early-out tardy ldsem readersdrivers/tty/tty_ldsem.c+21 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 00/44] ldisc patchset

Greg,
This patchset includes
'tty: Drop lock contention stat from ldsem trylocks'
so no need to apply that on this series. Also, I noticed you kept the 'tty is NULL' removal on a different branch so I left my patch in this series that removes it.

This series applies cleanly to tty-next.

v5 changes:

After completing an audit of the recursive use of ldisc references, I discovered the _blocking_ recursive acquisition of ldisc references was limited to line disciplines misusing the tty_perform_flush() function.
With that now resolved in,
'tty: Fix recursive deadlock in tty_perform_flush()'
the recursion design in ldsem has been removed.

The recursion removal is in its own patch,
'tty: Remove ldsem recursion support'
to ease review for those that have already reviewed the ldsem implementation.

In addition, this patchset implements lock stealing derived from the work of Michel Lespinasse <[email protected]> on writer lock stealing in rwsem.

Although the rwsem write lock stealing changes are motivated by performance criteria, these changes are motivated by reduced code line count and simplicity of design.

*** Edited below to remove recursion discussion ***

Back in early December I realized that a classic read/write semaphore with writer priority was the ideal mechanism for handling the line discipline referencing.

Line discipline references act as "readers"; closing or changing the line discipline is prevented while these references are outstanding. Conversely, line discipline references should not be granted while the line discipline is closing or changing; these are the "writers".

Unfortunately, the existing rwsem uses a FIFO priority for waiting threads and does not support timeouts.

So this implements just that: a writer-priority
read/write semaphore with timed waits.

Initially, it was my intention to have this in 2 patchsets but since the v2 and v3 patchsets were pushed back, this ends up being an all-in-one :)

Other changes in v4 from v3:

- From Jiri's review of v3:

'tty: Add diagnostic for halted line discipline' was split:
the function relocation is now in a separate patch, 'tty: Relocate tty_ldisc_halt() to avoid forward declaration'

'n_tty: Factor packet mode status change for reuse':
packet_mode_flush() was renamed n_tty_packet_mode_flush()

'tty: Refactor wait for ldisc refs out of tty_ldisc_hangup()':
the parentheses were removed in the return value conversion.

'tty: Strengthen no-subsequent-use guarantee of tty_ldisc_halt()':
although addressed in the follow-on patch, the timeout values are now identical so as to avoid confusion in reviewing.

'tty: Kick waiters _after_ the ldisc is locked' was dropped:
although my logic is solid, this change made the conversion to a r/w semaphore awkward-looking. I think it makes sense to fix this separately in n_tty anyway.

'tty: Remove unnecessary buffer work flush' was merged with
new patch 'tty: Complete ownership transfer of flip buffers'

Patches 19-31 implement the switch to ldsem.

Patch 32 removes the 'tty is NULL' diagnostic. The logic supporting this change is in the commit message but I'll repeat it here:

Now that the driver i/o path is separate from tty lifetimes (implemented in Jiri's last patch series, soon to be in 3.9-rc1), a driver may unknowingly submit i/o to a tty that no longer exists. There is little sense in WARNing about an expected outcome.

Patch 14/32 'tty: Complete ownership transfer of flip buffers' ensures that no bad will come of the superfluous work -- other than that work for no-good-reason was submitted in the first place -- by waiting for work that may have retrieved what will soon be a stale tty value and by cancelling outstanding work before the port is destroyed (the work is owned by the port and contained within its structure).

As before, this series passes the stress tests that Ilya wrote plus some new ones that I have written.

Peter Hurley (44):
tty: Add diagnostic for halted line discipline
n_tty: Factor packet mode status change for reuse
n_tty: Don't flush buffer when closing ldisc
tty: Refactor wait for ldisc refs out of tty_ldisc_hangup()
tty: Remove unnecessary re-test of ldisc ref count
tty: Fix ldisc halt sequence on hangup
tty: Relocate tty_ldisc_halt() to avoid forward declaration
tty: Strengthen no-subsequent-use guarantee of tty_ldisc_halt()
tty: Halt both ldiscs concurrently
tty: Wait for SAK work before waiting for hangup work
n_tty: Correct unthrottle-with-buffer-flush comments
n_tty: Fully initialize ldisc before restarting buffer work
tty: Don't reenable already enabled ldisc
tty: Complete ownership transfer of flip buffers
tty: Make core responsible for synchronizing its work
tty: Fix 'deferred reopen' ldisc comment
tty: Bracket ldisc release with TTY_DEBUG_HANGUP messages
tty: Add ldisc hangup debug messages
tty: Don't protect atomic operation with mutex
tty: Separate release semantics of ldisc reference
tty: Document unsafe ldisc reference acquire
tty: Fold one-line assign function into callers
tty: Locate get/put ldisc functions together
tty: Remove redundant tty_wait_until_sent()
tty: Fix recursive deadlock in tty_perform_flush()
tty: Add read-recursive, writer-prioritized rw semaphore
tty: Drop lock contention stat from ldsem trylocks
tty: Remove ldsem recursion support
tty: Add lock/unlock ldisc pair functions
tty: Replace ldisc locking with ldisc_sem
tty: Clarify ldisc variable
tty: Fix hangup race with TIOCSETD ioctl
tty: Clarify multiple-references comment in TIOCSETD ioctl
tty: Fix tty_ldisc_lock name collision
tty: Drop "tty is NULL" flip buffer diagnostic
tty: Inline ldsem down_failed() into down_{read,write}_failed()
tty: Drop ldsem wait type
tty: Drop wake type optimization
tty: Factor ldsem writer trylock
tty: Simplify lock taking for waiting writers
tty: Implement ldsem fast path write lock stealing
tty: Reduce and simplify ldsem atomic ops
tty: Early-out ldsem write lock stealing
tty: Early-out tardy ldsem readers

 drivers/net/ppp/ppp_async.c   |   2 +-
 drivers/net/ppp/ppp_synctty.c |   2 +-
 drivers/tty/Makefile          |   2 +-
 drivers/tty/n_tty.c           |  62 +++--
 drivers/tty/tty_buffer.c      |   4 +-
 drivers/tty/tty_io.c          |  33 ++-
 drivers/tty/tty_ioctl.c       |  28 ++-
 drivers/tty/tty_ldisc.c       | 551 +++++++++++++++---------------------------
 drivers/tty/tty_ldsem.c       | 450 ++++++++++++++++++++++++++++++++++
 drivers/tty/tty_port.c        |   1 +
 include/linux/tty.h           |   7 +-
 include/linux/tty_ldisc.h     |  49 +++-
 12 files changed, 779 insertions(+), 412 deletions(-)
 create mode 100644 drivers/tty/tty_ldsem.c
Signature · 1 line
1.8.1.2