Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934084AbZJMWo2 (ORCPT ); Tue, 13 Oct 2009 18:44:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761603AbZJMWo1 (ORCPT ); Tue, 13 Oct 2009 18:44:27 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:41409 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761602AbZJMWo0 (ORCPT ); Tue, 13 Oct 2009 18:44:26 -0400 Date: Tue, 13 Oct 2009 15:42:56 -0700 (PDT) From: Linus Torvalds X-X-Sender: torvalds@localhost.localdomain To: Paul Fulghum cc: Boyan , =?ISO-8859-15?Q?=22Fr=E9d=E9ric_L=2E_W=2E_Meunier=22?= , "Justin P. Mattock" , Nix , Alan Cox , "Rafael J. Wysocki" , Linux Kernel Mailing List , Kernel Testers List , Dmitry Torokhov , Ed Tomlinson , OGAWA Hirofumi Subject: Re: [Bug #14388] keyboard under X with 2.6.31 In-Reply-To: <4AD4F548.2030506@microgate.com> Message-ID: References: <56acieJJ2fF.A.nEB.Hzl0KB@chimera> <87ljjgfcbu.fsf@spindle.srvr.nix> <4AD3F769.5080405@gmail.com> <4AD437F9.9020708@yahoo.co.uk> <4AD4DE4C.4010402@yahoo.co.uk> <4AD4F548.2030506@microgate.com> User-Agent: Alpine 2.01 (LFD 1184 2008-12-16) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2034 Lines: 46 On Tue, 13 Oct 2009, Paul Fulghum wrote: > > If flush_to_ldisc() is reentered with the head set to null, nothing > is done. New buffers can be added where you say, but they are > added to the tail. So the order of flushed data is retained. They are added to the tail only if the tail is non-NULL. And buf.tail, in turn, is protected by the TTY_FLUSHING bit. And look what happens to TTY_FLUSHING if flush_to_ldisc() is called by multiple contexts - it doesn't nest right. The inner "flush_to_ldisc()" will clear the bit (your "nothing is done" case). Now, I agree that we can solve things differently. We could, for example, get rid of TTY_FLUSHING entirely. If you want to keep the crazy "head = NULL" special case, we could basically replace all tests of TTY_FLUSHING with "tty->buf.tail && !tty->buf.head" instead, and use _that_ as a "the TTY is in the middle of a flush" operation. That should be 100% equivalent to my patch. I do object to the whole crazy subtle TTY locking. I'm convinced it's wrong, and I'm convinced it's wrong exactly _because_ it tries to be so subtle and does non-obvious things. That's why my patch also changed the whole loop logic: it's not subtle any more. Not only did I make TTY_FLUSHING nest correctly, I also stopped playing games with buf.head: it's now purely a list, rather than "a list and a failed attempt to lock". And no, I'm not sure my patch helps. I'd have expected 'tty_buffer_flush()' to be something very rare, for example. But I also didn't really check if we may do it some other way. But I _am_ sure that it makes the code a whole lot more straightforward. Bits that say "we're busy flushing" suddenly actually act that way, and pointers that say "this is the head of the buffers" also act that wy. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/