linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Peterson <joe@skyrush.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: alan@lxorguk.ukuu.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] TTY: Fix loss of echoed characters (2nd follow-on PATCH attached)
Date: Tue, 09 Sep 2008 07:00:36 -0600	[thread overview]
Message-ID: <48C67374.1000108@skyrush.com> (raw)
In-Reply-To: <20080908173250.2452c5b8.akpm@linux-foundation.org>

Andrew Morton wrote:
> On Mon, 08 Sep 2008 10:11:46 -0600
> Joe Peterson <joe@skyrush.com> wrote:
> 
>> +	spin_lock_irqsave(&tty->echo_lock, flags);
>>  	lock_kernel();
> 
> Taking a spinlock outside lock_kernel() isn't good, and is quite unusual.
> - It might be ab/ba deadlockable (I didn't check) (I trust you always
>   test with lockdep enabled?)

Indeed - and, as Alan said, lock_kernel() can sleep (a nuance I had not
realized until looking more into the kernel locking mechanisms just
now).  Although I have seen no issues during testing (and I do have
lockdep in the kernel), you are 100% right.

I had wanted to keep from disturbing the locking situation in n_tty, but
maybe it is time to get rid of the BKL there.

My echo buffer patches actually isolate the tty column state stuff to
the output processing functions now anyway, so the BLK may not really be
necessary at this point.  This inspires me to look into this.

> swapping the above two lines would presumably be an easy fix, but one
> wonders whether we still need lock_kernel() in there once you've added
> this lock.

I don't think this is a good idea either, since I don't want to spinlock
during the output processing, which calls the driver output func.  I
think a mutex is more appropriate anyway (and there are some already
defined and in use for tty write locking, etc.) - let me know if you
think otherwise.  I will play around with this and re-post a patch for
review soon.

						-Thanks, Joe

  parent reply	other threads:[~2008-09-09 13:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200807252257.m6PMvieO003213@imap1.linux-foundation.org>
2008-08-20 15:36 ` [PATCH] TTY: Fix loss of echoed characters Joe Peterson
2008-08-26 12:41   ` Joe Peterson
2008-09-08 16:11     ` [PATCH] TTY: Fix loss of echoed characters (2nd follow-on PATCH attached) Joe Peterson
2008-09-09  0:32       ` Andrew Morton
2008-09-09 10:55         ` Alan Cox
2008-09-09 17:43           ` Andrew Morton
2008-09-09 20:42             ` Joe Peterson
2008-09-10 23:39               ` Andrew Morton
2008-09-11 12:53                 ` Joe Peterson
2008-09-09 13:00         ` Joe Peterson [this message]
2008-09-09 13:12           ` Alan Cox
2008-09-09 13:15             ` Joe Peterson
2008-09-09 13:19               ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48C67374.1000108@skyrush.com \
    --to=joe@skyrush.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).