• Peter Hurley's avatar
    n_tty: Eliminate receive_room() from consumer/exclusive paths · 2c5dc464
    Peter Hurley authored
    The input worker never reschedules itself; it only processes input until
    either there is no more input or the read buffer is full. So the reader
    is responsible for restarting the input worker only if the read buffer
    was previously full (no_room == 1) _and_ space is now available to process
    more input because the reader has consumed data from the read buffer.
    
    However, computing the actual space available is not required to determine
    if the reader has consumed data from the read buffer. This condition is
    evaluated in 5 situations, each of which the space avail is already known:
    1. n_tty_flush_buffer() - the read buffer is empty; kick the worker
    2. n_tty_set_termios() - no data has been consumed; do not kick the worker
           (although it may have kicked the reader so data _will be_ consumed)
    3. n_tty_check_unthrottle - avail space > 3968; kick the worker
    4. n_tty_read, before leaving - only kick the worker if the reader has
           moved the tail. This prevents unnecessarily kicking the worker
           when timeout-style reading is used.
    5. n_tty_read, before sleeping - although it is possible for the read
           buffer to be full and input_available_p() to be false, this can
           only happen when the input worker is racing the reader, in which
           case the reader will have been woken and won't sleep.
    
    Rename n_tty_set_room() to n_tty_kick_worker() to reflect what the
    function actually does.
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    2c5dc464
n_tty.c 61.4 KB